@simple-builder/react 1.2.9 → 1.3.0

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