@simple-builder/react 1.0.21 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/{build-container-client-UTWTM32L.css → build-container-client-6NICVHM7.css} +244 -13
  2. package/dist/build-container-client-BAVL356F.js +2282 -0
  3. package/dist/build-container-client-KI3QULNY.mjs +2246 -0
  4. package/dist/build-container-client-UYQEUZU5.mjs +2251 -0
  5. package/dist/build-container-client-XVX67J7D.js +2287 -0
  6. package/dist/{builder-content-BGBWMI6B.js → builder-content-2CLARIDQ.js} +7 -7
  7. package/dist/{builder-content-RQZGNHGE.mjs → builder-content-J45ZXXEM.mjs} +2 -2
  8. package/dist/{builder-content-JWIMCW6L.css → builder-content-P24OTLH4.css} +244 -13
  9. package/dist/builder-content-Y7KZGM4Z.js +42 -0
  10. package/dist/builder-content-YOL4MKX3.mjs +20 -0
  11. package/dist/{chunk-SMX2JVU7.js → chunk-47IWLKYO.js} +1 -1
  12. package/dist/{chunk-YM22QCRZ.mjs → chunk-527WHDFS.mjs} +1 -1
  13. package/dist/chunk-F7EVAQN7.mjs +123 -0
  14. package/dist/{chunk-KD2J6VPO.mjs → chunk-FUIGTZRW.mjs} +2 -2
  15. package/dist/{chunk-Q2EMWEEZ.js → chunk-IAIJXTFG.js} +28 -21
  16. package/dist/chunk-ISTZWAYI.js +263 -0
  17. package/dist/{chunk-GQ2NJQNP.js → chunk-M2YJU6AM.js} +3 -3
  18. package/dist/chunk-MV72DQML.mjs +20 -0
  19. package/dist/{chunk-JDY3WVEQ.mjs → chunk-Q42UV6O3.mjs} +25 -18
  20. package/dist/chunk-TZQPIYI7.mjs +238 -0
  21. package/dist/chunk-U3LGZ4IJ.js +42 -0
  22. package/dist/chunk-ZEA47N62.js +153 -0
  23. package/dist/index.css +244 -13
  24. package/dist/index.js +6 -6
  25. package/dist/index.mjs +2 -2
  26. package/package.json +18 -5
  27. package/dist/build-container-client-EGUVIJQE.mjs +0 -1479
  28. package/dist/build-container-client-VLVAC2RM.js +0 -1509
@@ -0,0 +1,2251 @@
1
+ 'use client';
2
+ 'use client';
3
+ 'use client';
4
+ 'use client';
5
+ 'use client';
6
+ import './chunk-FUIGTZRW.mjs';
7
+ import { buttonVariants, Button, useBuilder } from './chunk-TZQPIYI7.mjs';
8
+ import { cn, tv, DesignWrapper, builder, Image } from './chunk-527WHDFS.mjs';
9
+ import * as React25 from 'react';
10
+ import { useCallback } from 'react';
11
+ 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';
12
+ import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
13
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
14
+ import { mergeAttributes, getMarkRange, EditorContent, useEditor } from '@tiptap/react';
15
+ import { Color } from '@tiptap/extension-color';
16
+ import { TextStyle } from '@tiptap/extension-text-style';
17
+ import { Underline } from '@tiptap/extension-underline';
18
+ import { StarterKit } from '@tiptap/starter-kit';
19
+ import TiptapLink from '@tiptap/extension-link';
20
+ import { Plugin, TextSelection } from '@tiptap/pm/state';
21
+ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
22
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
23
+ import * as TogglePrimitive from '@radix-ui/react-toggle';
24
+ import { cva } from 'class-variance-authority';
25
+ import { LuChevronDown, LuCheck, LuHeading, LuLink2, LuEllipsis, LuBold, LuItalic, LuUnderline, LuStrikethrough, LuCode, LuRemoveFormatting, LuQuote, LuMinus, LuListOrdered, LuList } from 'react-icons/lu';
26
+ import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
27
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
28
+ import { Slot } from '@radix-ui/react-slot';
29
+ import { useFormContext, useForm, useFieldArray, FormProvider, Controller } from 'react-hook-form';
30
+ import * as LabelPrimitive from '@radix-ui/react-label';
31
+ import * as SwitchPrimitives from '@radix-ui/react-switch';
32
+ import { zodResolver } from '@hookform/resolvers/zod';
33
+ import { z } from 'zod';
34
+ import { format } from 'date-fns';
35
+ import { DayPicker } from 'react-day-picker';
36
+ import * as SelectPrimitive from '@radix-ui/react-select';
37
+ import * as TabsPrimitive from '@radix-ui/react-tabs';
38
+ import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
39
+
40
+ var AlertDialog = AlertDialogPrimitive.Root;
41
+ var AlertDialogTrigger = AlertDialogPrimitive.Trigger;
42
+ var AlertDialogPortal = AlertDialogPrimitive.Portal;
43
+ var AlertDialogOverlay = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
44
+ AlertDialogPrimitive.Overlay,
45
+ {
46
+ className: cn(
47
+ "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",
48
+ className
49
+ ),
50
+ ...props,
51
+ ref
52
+ }
53
+ ));
54
+ AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
55
+ var AlertDialogContent = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(AlertDialogPortal, null, /* @__PURE__ */ React25.createElement(AlertDialogOverlay, null), /* @__PURE__ */ React25.createElement(
56
+ AlertDialogPrimitive.Content,
57
+ {
58
+ ref,
59
+ className: cn(
60
+ "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",
61
+ className
62
+ ),
63
+ ...props
64
+ }
65
+ )));
66
+ AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
67
+ var AlertDialogFooter = ({
68
+ className,
69
+ ...props
70
+ }) => /* @__PURE__ */ React25.createElement(
71
+ "div",
72
+ {
73
+ className: cn(
74
+ "sb-flex sb-flex-col-reverse sm:sb-flex-row sm:sb-justify-end sm:sb-space-x-2",
75
+ className
76
+ ),
77
+ ...props
78
+ }
79
+ );
80
+ AlertDialogFooter.displayName = "AlertDialogFooter";
81
+ var AlertDialogTitle = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
82
+ AlertDialogPrimitive.Title,
83
+ {
84
+ ref,
85
+ className: cn("sb-text-lg sb-font-semibold", className),
86
+ ...props
87
+ }
88
+ ));
89
+ AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
90
+ var AlertDialogDescription = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
91
+ AlertDialogPrimitive.Description,
92
+ {
93
+ ref,
94
+ className: cn("sb-text-sm sb-text-muted-foreground", className),
95
+ ...props
96
+ }
97
+ ));
98
+ AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
99
+ var AlertDialogAction = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
100
+ AlertDialogPrimitive.Action,
101
+ {
102
+ ref,
103
+ className: cn(buttonVariants(), className),
104
+ ...props
105
+ }
106
+ ));
107
+ AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
108
+ var AlertDialogCancel = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
109
+ AlertDialogPrimitive.Cancel,
110
+ {
111
+ ref,
112
+ className: cn(
113
+ buttonVariants({ variant: "outline" }),
114
+ "sb-mt-2 sm:sb-mt-0",
115
+ className
116
+ ),
117
+ ...props
118
+ }
119
+ ));
120
+ AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
121
+ var Popover = PopoverPrimitive.Root;
122
+ var PopoverTrigger = PopoverPrimitive.Trigger;
123
+ var PopoverClose = PopoverPrimitive.Close;
124
+ var PopoverContent = React25.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React25.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React25.createElement(
125
+ PopoverPrimitive.Content,
126
+ {
127
+ ref,
128
+ align,
129
+ sideOffset,
130
+ className: cn(
131
+ "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]",
132
+ className
133
+ ),
134
+ ...props
135
+ }
136
+ )));
137
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
138
+ var Link = TiptapLink.extend({
139
+ inclusive: false,
140
+ parseHTML() {
141
+ return [{ tag: 'a[href]:not([data-type="button"]):not([href *= "javascript:" i])' }];
142
+ },
143
+ renderHTML({ HTMLAttributes }) {
144
+ return ["a", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
145
+ },
146
+ addOptions() {
147
+ return {
148
+ ...this.parent?.(),
149
+ openOnClick: false
150
+ };
151
+ },
152
+ addProseMirrorPlugins() {
153
+ return [
154
+ ...this.parent?.() || [],
155
+ new Plugin({
156
+ props: {
157
+ handleClick(view, pos) {
158
+ const { schema: schema2, doc, tr } = view.state;
159
+ const range = getMarkRange(doc.resolve(pos), schema2.marks.link);
160
+ if (!range) {
161
+ return;
162
+ }
163
+ const { from, to } = range;
164
+ const start = Math.min(from, to);
165
+ const end = Math.max(from, to);
166
+ if (pos < start || pos > end) {
167
+ return;
168
+ }
169
+ const $start = doc.resolve(start);
170
+ const $end = doc.resolve(end);
171
+ const transaction = tr.setSelection(new TextSelection($start, $end));
172
+ view.dispatch(transaction);
173
+ }
174
+ }
175
+ })
176
+ ];
177
+ }
178
+ });
179
+
180
+ // src/features/rich-text-editor/utils/get-output.ts
181
+ var getOutput = (editor, format2) => {
182
+ switch (format2) {
183
+ case "json":
184
+ return editor.getJSON();
185
+ case "html":
186
+ return editor.isEmpty ? "" : editor.getHTML();
187
+ default:
188
+ return editor.getText();
189
+ }
190
+ };
191
+
192
+ // src/features/rich-text-editor/hooks/useRichTextEditor.ts
193
+ var useRichTextEditor = ({
194
+ value,
195
+ output = "html",
196
+ editorClassName,
197
+ onUpdate,
198
+ onBlur,
199
+ ...options
200
+ }) => {
201
+ const handleCreate = useCallback(
202
+ (editor2) => {
203
+ if (value && editor2.isEmpty) {
204
+ editor2.commands.setContent(value);
205
+ }
206
+ },
207
+ [value]
208
+ );
209
+ const handleUpdate = useCallback(
210
+ (editor2) => {
211
+ onUpdate?.(getOutput(editor2, output));
212
+ },
213
+ [output]
214
+ );
215
+ const handleBlur = useCallback(
216
+ (editor2) => {
217
+ onBlur?.(getOutput(editor2, output));
218
+ },
219
+ [output, onBlur]
220
+ );
221
+ const editor = useEditor({
222
+ extensions: [StarterKit, Underline, Color, TextStyle, Link],
223
+ editorProps: {
224
+ attributes: {
225
+ autocomplete: "off",
226
+ autocorrect: "off",
227
+ autocapitalize: "off",
228
+ class: cn("sb-focus:outline-none", editorClassName)
229
+ }
230
+ },
231
+ onCreate: ({ editor: editor2 }) => handleCreate(editor2),
232
+ onUpdate: ({ editor: editor2 }) => handleUpdate(editor2),
233
+ onBlur: ({ editor: editor2 }) => handleBlur(editor2),
234
+ ...options
235
+ });
236
+ return editor;
237
+ };
238
+ var DropdownMenu = DropdownMenuPrimitive.Root;
239
+ var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
240
+ var DropdownMenuSubTrigger = React25.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
241
+ DropdownMenuPrimitive.SubTrigger,
242
+ {
243
+ ref,
244
+ className: cn(
245
+ "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",
246
+ inset && "sb-pl-8",
247
+ className
248
+ ),
249
+ ...props
250
+ },
251
+ children,
252
+ /* @__PURE__ */ React25.createElement(ChevronRight, { className: "sb-ml-auto" })
253
+ ));
254
+ DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
255
+ var DropdownMenuSubContent = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
256
+ DropdownMenuPrimitive.SubContent,
257
+ {
258
+ ref,
259
+ className: cn(
260
+ "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]",
261
+ className
262
+ ),
263
+ ...props
264
+ }
265
+ ));
266
+ DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
267
+ var DropdownMenuContent = React25.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React25.createElement(DropdownMenuPrimitive.Portal, null, /* @__PURE__ */ React25.createElement(
268
+ DropdownMenuPrimitive.Content,
269
+ {
270
+ ref,
271
+ sideOffset,
272
+ className: cn(
273
+ "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",
274
+ "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]",
275
+ className
276
+ ),
277
+ ...props
278
+ }
279
+ )));
280
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
281
+ var DropdownMenuItem = React25.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ React25.createElement(
282
+ DropdownMenuPrimitive.Item,
283
+ {
284
+ ref,
285
+ className: cn(
286
+ "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",
287
+ inset && "sb-pl-8",
288
+ className
289
+ ),
290
+ ...props
291
+ }
292
+ ));
293
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
294
+ var DropdownMenuCheckboxItem = React25.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ React25.createElement(
295
+ DropdownMenuPrimitive.CheckboxItem,
296
+ {
297
+ ref,
298
+ className: cn(
299
+ "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",
300
+ className
301
+ ),
302
+ checked,
303
+ ...props
304
+ },
305
+ /* @__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" }))),
306
+ children
307
+ ));
308
+ DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
309
+ var DropdownMenuRadioItem = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
310
+ DropdownMenuPrimitive.RadioItem,
311
+ {
312
+ ref,
313
+ className: cn(
314
+ "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",
315
+ className
316
+ ),
317
+ ...props
318
+ },
319
+ /* @__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" }))),
320
+ children
321
+ ));
322
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
323
+ var DropdownMenuLabel = React25.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ React25.createElement(
324
+ DropdownMenuPrimitive.Label,
325
+ {
326
+ ref,
327
+ className: cn(
328
+ "sb-px-2 sb-py-1.5 sb-text-sm sb-font-semibold",
329
+ inset && "sb-pl-8",
330
+ className
331
+ ),
332
+ ...props
333
+ }
334
+ ));
335
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
336
+ var DropdownMenuSeparator = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
337
+ DropdownMenuPrimitive.Separator,
338
+ {
339
+ ref,
340
+ className: cn("sb--mx-1 sb-my-1 sb-h-px sb-bg-muted", className),
341
+ ...props
342
+ }
343
+ ));
344
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
345
+ var Separator2 = React25.forwardRef(
346
+ ({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ React25.createElement(
347
+ SeparatorPrimitive.Root,
348
+ {
349
+ ref,
350
+ decorative,
351
+ orientation,
352
+ className: cn(
353
+ "sb-shrink-0 sb-bg-border",
354
+ orientation === "horizontal" ? "sb-h-[1px] sb-w-full" : "sb-h-full sb-w-[1px]",
355
+ className
356
+ ),
357
+ ...props
358
+ }
359
+ )
360
+ );
361
+ Separator2.displayName = SeparatorPrimitive.Root.displayName;
362
+ var toggleVariants = cva(
363
+ "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",
364
+ {
365
+ variants: {
366
+ variant: {
367
+ default: "sb-bg-transparent",
368
+ outline: "sb-border sb-border-input sb-bg-transparent sb-shadow-sm hover:sb-bg-accent hover:sb-text-accent-foreground"
369
+ },
370
+ size: {
371
+ default: "sb-h-9 sb-px-2 sb-min-w-9",
372
+ sm: "sb-h-8 sb-px-1.5 sb-min-w-8",
373
+ lg: "sb-h-10 sb-px-2.5 sb-min-w-10"
374
+ }
375
+ },
376
+ defaultVariants: {
377
+ variant: "default",
378
+ size: "default"
379
+ }
380
+ }
381
+ );
382
+ var Toggle = React25.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ React25.createElement(
383
+ TogglePrimitive.Root,
384
+ {
385
+ ref,
386
+ className: cn(toggleVariants({ variant, size, className })),
387
+ ...props
388
+ }
389
+ ));
390
+ Toggle.displayName = TogglePrimitive.Root.displayName;
391
+ var ToggleGroupContext = React25.createContext({
392
+ size: "default",
393
+ variant: "default"
394
+ });
395
+ var ToggleGroup = React25.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
396
+ ToggleGroupPrimitive.Root,
397
+ {
398
+ ref,
399
+ className: cn("sb-flex sb-items-center sb-justify-center sb-gap-1", className),
400
+ ...props
401
+ },
402
+ /* @__PURE__ */ React25.createElement(ToggleGroupContext.Provider, { value: { variant, size } }, children)
403
+ ));
404
+ ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
405
+ var ToggleGroupItem = React25.forwardRef(({ className, children, variant, size, ...props }, ref) => {
406
+ const context = React25.useContext(ToggleGroupContext);
407
+ return /* @__PURE__ */ React25.createElement(
408
+ ToggleGroupPrimitive.Item,
409
+ {
410
+ ref,
411
+ className: cn(
412
+ toggleVariants({
413
+ variant: context.variant || variant,
414
+ size: context.size || size
415
+ }),
416
+ className
417
+ ),
418
+ ...props
419
+ },
420
+ children
421
+ );
422
+ });
423
+ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
424
+ var PALETTES = [
425
+ {
426
+ inverse: "hsl(var(--background))",
427
+ colors: [
428
+ { cssVar: "hsl(var(--foreground))" },
429
+ { cssVar: "hsl(var(--secondary-foreground))" },
430
+ { cssVar: "hsl(var(--muted-foreground))" },
431
+ { cssVar: "hsl(var(--accent-foreground))" },
432
+ { cssVar: "hsl(var(--destructive-foreground))" }
433
+ ]
434
+ },
435
+ {
436
+ inverse: "hsl(var(--foreground))",
437
+ colors: [
438
+ { cssVar: "hsl(var(--background))" },
439
+ { cssVar: "hsl(var(--secondary))" },
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 = ({
1011
+ className,
1012
+ ...props
1013
+ }) => {
1014
+ return /* @__PURE__ */ React25.createElement(
1015
+ Toggle,
1016
+ {
1017
+ size: "sm",
1018
+ className: cn(
1019
+ "sb-size-8 sb-p-0 data-[state=on]:sb-bg-accent",
1020
+ { "sb-bg-accent": props.pressed },
1021
+ className
1022
+ ),
1023
+ ...props
1024
+ }
1025
+ );
1026
+ };
1027
+
1028
+ // src/features/rich-text-editor/components/rich-text-editor.tsx
1029
+ var RichTextEditor = ({
1030
+ value,
1031
+ onChange,
1032
+ className,
1033
+ editorClassName,
1034
+ editorContentClassName,
1035
+ ...props
1036
+ }) => {
1037
+ const editor = useRichTextEditor({
1038
+ value,
1039
+ onUpdate: onChange,
1040
+ editorClassName: cn("sb-flex-1 sb-px-3 sb-py-1", editorClassName),
1041
+ ...props
1042
+ });
1043
+ if (!editor) {
1044
+ return null;
1045
+ }
1046
+ return /* @__PURE__ */ React25.createElement(
1047
+ "div",
1048
+ {
1049
+ className: cn(
1050
+ "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",
1051
+ className
1052
+ )
1053
+ },
1054
+ /* @__PURE__ */ React25.createElement(Toolbar, { editor }),
1055
+ /* @__PURE__ */ React25.createElement(
1056
+ EditorContent,
1057
+ {
1058
+ editor,
1059
+ className: cn(
1060
+ "sb-editflow sb-prose sb-flex sb-flex-1",
1061
+ editorContentClassName
1062
+ )
1063
+ }
1064
+ )
1065
+ );
1066
+ };
1067
+ function Calendar({
1068
+ className,
1069
+ classNames,
1070
+ showOutsideDays = true,
1071
+ ...props
1072
+ }) {
1073
+ return /* @__PURE__ */ React25.createElement(
1074
+ DayPicker,
1075
+ {
1076
+ showOutsideDays,
1077
+ className: cn("sb-p-3 sb-font-roboto", className),
1078
+ classNames: {
1079
+ months: "sb-flex sb-flex-col sm:sb-flex-row sb-space-y-4 sm:sb-space-x-4 sm:sb-space-y-0",
1080
+ month: "sb-space-y-4",
1081
+ caption: "sb-flex sb-justify-center sb-pt-1 sb-relative sb-items-center",
1082
+ caption_label: "sb-text-sm sb-font-medium",
1083
+ nav: "sb-space-x-1 sb-flex sb-items-center",
1084
+ nav_button: cn(
1085
+ buttonVariants({ variant: "outline" }),
1086
+ "sb-h-7 sb-w-7 sb-bg-transparent sb-p-0 sb-opacity-50 hover:sb-opacity-100"
1087
+ ),
1088
+ nav_button_previous: "sb-absolute sb-left-1",
1089
+ nav_button_next: "sb-absolute sb-right-1",
1090
+ table: "sb-w-full sb-border-collapse sb-space-y-1",
1091
+ head_row: "sb-flex",
1092
+ head_cell: "sb-text-muted-foreground sb-rounded-md sb-w-8 sb-font-normal sb-text-[0.8rem]",
1093
+ row: "sb-flex sb-w-full sb-mt-2",
1094
+ cell: cn(
1095
+ "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",
1096
+ 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"
1097
+ ),
1098
+ day: cn(
1099
+ buttonVariants({ variant: "ghost" }),
1100
+ "sb-h-8 sb-w-8 sb-p-0 sb-font-normal aria-selected:sb-opacity-100"
1101
+ ),
1102
+ day_range_start: "day-range-start",
1103
+ day_range_end: "day-range-end",
1104
+ 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",
1105
+ day_today: "sb-bg-accent sb-text-accent-foreground",
1106
+ 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",
1107
+ day_disabled: "sb-text-muted-foreground sb-opacity-50",
1108
+ day_range_middle: "aria-selected:sb-bg-accent aria-selected:sb-text-accent-foreground",
1109
+ day_hidden: "invisible",
1110
+ ...classNames
1111
+ },
1112
+ components: {
1113
+ IconLeft: () => /* @__PURE__ */ React25.createElement(ChevronLeftIcon, { className: "sb-h-4 sb-w-4" }),
1114
+ IconRight: () => /* @__PURE__ */ React25.createElement(ChevronRightIcon, { className: "sb-h-4 sb-w-4" })
1115
+ },
1116
+ ...props
1117
+ }
1118
+ );
1119
+ }
1120
+ Calendar.displayName = "Calendar";
1121
+ var ColorPicker = (props) => {
1122
+ const { color, onColorChange, className } = props;
1123
+ const colors = props.colors ?? [
1124
+ "#000000",
1125
+ "#ffffff",
1126
+ "#0f172a",
1127
+ "#F1F5F9",
1128
+ "#64748B",
1129
+ "#E6007E",
1130
+ "#F8FAFC",
1131
+ "#009DD1",
1132
+ "#FF0000"
1133
+ ];
1134
+ return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
1135
+ Button,
1136
+ {
1137
+ variant: "outline",
1138
+ size: "sm",
1139
+ className: cn(
1140
+ "sb-justify-start sb-text-left sb-font-normal sb-normal-case sb-w-full",
1141
+ !color && "sb-text-muted-foreground",
1142
+ className
1143
+ )
1144
+ },
1145
+ /* @__PURE__ */ React25.createElement("div", { className: "sb-w-full sb-flex sb-items-center sb-gap-2" }, color ? /* @__PURE__ */ React25.createElement(
1146
+ "div",
1147
+ {
1148
+ className: "sb-h-4 sb-w-4 sb-rounded !sb-bg-center !sb-bg-cover sb-transition-all sb-border",
1149
+ style: { background: color }
1150
+ }
1151
+ ) : /* @__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"))
1152
+ )), /* @__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(
1153
+ "div",
1154
+ {
1155
+ key: s,
1156
+ style: { background: s },
1157
+ className: "sb-rounded-md sb-h-6 sb-w-6 sb-cursor-pointer active:sb-scale-105 sb-border",
1158
+ onClick: () => onColorChange(s)
1159
+ }
1160
+ ))));
1161
+ };
1162
+ var MediaInput = (props) => {
1163
+ const { onFilesChange, limit = 32, multiple = false, onError } = props;
1164
+ const id = React25.useId();
1165
+ const [queue, setQueue] = React25.useState([]);
1166
+ const [sources, setSources] = React25.useState(props.files ?? []);
1167
+ const maxConcurrentUploads = 3;
1168
+ const uploadingCountRef = React25.useRef(0);
1169
+ const handleFilesAdd = async (e) => {
1170
+ const files = e.target.files;
1171
+ if (!files || files.length === 0) {
1172
+ return;
1173
+ }
1174
+ if (files.length + sources.length > (multiple ? limit : 1)) {
1175
+ onError?.(
1176
+ new MediaInputError(
1177
+ `Maximaal ${limit} bestanden.`,
1178
+ `Je probeerde nu ${files.length + sources.length} bestanden toe te voegen, maar je mag er maximaal ${limit} toevoegen.`
1179
+ )
1180
+ );
1181
+ return;
1182
+ }
1183
+ const queue2 = Array.from(files);
1184
+ setQueue(queue2);
1185
+ for (const file of queue2) {
1186
+ try {
1187
+ while (uploadingCountRef.current >= maxConcurrentUploads && uploadingCountRef.current > 0) {
1188
+ await new Promise((resolve) => setTimeout(resolve, 300));
1189
+ }
1190
+ uploadingCountRef.current++;
1191
+ const formData = new FormData();
1192
+ formData.append("file", file);
1193
+ const res = await fetch("/api/simple-builder/file/upload", {
1194
+ method: "POST",
1195
+ body: formData
1196
+ });
1197
+ if (res === void 0 || !res.ok) {
1198
+ onError?.(
1199
+ new MediaInputError(
1200
+ "Bestand uploaden misulukt",
1201
+ `Bestand ${file.name} kon niet worden ge\xFCpload.`
1202
+ )
1203
+ );
1204
+ continue;
1205
+ }
1206
+ const { data: url } = await res.json();
1207
+ if (!url) {
1208
+ onError?.(
1209
+ new MediaInputError(
1210
+ "Bestand uploaden misulukt",
1211
+ `De URL van bestand ${file.name} kon niet worden opgehaald.`
1212
+ )
1213
+ );
1214
+ continue;
1215
+ }
1216
+ setSources((prev) => [...prev, url]);
1217
+ onFilesChange?.([...sources, url]);
1218
+ } catch (e2) {
1219
+ onError?.(
1220
+ new MediaInputError(
1221
+ "Bestand uploaden misulukt",
1222
+ `Bestand ${file.name} kon niet worden ge\xFCpload.`
1223
+ )
1224
+ );
1225
+ } finally {
1226
+ setQueue((prev) => prev.filter((f) => f !== file));
1227
+ uploadingCountRef.current--;
1228
+ }
1229
+ }
1230
+ };
1231
+ const handleSourceDelete = async (src) => {
1232
+ setSources((prev) => prev.filter((s) => s !== src));
1233
+ onFilesChange?.(sources.filter((s) => s !== src));
1234
+ await fetch("/api/uploadthing/delete", {
1235
+ method: "POST",
1236
+ body: JSON.stringify({ src })
1237
+ });
1238
+ };
1239
+ 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(
1240
+ Image,
1241
+ {
1242
+ src,
1243
+ alt: "",
1244
+ fill: true,
1245
+ className: "sb-absolute sb-inset-0 sb-object-cover sb-pointer-events-none"
1246
+ }
1247
+ ), /* @__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(
1248
+ "button",
1249
+ {
1250
+ 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",
1251
+ onClick: () => handleSourceDelete(src)
1252
+ },
1253
+ /* @__PURE__ */ React25.createElement(Trash2Icon, { className: "sb-h-4 sb-w-4" })
1254
+ )))), queue.map((_, i) => /* @__PURE__ */ React25.createElement(
1255
+ MediaInputItem,
1256
+ {
1257
+ key: i,
1258
+ className: cn(
1259
+ "sb-flex sb-h-28 sb-w-28 sb-items-center sb-justify-center",
1260
+ props.itemClassName
1261
+ )
1262
+ },
1263
+ /* @__PURE__ */ React25.createElement(Loader2Icon, { className: "sb-h-6 sb-w-6 sb-animate-spin" })
1264
+ )), multiple || !multiple && !sources.length && !queue.length ? /* @__PURE__ */ React25.createElement(
1265
+ "label",
1266
+ {
1267
+ htmlFor: id,
1268
+ className: cn(
1269
+ "sb-flex sb-h-28 sb-w-28 sb-cursor-pointer sb-items-center sb-justify-center sb-rounded-lg sb-border",
1270
+ props.itemClassName
1271
+ )
1272
+ },
1273
+ /* @__PURE__ */ React25.createElement(PlusIcon, { className: "sb-h-6 sb-w-6" }),
1274
+ /* @__PURE__ */ React25.createElement(
1275
+ "input",
1276
+ {
1277
+ id,
1278
+ type: "file",
1279
+ onChange: handleFilesAdd,
1280
+ multiple,
1281
+ accept: ".png,.jpg,.jpeg,.webp,.gif,.svg",
1282
+ className: "sb-hidden"
1283
+ }
1284
+ )
1285
+ ) : null);
1286
+ };
1287
+ var MediaInputItem = (props) => {
1288
+ return /* @__PURE__ */ React25.createElement(
1289
+ "div",
1290
+ {
1291
+ className: cn(
1292
+ "sb-relative sb-h-28 sb-w-28 sb-overflow-hidden sb-rounded-lg sb-border",
1293
+ props.className
1294
+ )
1295
+ },
1296
+ props.children
1297
+ );
1298
+ };
1299
+ var MediaInputError = class extends Error {
1300
+ title;
1301
+ description;
1302
+ constructor(message, description) {
1303
+ super(message);
1304
+ this.title = message;
1305
+ this.description = description;
1306
+ }
1307
+ };
1308
+ var Select = SelectPrimitive.Root;
1309
+ var SelectValue = SelectPrimitive.Value;
1310
+ var SelectTrigger = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1311
+ SelectPrimitive.Trigger,
1312
+ {
1313
+ ref,
1314
+ className: cn(
1315
+ "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",
1316
+ className
1317
+ ),
1318
+ ...props
1319
+ },
1320
+ children,
1321
+ /* @__PURE__ */ React25.createElement(SelectPrimitive.Icon, { asChild: true }, /* @__PURE__ */ React25.createElement(ChevronDown, { className: "sb-h-4 sb-w-4 sb-opacity-50" }))
1322
+ ));
1323
+ SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
1324
+ var SelectScrollUpButton = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1325
+ SelectPrimitive.ScrollUpButton,
1326
+ {
1327
+ ref,
1328
+ className: cn(
1329
+ "sb-flex sb-cursor-default sb-items-center sb-justify-center sb-py-1",
1330
+ className
1331
+ ),
1332
+ ...props
1333
+ },
1334
+ /* @__PURE__ */ React25.createElement(ChevronUp, { className: "sb-h-4 sb-w-4" })
1335
+ ));
1336
+ SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
1337
+ var SelectScrollDownButton = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1338
+ SelectPrimitive.ScrollDownButton,
1339
+ {
1340
+ ref,
1341
+ className: cn(
1342
+ "sb-flex sb-cursor-default sb-items-center sb-justify-center sb-py-1",
1343
+ className
1344
+ ),
1345
+ ...props
1346
+ },
1347
+ /* @__PURE__ */ React25.createElement(ChevronDown, { className: "sb-h-4 sb-w-4" })
1348
+ ));
1349
+ SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
1350
+ var SelectContent = React25.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ React25.createElement(SelectPrimitive.Portal, null, /* @__PURE__ */ React25.createElement(
1351
+ SelectPrimitive.Content,
1352
+ {
1353
+ ref,
1354
+ className: cn(
1355
+ "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",
1356
+ 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",
1357
+ className
1358
+ ),
1359
+ position,
1360
+ ...props
1361
+ },
1362
+ /* @__PURE__ */ React25.createElement(SelectScrollUpButton, null),
1363
+ /* @__PURE__ */ React25.createElement(
1364
+ SelectPrimitive.Viewport,
1365
+ {
1366
+ className: cn(
1367
+ "sb-p-1",
1368
+ position === "popper" && "sb-h-[var(--radix-select-trigger-height)] sb-w-full sb-min-w-[var(--radix-select-trigger-width)]"
1369
+ )
1370
+ },
1371
+ children
1372
+ ),
1373
+ /* @__PURE__ */ React25.createElement(SelectScrollDownButton, null)
1374
+ )));
1375
+ SelectContent.displayName = SelectPrimitive.Content.displayName;
1376
+ var SelectLabel = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1377
+ SelectPrimitive.Label,
1378
+ {
1379
+ ref,
1380
+ className: cn(
1381
+ "sb-py-1.5 sb-pl-8 sb-pr-2 sb-text-sm sb-font-semibold",
1382
+ className
1383
+ ),
1384
+ ...props
1385
+ }
1386
+ ));
1387
+ SelectLabel.displayName = SelectPrimitive.Label.displayName;
1388
+ var SelectItem = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1389
+ SelectPrimitive.Item,
1390
+ {
1391
+ ref,
1392
+ className: cn(
1393
+ "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",
1394
+ className
1395
+ ),
1396
+ ...props
1397
+ },
1398
+ /* @__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" }))),
1399
+ /* @__PURE__ */ React25.createElement(SelectPrimitive.ItemText, null, children)
1400
+ ));
1401
+ SelectItem.displayName = SelectPrimitive.Item.displayName;
1402
+ var SelectSeparator = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1403
+ SelectPrimitive.Separator,
1404
+ {
1405
+ ref,
1406
+ className: cn("sb--mx-1 sb-my-1 sb-h-px sb-bg-muted", className),
1407
+ ...props
1408
+ }
1409
+ ));
1410
+ SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
1411
+ var Textarea = React25.forwardRef(
1412
+ ({ className, ...props }, ref) => {
1413
+ return /* @__PURE__ */ React25.createElement(
1414
+ "textarea",
1415
+ {
1416
+ className: cn(
1417
+ "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",
1418
+ className
1419
+ ),
1420
+ ref,
1421
+ ...props
1422
+ }
1423
+ );
1424
+ }
1425
+ );
1426
+ Textarea.displayName = "Textarea";
1427
+
1428
+ // src/components/container-item-form.tsx
1429
+ var ContainerItemForm = (props) => {
1430
+ const { item } = props;
1431
+ const { patchItem } = useBuilder();
1432
+ const component = builder.getComponent(item.component);
1433
+ if (!component) {
1434
+ throw new Error(
1435
+ `[simple-builder]: Component with id ${item.component} not found in container item form component`
1436
+ );
1437
+ }
1438
+ const form = useForm({
1439
+ defaultValues: (component.inputs || []).reduce(
1440
+ (acc, input) => ({
1441
+ ...acc,
1442
+ [input.name]: item?.props?.[input.name] ?? input.defaultValue
1443
+ }),
1444
+ {}
1445
+ )
1446
+ });
1447
+ const onSubmit = (values) => {
1448
+ patchItem(item.id, {
1449
+ props: values
1450
+ });
1451
+ };
1452
+ React25.useEffect(() => {
1453
+ const subscription = form.watch(() => form.handleSubmit(onSubmit)());
1454
+ return () => subscription.unsubscribe();
1455
+ }, [form.watch, form.handleSubmit]);
1456
+ 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(
1457
+ RenderFormField,
1458
+ {
1459
+ key: input.name,
1460
+ type: input.type,
1461
+ input,
1462
+ form
1463
+ }
1464
+ )))));
1465
+ };
1466
+ var RenderFormField = (props) => {
1467
+ const { type, input, form } = props;
1468
+ const fieldArray = useFieldArray({
1469
+ control: form.control,
1470
+ name: input.name
1471
+ });
1472
+ if (input.multiple) {
1473
+ 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(
1474
+ (field, i) => type !== "grouped" ? /* @__PURE__ */ React25.createElement(
1475
+ FormField,
1476
+ {
1477
+ key: field.id,
1478
+ control: form.control,
1479
+ name: `${input.name}.${i}`,
1480
+ 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" })))
1481
+ }
1482
+ ) : /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-items-center sb-relative" }, /* @__PURE__ */ React25.createElement(
1483
+ RenderFormField,
1484
+ {
1485
+ key: field.id,
1486
+ form,
1487
+ type,
1488
+ input: {
1489
+ ...input,
1490
+ name: `${input.name}.${i}`,
1491
+ multiple: false,
1492
+ friendlyName: ""
1493
+ }
1494
+ }
1495
+ ), /* @__PURE__ */ React25.createElement(
1496
+ "button",
1497
+ {
1498
+ type: "button",
1499
+ onClick: () => fieldArray.remove(i),
1500
+ className: "sb-absolute sb-top-2 sb-right-2 sb-text-foreground/70 hover:sb-text-foreground"
1501
+ },
1502
+ /* @__PURE__ */ React25.createElement(XIcon, { className: "sb-h-4 sb-w-4" })
1503
+ ))
1504
+ ), /* @__PURE__ */ React25.createElement(
1505
+ Button,
1506
+ {
1507
+ type: "button",
1508
+ variant: "outline",
1509
+ size: "sm",
1510
+ className: cn(
1511
+ "sb-w-[89%] sb-border-2 sb-border-dashed sb-text-muted-foreground",
1512
+ type === "grouped" && "sb-w-full"
1513
+ ),
1514
+ onClick: () => fieldArray.append(void 0)
1515
+ },
1516
+ /* @__PURE__ */ React25.createElement(PlusCircleIcon, { className: "sb-h-4 sb-w-4" })
1517
+ )));
1518
+ }
1519
+ switch (type) {
1520
+ case "string":
1521
+ case "number":
1522
+ case "longText":
1523
+ case "color":
1524
+ case "date":
1525
+ case "file":
1526
+ return /* @__PURE__ */ React25.createElement(
1527
+ FormField,
1528
+ {
1529
+ key: input.name,
1530
+ control: form.control,
1531
+ name: input.name,
1532
+ 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))
1533
+ }
1534
+ );
1535
+ case "richText":
1536
+ 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(
1537
+ FormField,
1538
+ {
1539
+ key: input.name,
1540
+ control: form.control,
1541
+ name: input.name,
1542
+ 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))
1543
+ }
1544
+ )))));
1545
+ case "boolean":
1546
+ return /* @__PURE__ */ React25.createElement(
1547
+ FormField,
1548
+ {
1549
+ key: input.name,
1550
+ control: form.control,
1551
+ name: input.name,
1552
+ 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))
1553
+ }
1554
+ );
1555
+ case "grouped":
1556
+ 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(
1557
+ RenderFormField,
1558
+ {
1559
+ key: `${input.name}.${sub.name}`,
1560
+ type: sub.type,
1561
+ input: {
1562
+ ...sub,
1563
+ name: `${input.name}.${sub.name}`
1564
+ },
1565
+ form
1566
+ }
1567
+ ))));
1568
+ default:
1569
+ throw new Error(
1570
+ `[simple-builder]: Input type "${props.type}" not supported in render form field.`
1571
+ );
1572
+ }
1573
+ };
1574
+ var RenderInput = (props) => {
1575
+ const { type, options, field } = props;
1576
+ switch (type) {
1577
+ case "string":
1578
+ if (!options)
1579
+ return /* @__PURE__ */ React25.createElement(Input, { ...field });
1580
+ 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))));
1581
+ case "longText":
1582
+ return /* @__PURE__ */ React25.createElement(Textarea, { ...field });
1583
+ case "richText":
1584
+ return /* @__PURE__ */ React25.createElement(RichTextEditor, { ...field });
1585
+ case "number":
1586
+ return /* @__PURE__ */ React25.createElement(Input, { type: "number", ...field });
1587
+ case "color":
1588
+ return /* @__PURE__ */ React25.createElement(ColorPicker, { color: field.value, onColorChange: field.onChange });
1589
+ case "date":
1590
+ return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
1591
+ Button,
1592
+ {
1593
+ variant: "outline",
1594
+ size: "sm",
1595
+ className: cn(
1596
+ "sb-w-full sb-flex sb-justify-start sb-text-left sb-font-normal",
1597
+ !field.value && "sb-text-muted-foreground"
1598
+ )
1599
+ },
1600
+ /* @__PURE__ */ React25.createElement(CalendarIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }),
1601
+ field.value && !Array.isArray(field.value) ? format(field.value, "PPP") : /* @__PURE__ */ React25.createElement("span", null, "Pick a date")
1602
+ )), /* @__PURE__ */ React25.createElement(PopoverContent, { className: "sb-w-auto sb-p-0", align: "start" }, /* @__PURE__ */ React25.createElement(
1603
+ Calendar,
1604
+ {
1605
+ mode: "single",
1606
+ selected: field.value,
1607
+ onSelect: field.onChange,
1608
+ initialFocus: true
1609
+ }
1610
+ )));
1611
+ case "boolean":
1612
+ return /* @__PURE__ */ React25.createElement(Switch, { checked: field.value, onCheckedChange: field.onChange });
1613
+ case "file":
1614
+ return /* @__PURE__ */ React25.createElement(
1615
+ MediaInput,
1616
+ {
1617
+ className: "sb-grid sb-grid-cols-2 sb-gap-1",
1618
+ itemClassName: "sb-aspect-video sb-h-auto sb-w-full",
1619
+ multiple: false,
1620
+ files: field.value ? [field.value] : [],
1621
+ onFilesChange: (files) => field.onChange(files[0]),
1622
+ onError: (e) => console.error(
1623
+ "[media-input]: Title: " + e?.title,
1624
+ "media-input: Error: " + e?.description
1625
+ )
1626
+ }
1627
+ );
1628
+ default:
1629
+ throw new Error(
1630
+ `[simple-builder]: Input type "${props.type}" not supported in render input.`
1631
+ );
1632
+ }
1633
+ };
1634
+ var Tabs = TabsPrimitive.Root;
1635
+ var tabsListVariants = tv({
1636
+ variants: {
1637
+ variant: {
1638
+ 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",
1639
+ text: "sb-flex sb-items-center sb-border-b sb-px-4 sb-space-x-6"
1640
+ }
1641
+ },
1642
+ defaultVariants: {
1643
+ variant: "contained"
1644
+ }
1645
+ });
1646
+ var TabsList = React25.forwardRef(({ variant, className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1647
+ TabsPrimitive.List,
1648
+ {
1649
+ ref,
1650
+ className: tabsListVariants({ variant, className }),
1651
+ ...props
1652
+ }
1653
+ ));
1654
+ TabsList.displayName = TabsPrimitive.List.displayName;
1655
+ var tabsTriggerVariants = tv({
1656
+ variants: {
1657
+ variant: {
1658
+ 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",
1659
+ 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"
1660
+ }
1661
+ },
1662
+ defaultVariants: {
1663
+ variant: "contained"
1664
+ }
1665
+ });
1666
+ var TabsTrigger = React25.forwardRef(({ variant, className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1667
+ TabsPrimitive.Trigger,
1668
+ {
1669
+ ref,
1670
+ className: tabsTriggerVariants({ variant, className }),
1671
+ ...props
1672
+ }
1673
+ ));
1674
+ TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
1675
+ var TabsContent = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1676
+ TabsPrimitive.Content,
1677
+ {
1678
+ ref,
1679
+ className: cn(
1680
+ "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",
1681
+ className
1682
+ ),
1683
+ ...props
1684
+ }
1685
+ ));
1686
+ TabsContent.displayName = TabsPrimitive.Content.displayName;
1687
+
1688
+ // src/components/ui/background-picker.tsx
1689
+ var BackgroundPicker = (props) => {
1690
+ const { background, onBackgroundChange, className } = props;
1691
+ const solids = props.solids ?? [
1692
+ "#000000",
1693
+ "#ffffff",
1694
+ "#0f172a",
1695
+ "#F1F5F9",
1696
+ "#64748B",
1697
+ "#E6007E",
1698
+ "#F8FAFC",
1699
+ "#009DD1",
1700
+ "#FF0000"
1701
+ ];
1702
+ const gradients = props.gradients ?? [
1703
+ "linear-gradient(to top left,#accbee,#e7f0fd)",
1704
+ "linear-gradient(to top left,#d5d4d0,#d5d4d0,#eeeeec)"
1705
+ ];
1706
+ const images = props.images ?? [
1707
+ "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)",
1708
+ "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)"
1709
+ ];
1710
+ const defaultTab = React25.useMemo(() => {
1711
+ if (background.includes("url"))
1712
+ return "image";
1713
+ if (background.includes("gradient"))
1714
+ return "gradient";
1715
+ return "solid";
1716
+ }, [background]);
1717
+ return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
1718
+ Button,
1719
+ {
1720
+ variant: "outline",
1721
+ size: "sm",
1722
+ className: cn(
1723
+ "sb-justify-start sb-text-left sb-font-normal sb-normal-case sb-w-full",
1724
+ !background && "sb-text-muted-foreground",
1725
+ className
1726
+ )
1727
+ },
1728
+ /* @__PURE__ */ React25.createElement("div", { className: "sb-w-full sb-flex sb-items-center sb-gap-2" }, background ? /* @__PURE__ */ React25.createElement(
1729
+ "div",
1730
+ {
1731
+ className: "sb-h-4 sb-w-4 sb-rounded !sb-bg-center !sb-bg-cover sb-transition-all sb-border",
1732
+ style: { background }
1733
+ }
1734
+ ) : /* @__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"))
1735
+ )), /* @__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(
1736
+ TabsContent,
1737
+ {
1738
+ value: "solid",
1739
+ className: "data-[state=active]:sb-flex sb-flex-wrap sb-gap-1 sb-p-4"
1740
+ },
1741
+ solids.map((s) => /* @__PURE__ */ React25.createElement(
1742
+ "div",
1743
+ {
1744
+ key: s,
1745
+ style: { background: s },
1746
+ className: "sb-rounded-md sb-h-6 sb-w-6 sb-cursor-pointer active:sb-scale-105 sb-border",
1747
+ onClick: () => onBackgroundChange(s)
1748
+ }
1749
+ ))
1750
+ ), /* @__PURE__ */ React25.createElement(
1751
+ TabsContent,
1752
+ {
1753
+ value: "gradient",
1754
+ className: "data-[state=active]:sb-flex sb-flex-wrap sb-gap-1 sb-p-4"
1755
+ },
1756
+ gradients.map((s) => /* @__PURE__ */ React25.createElement(
1757
+ "div",
1758
+ {
1759
+ key: s,
1760
+ style: { background: s },
1761
+ className: "rounded-md h-6 w-6 cursor-pointer active:scale-105 border",
1762
+ onClick: () => onBackgroundChange(s)
1763
+ }
1764
+ ))
1765
+ ), /* @__PURE__ */ React25.createElement(TabsContent, { value: "image" }, /* @__PURE__ */ React25.createElement("div", { className: "sb-p-4 sb-border-b" }, /* @__PURE__ */ React25.createElement(
1766
+ MediaInput,
1767
+ {
1768
+ className: "sb-grid sb-grid-cols-2 sb-gap-1",
1769
+ itemClassName: "sb-aspect-video sb-h-auto sb-w-full",
1770
+ multiple: false,
1771
+ onFilesChange: (files) => {
1772
+ if (!files.length)
1773
+ return;
1774
+ onBackgroundChange(`url(${files[0]})`);
1775
+ },
1776
+ onError: (e) => console.error(
1777
+ "[media-input]: Title: " + e?.title,
1778
+ "media-input: Error: " + e?.description
1779
+ )
1780
+ }
1781
+ )), /* @__PURE__ */ React25.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-gap-1 sb-p-4" }, images.map((s) => /* @__PURE__ */ React25.createElement(
1782
+ "div",
1783
+ {
1784
+ key: s,
1785
+ style: { backgroundImage: s },
1786
+ 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",
1787
+ onClick: () => onBackgroundChange(s)
1788
+ }
1789
+ )))))));
1790
+ };
1791
+ var SpacingInput = (props) => {
1792
+ const [value, setValue] = React25.useState(parse(props.value || "0px"));
1793
+ const [indipendent, setIndipendent] = React25.useState(
1794
+ isIndipendent(parse(props.value || "0px"))
1795
+ );
1796
+ React25.useEffect(() => {
1797
+ if (!props.onChange)
1798
+ return;
1799
+ props.onChange(stringify(value));
1800
+ }, [value, props.onChange]);
1801
+ 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(
1802
+ AdvancedInput,
1803
+ {
1804
+ value: value.left,
1805
+ pattern: "\\d+",
1806
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, left: +value2, right: +value2 })),
1807
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalSpaceAroundIcon, { className: "sb-h-4 sb-w-4" }),
1808
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1809
+ }
1810
+ ), /* @__PURE__ */ React25.createElement(
1811
+ AdvancedInput,
1812
+ {
1813
+ value: value.top,
1814
+ pattern: "\\d+",
1815
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, top: +value2, bottom: +value2 })),
1816
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalSpaceAroundIcon, { className: "sb-h-4 sb-w-4 sb-rotate-90" }),
1817
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1818
+ }
1819
+ )) : /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(
1820
+ AdvancedInput,
1821
+ {
1822
+ value: value.left,
1823
+ pattern: "\\d+",
1824
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, left: +value2 })),
1825
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4" }),
1826
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1827
+ }
1828
+ ), /* @__PURE__ */ React25.createElement(
1829
+ AdvancedInput,
1830
+ {
1831
+ value: value.top,
1832
+ pattern: "\\d+",
1833
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, top: +value2 })),
1834
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb-rotate-90" }),
1835
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1836
+ }
1837
+ ), /* @__PURE__ */ React25.createElement(
1838
+ AdvancedInput,
1839
+ {
1840
+ value: value.right,
1841
+ pattern: "\\d+",
1842
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, right: +value2 })),
1843
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb-rotate-180" }),
1844
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1845
+ }
1846
+ ), /* @__PURE__ */ React25.createElement(
1847
+ AdvancedInput,
1848
+ {
1849
+ value: value.bottom,
1850
+ pattern: "\\d+",
1851
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, bottom: +value2 })),
1852
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb--rotate-90" }),
1853
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1854
+ }
1855
+ ))), /* @__PURE__ */ React25.createElement("div", { className: "sb-shrink-0" }, /* @__PURE__ */ React25.createElement(
1856
+ Toggle,
1857
+ {
1858
+ className: "sb-shrink-0 sb-flex sb-w-8 sb-h-8 sb-p-0",
1859
+ variant: "outline",
1860
+ size: "sm",
1861
+ pressed: indipendent,
1862
+ onPressedChange: setIndipendent
1863
+ },
1864
+ /* @__PURE__ */ React25.createElement(ScanIcon, { className: "sb-h-4 sb-w-4" })
1865
+ )));
1866
+ };
1867
+ var isIndipendent = (value) => {
1868
+ const { top, right, bottom, left } = value;
1869
+ return top !== bottom || right !== left;
1870
+ };
1871
+ var parse = (value) => {
1872
+ const matches = value.match(/(\d+)/gm);
1873
+ const [top = 0, right = 0, bottom = 0, left = 0] = matches?.map((match) => +match) || [];
1874
+ switch (matches?.length) {
1875
+ case 1:
1876
+ return { top, right: top, bottom: top, left: top };
1877
+ case 2:
1878
+ return { top, bottom: top, left: right, right };
1879
+ case 3:
1880
+ return { top, right, left: right, bottom };
1881
+ default:
1882
+ return { top, right, bottom, left };
1883
+ }
1884
+ };
1885
+ var stringify = (value) => {
1886
+ const { top, right, bottom, left } = value;
1887
+ if (top === right && top === bottom && top === left) {
1888
+ return `${top}px`;
1889
+ }
1890
+ if (top === bottom && right === left) {
1891
+ return `${top}px ${right}px`;
1892
+ }
1893
+ if (right === left) {
1894
+ return `${top}px ${right}px ${bottom}px`;
1895
+ }
1896
+ return `${top}px ${right}px ${bottom}px ${left}px`;
1897
+ };
1898
+
1899
+ // src/components/item-design-form.tsx
1900
+ var designSchema = z.object({
1901
+ container: z.coerce.boolean(),
1902
+ hidden: z.enum(["always", "mobile", "desktop", "never"]),
1903
+ desktop: z.object({
1904
+ background: z.string(),
1905
+ color: z.string(),
1906
+ padding: z.string(),
1907
+ margin: z.string()
1908
+ }),
1909
+ mobile: z.object({
1910
+ background: z.string(),
1911
+ color: z.string(),
1912
+ padding: z.string(),
1913
+ margin: z.string()
1914
+ })
1915
+ });
1916
+ var ItemDesignForm = (props) => {
1917
+ const { item } = props;
1918
+ const component = builder.getComponent(item.component);
1919
+ if (!component) {
1920
+ throw new Error(
1921
+ `[simple-builder]: Component "${item.component}" not found`
1922
+ );
1923
+ }
1924
+ const getDefaultDeviceValue = (params) => {
1925
+ const { device: device2 = "desktop", key, fallback = "" } = params;
1926
+ if (item.styles?.[device2]?.[key] !== void 0) {
1927
+ return item.styles[device2][key];
1928
+ }
1929
+ if (component.defaultStyles?.[device2]?.[key] !== void 0) {
1930
+ return component.defaultStyles[device2][key];
1931
+ }
1932
+ if (device2 === "mobile") {
1933
+ const desktopValue = getDefaultDeviceValue({
1934
+ ...params,
1935
+ device: "desktop"
1936
+ });
1937
+ if (desktopValue !== void 0) {
1938
+ return desktopValue;
1939
+ }
1940
+ }
1941
+ return fallback;
1942
+ };
1943
+ const getDefaultDeviceValues = (device2) => {
1944
+ return {
1945
+ background: getDefaultDeviceValue({ device: device2, key: "background" }),
1946
+ color: getDefaultDeviceValue({ device: device2, key: "color" }),
1947
+ padding: getDefaultDeviceValue({ device: device2, key: "padding" }),
1948
+ margin: getDefaultDeviceValue({ device: device2, key: "margin" })
1949
+ };
1950
+ };
1951
+ const form = useForm({
1952
+ resolver: zodResolver(designSchema),
1953
+ values: {
1954
+ container: item.styles?.container ?? true,
1955
+ hidden: item.styles?.hidden ?? "never",
1956
+ desktop: getDefaultDeviceValues("desktop"),
1957
+ mobile: getDefaultDeviceValues("mobile")
1958
+ }
1959
+ });
1960
+ const { patchItem } = useBuilder();
1961
+ const onSubmit = (values) => {
1962
+ const { container, hidden, desktop, mobile } = values;
1963
+ const dirtyFields = form.formState.dirtyFields;
1964
+ const desktopPatch = Object.entries(desktop).reduce(
1965
+ (acc, [key, value]) => ({
1966
+ ...acc,
1967
+ ...value && { [key]: value }
1968
+ }),
1969
+ { ...item.styles?.desktop }
1970
+ );
1971
+ const mobilePatch = Object.entries(mobile).reduce(
1972
+ (acc, [key, value]) => {
1973
+ const desktopValue = desktop[key];
1974
+ const isDirty = dirtyFields.desktop?.[key];
1975
+ if (value === desktopValue || isDirty) {
1976
+ return acc;
1977
+ }
1978
+ if (["padding", "margin"].includes(key)) {
1979
+ if (value === "0px" && desktopValue === "0px") {
1980
+ return acc;
1981
+ }
1982
+ }
1983
+ return {
1984
+ ...acc,
1985
+ ...value && { [key]: value }
1986
+ };
1987
+ },
1988
+ { ...item.styles?.mobile }
1989
+ );
1990
+ patchItem(item.id, {
1991
+ styles: {
1992
+ ...container === false && { container },
1993
+ ...hidden !== "never" && { hidden },
1994
+ ...Object.keys(desktopPatch).length && { desktop: desktopPatch },
1995
+ ...Object.keys(mobilePatch).length && { mobile: mobilePatch }
1996
+ }
1997
+ });
1998
+ };
1999
+ const [device, setDevice] = React25.useState("desktop");
2000
+ React25.useEffect(() => {
2001
+ const subscription = form.watch(() => form.handleSubmit(onSubmit)());
2002
+ return () => subscription.unsubscribe();
2003
+ }, [form.watch, form.handleSubmit]);
2004
+ 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(
2005
+ Tabs,
2006
+ {
2007
+ defaultValue: device,
2008
+ onValueChange: (device2) => setDevice(device2)
2009
+ },
2010
+ /* @__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")))
2011
+ ), /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-4" }, /* @__PURE__ */ React25.createElement(
2012
+ FormField,
2013
+ {
2014
+ control: form.control,
2015
+ key: `${device}.background`,
2016
+ name: `${device}.background`,
2017
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Achtergrond"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2018
+ BackgroundPicker,
2019
+ {
2020
+ background: field.value,
2021
+ onBackgroundChange: field.onChange
2022
+ }
2023
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2024
+ }
2025
+ ), /* @__PURE__ */ React25.createElement(
2026
+ FormField,
2027
+ {
2028
+ control: form.control,
2029
+ key: `${device}.color`,
2030
+ name: `${device}.color`,
2031
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Inhoud kleur"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2032
+ ColorPicker,
2033
+ {
2034
+ color: field.value,
2035
+ onColorChange: field.onChange
2036
+ }
2037
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2038
+ }
2039
+ ), /* @__PURE__ */ React25.createElement("hr", null), /* @__PURE__ */ React25.createElement(
2040
+ FormField,
2041
+ {
2042
+ control: form.control,
2043
+ name: "hidden",
2044
+ 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))
2045
+ }
2046
+ ), /* @__PURE__ */ React25.createElement("hr", null), /* @__PURE__ */ React25.createElement(
2047
+ FormField,
2048
+ {
2049
+ control: form.control,
2050
+ name: "container",
2051
+ 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(
2052
+ Switch,
2053
+ {
2054
+ checked: !field.value,
2055
+ onCheckedChange: (v) => field.onChange(!v)
2056
+ }
2057
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2058
+ }
2059
+ ), /* @__PURE__ */ React25.createElement("hr", null), /* @__PURE__ */ React25.createElement(
2060
+ FormField,
2061
+ {
2062
+ control: form.control,
2063
+ key: `${device}.padding`,
2064
+ name: `${device}.padding`,
2065
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Padding"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2066
+ SpacingInput,
2067
+ {
2068
+ value: field.value,
2069
+ onChange: field.onChange
2070
+ }
2071
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2072
+ }
2073
+ ), /* @__PURE__ */ React25.createElement(
2074
+ FormField,
2075
+ {
2076
+ control: form.control,
2077
+ key: `${device}.margin`,
2078
+ name: `${device}.margin`,
2079
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Margin"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2080
+ SpacingInput,
2081
+ {
2082
+ value: field.value,
2083
+ onChange: field.onChange
2084
+ }
2085
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2086
+ }
2087
+ )))));
2088
+ };
2089
+ var ScrollArea = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
2090
+ ScrollAreaPrimitive.Root,
2091
+ {
2092
+ ref,
2093
+ className: cn("sb-relative sb-overflow-hidden", className),
2094
+ ...props
2095
+ },
2096
+ /* @__PURE__ */ React25.createElement(ScrollAreaPrimitive.Viewport, { className: "sb-h-full sb-max-h-[80vh] sb-w-full sb-rounded-[inherit]" }, children),
2097
+ /* @__PURE__ */ React25.createElement(ScrollBar, null),
2098
+ /* @__PURE__ */ React25.createElement(ScrollAreaPrimitive.Corner, null)
2099
+ ));
2100
+ ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
2101
+ var ScrollBar = React25.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ React25.createElement(
2102
+ ScrollAreaPrimitive.ScrollAreaScrollbar,
2103
+ {
2104
+ ref,
2105
+ orientation,
2106
+ className: cn(
2107
+ "sb-flex sb-touch-none sb-select-none sb-transition-colors",
2108
+ orientation === "vertical" && "sb-h-full sb-w-2.5 sb-border-l sb-border-l-transparent sb-p-[1px]",
2109
+ orientation === "horizontal" && "sb-h-2.5 sb-flex-col sb-border-t sb-border-t-transparent sb-p-[1px]",
2110
+ className
2111
+ ),
2112
+ ...props
2113
+ },
2114
+ /* @__PURE__ */ React25.createElement(ScrollAreaPrimitive.ScrollAreaThumb, { className: "sb-relative sb-flex-1 sb-rounded-full sb-bg-border" })
2115
+ ));
2116
+ ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
2117
+
2118
+ // src/components/container-item-toolbar.tsx
2119
+ var ContainerItemToolbar = (props) => {
2120
+ const { contentId, canBringUp = false, canBringDown = false } = props;
2121
+ const { bringUp, bringDown } = useBuilder();
2122
+ 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(
2123
+ Button,
2124
+ {
2125
+ variant: "ghost",
2126
+ className: "sb-w-8 sb-h-8 sb-p-0",
2127
+ onClick: () => bringUp(contentId),
2128
+ disabled: !canBringUp
2129
+ },
2130
+ /* @__PURE__ */ React25.createElement(ArrowUp, { className: "sb-h-5 sb-w-5" })
2131
+ ), /* @__PURE__ */ React25.createElement(
2132
+ Button,
2133
+ {
2134
+ variant: "ghost",
2135
+ className: "sb-w-8 sb-h-8 sb-p-0",
2136
+ onClick: () => bringDown(contentId),
2137
+ disabled: !canBringDown
2138
+ },
2139
+ /* @__PURE__ */ React25.createElement(ArrowDown, { className: "sb-h-5 sb-w-5" })
2140
+ ), /* @__PURE__ */ React25.createElement(DeleteButton, { contentId })));
2141
+ };
2142
+ var EditButton = ({ id }) => {
2143
+ 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(
2144
+ PopoverContent,
2145
+ {
2146
+ side: "left",
2147
+ align: "start",
2148
+ sideOffset: 16,
2149
+ alignOffset: -8,
2150
+ className: "sb-p-0 sb-relative",
2151
+ collisionPadding: 16
2152
+ },
2153
+ /* @__PURE__ */ React25.createElement(EditPopoverInner, { id })
2154
+ ));
2155
+ };
2156
+ var EditPopoverInner = (props) => {
2157
+ const { id } = props;
2158
+ const { getItem } = useBuilder();
2159
+ const item = getItem(id);
2160
+ if (!item) {
2161
+ throw new Error(
2162
+ `[simple-builder]: Item with id ${id} not found in container item form component`
2163
+ );
2164
+ }
2165
+ 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 })));
2166
+ };
2167
+ var DeleteButton = ({ contentId }) => {
2168
+ const { deleteContent } = useBuilder();
2169
+ return /* @__PURE__ */ React25.createElement(AlertDialog, null, /* @__PURE__ */ React25.createElement(AlertDialogTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
2170
+ Button,
2171
+ {
2172
+ variant: "ghost",
2173
+ className: "sb-w-8 sb-h-8 sb-p-0 sb-text-destructive"
2174
+ },
2175
+ /* @__PURE__ */ React25.createElement(Trash2Icon, { className: "sb-h-5 sb-w-5" })
2176
+ )), /* @__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(
2177
+ AlertDialogAction,
2178
+ {
2179
+ className: buttonVariants({ variant: "destructive" }),
2180
+ onClick: () => deleteContent(contentId)
2181
+ },
2182
+ "Verwijderen"
2183
+ ))));
2184
+ };
2185
+
2186
+ // src/components/build-container-client.tsx
2187
+ var BuildContainerInner = (props) => {
2188
+ const { id, name, content, multiple = false } = props;
2189
+ const items = Array.isArray(content) ? content : content?.[name] || [];
2190
+ if (!multiple && items.length > 1) {
2191
+ console.error(
2192
+ "[simple-builder]: Multiple content blocks detected when using property multiple false."
2193
+ );
2194
+ }
2195
+ 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(
2196
+ ContainerItemToolbar,
2197
+ {
2198
+ contentId: item.id,
2199
+ canBringUp: i > 0,
2200
+ canBringDown: i < items.length - 1
2201
+ }
2202
+ )), multiple && /* @__PURE__ */ React25.createElement(
2203
+ AddContentDividerButton,
2204
+ {
2205
+ parent: id,
2206
+ container: name,
2207
+ index: i + 1
2208
+ }
2209
+ ))));
2210
+ };
2211
+ var build_container_client_default = BuildContainerInner;
2212
+ var AddContentButton = (props) => {
2213
+ const components = builder.getComponents();
2214
+ const { addContent } = useBuilder();
2215
+ 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) => {
2216
+ const Icon2 = component.icon ?? ImageIcon;
2217
+ return /* @__PURE__ */ React25.createElement(PopoverClose, { key: component.name, asChild: true }, /* @__PURE__ */ React25.createElement(
2218
+ Button,
2219
+ {
2220
+ variant: "ghost",
2221
+ className: "sb-justify-start",
2222
+ onClick: () => {
2223
+ addContent(
2224
+ component.name,
2225
+ props.container,
2226
+ props.parent,
2227
+ props.index
2228
+ );
2229
+ }
2230
+ },
2231
+ /* @__PURE__ */ React25.createElement(Icon2, { className: "sb-mr-2 sb-h-4 sb-w-4 sb-shrink-0" }),
2232
+ component.friendlyName ?? component.name
2233
+ ));
2234
+ }))));
2235
+ };
2236
+ var AddContentPlaceholder = (props) => {
2237
+ 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")));
2238
+ };
2239
+ var AddContentDividerButton = (props) => {
2240
+ 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(
2241
+ Button,
2242
+ {
2243
+ size: "sm",
2244
+ className: "sb-absolute sb-left-1/2 sb-top-1/2 sb--translate-y-1/2 sb--translate-x-1/2 sb-shadow"
2245
+ },
2246
+ /* @__PURE__ */ React25.createElement(PlusIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }),
2247
+ "Blok Toevoegen"
2248
+ )));
2249
+ };
2250
+
2251
+ export { build_container_client_default as default };