@simple-builder/react 1.2.10 → 1.3.0

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