@simple-builder/react 1.2.7 → 1.2.9

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