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