@simple-builder/react 1.3.9 → 1.4.1

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