@simple-builder/react 1.2.10 → 1.3.1

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