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