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