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