@simple-builder/react 1.4.1 → 1.4.2

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