@simple-builder/react 1.2.9 → 1.3.0

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