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