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