@simple-builder/react 1.2.9 → 1.3.0

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