@simple-builder/react 1.2.10 → 1.3.0

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