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