@simple-builder/react 1.2.3 → 1.2.5

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