@simple-builder/react 1.2.5 → 1.2.6

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