@simple-builder/react 1.2.5 → 1.2.7

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