@simple-builder/react 1.2.4 → 1.2.5

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