@simple-builder/react 1.2.8 → 1.2.10

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