@simple-builder/react 1.3.9 → 1.4.0

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