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