@simple-builder/react 1.0.21 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/{build-container-client-UTWTM32L.css → build-container-client-6NICVHM7.css} +244 -13
  2. package/dist/build-container-client-BAVL356F.js +2282 -0
  3. package/dist/build-container-client-KI3QULNY.mjs +2246 -0
  4. package/dist/build-container-client-UYQEUZU5.mjs +2251 -0
  5. package/dist/build-container-client-XVX67J7D.js +2287 -0
  6. package/dist/{builder-content-BGBWMI6B.js → builder-content-2CLARIDQ.js} +7 -7
  7. package/dist/{builder-content-RQZGNHGE.mjs → builder-content-J45ZXXEM.mjs} +2 -2
  8. package/dist/{builder-content-JWIMCW6L.css → builder-content-P24OTLH4.css} +244 -13
  9. package/dist/builder-content-Y7KZGM4Z.js +42 -0
  10. package/dist/builder-content-YOL4MKX3.mjs +20 -0
  11. package/dist/{chunk-SMX2JVU7.js → chunk-47IWLKYO.js} +1 -1
  12. package/dist/{chunk-YM22QCRZ.mjs → chunk-527WHDFS.mjs} +1 -1
  13. package/dist/chunk-F7EVAQN7.mjs +123 -0
  14. package/dist/{chunk-KD2J6VPO.mjs → chunk-FUIGTZRW.mjs} +2 -2
  15. package/dist/{chunk-Q2EMWEEZ.js → chunk-IAIJXTFG.js} +28 -21
  16. package/dist/chunk-ISTZWAYI.js +263 -0
  17. package/dist/{chunk-GQ2NJQNP.js → chunk-M2YJU6AM.js} +3 -3
  18. package/dist/chunk-MV72DQML.mjs +20 -0
  19. package/dist/{chunk-JDY3WVEQ.mjs → chunk-Q42UV6O3.mjs} +25 -18
  20. package/dist/chunk-TZQPIYI7.mjs +238 -0
  21. package/dist/chunk-U3LGZ4IJ.js +42 -0
  22. package/dist/chunk-ZEA47N62.js +153 -0
  23. package/dist/index.css +244 -13
  24. package/dist/index.js +6 -6
  25. package/dist/index.mjs +2 -2
  26. package/package.json +18 -5
  27. package/dist/build-container-client-EGUVIJQE.mjs +0 -1479
  28. package/dist/build-container-client-VLVAC2RM.js +0 -1509
@@ -1,1509 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- require('./chunk-GQ2NJQNP.js');
5
- var chunkQ2EMWEEZ_js = require('./chunk-Q2EMWEEZ.js');
6
- var chunkSMX2JVU7_js = require('./chunk-SMX2JVU7.js');
7
- var React17 = require('react');
8
- var lucideReact = require('lucide-react');
9
- var AlertDialogPrimitive = require('@radix-ui/react-alert-dialog');
10
- var PopoverPrimitive = require('@radix-ui/react-popover');
11
- var dateFns = require('date-fns');
12
- var reactHookForm = require('react-hook-form');
13
- var reactDayPicker = require('react-day-picker');
14
- var reactSlot = require('@radix-ui/react-slot');
15
- var LabelPrimitive = require('@radix-ui/react-label');
16
- var SelectPrimitive = require('@radix-ui/react-select');
17
- var SwitchPrimitives = require('@radix-ui/react-switch');
18
- var zod$1 = require('@hookform/resolvers/zod');
19
- var zod = require('zod');
20
- var TabsPrimitive = require('@radix-ui/react-tabs');
21
- var TogglePrimitive = require('@radix-ui/react-toggle');
22
- var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
23
-
24
- function _interopNamespace(e) {
25
- if (e && e.__esModule) return e;
26
- var n = Object.create(null);
27
- if (e) {
28
- Object.keys(e).forEach(function (k) {
29
- if (k !== 'default') {
30
- var d = Object.getOwnPropertyDescriptor(e, k);
31
- Object.defineProperty(n, k, d.get ? d : {
32
- enumerable: true,
33
- get: function () { return e[k]; }
34
- });
35
- }
36
- });
37
- }
38
- n.default = e;
39
- return Object.freeze(n);
40
- }
41
-
42
- var React17__namespace = /*#__PURE__*/_interopNamespace(React17);
43
- var AlertDialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(AlertDialogPrimitive);
44
- var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
45
- var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
46
- var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
47
- var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
48
- var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
49
- var TogglePrimitive__namespace = /*#__PURE__*/_interopNamespace(TogglePrimitive);
50
- var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
51
-
52
- var AlertDialog = AlertDialogPrimitive__namespace.Root;
53
- var AlertDialogTrigger = AlertDialogPrimitive__namespace.Trigger;
54
- var AlertDialogPortal = AlertDialogPrimitive__namespace.Portal;
55
- var AlertDialogOverlay = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
56
- AlertDialogPrimitive__namespace.Overlay,
57
- {
58
- className: chunkSMX2JVU7_js.cn(
59
- "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",
60
- className
61
- ),
62
- ...props,
63
- ref
64
- }
65
- ));
66
- AlertDialogOverlay.displayName = AlertDialogPrimitive__namespace.Overlay.displayName;
67
- var AlertDialogContent = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(AlertDialogPortal, null, /* @__PURE__ */ React17__namespace.createElement(AlertDialogOverlay, null), /* @__PURE__ */ React17__namespace.createElement(
68
- AlertDialogPrimitive__namespace.Content,
69
- {
70
- ref,
71
- className: chunkSMX2JVU7_js.cn(
72
- "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",
73
- className
74
- ),
75
- ...props
76
- }
77
- )));
78
- AlertDialogContent.displayName = AlertDialogPrimitive__namespace.Content.displayName;
79
- var AlertDialogFooter = ({
80
- className,
81
- ...props
82
- }) => /* @__PURE__ */ React17__namespace.createElement(
83
- "div",
84
- {
85
- className: chunkSMX2JVU7_js.cn(
86
- "sb-flex sb-flex-col-reverse sm:sb-flex-row sm:sb-justify-end sm:sb-space-x-2",
87
- className
88
- ),
89
- ...props
90
- }
91
- );
92
- AlertDialogFooter.displayName = "AlertDialogFooter";
93
- var AlertDialogTitle = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
94
- AlertDialogPrimitive__namespace.Title,
95
- {
96
- ref,
97
- className: chunkSMX2JVU7_js.cn("sb-text-lg sb-font-semibold", className),
98
- ...props
99
- }
100
- ));
101
- AlertDialogTitle.displayName = AlertDialogPrimitive__namespace.Title.displayName;
102
- var AlertDialogDescription = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
103
- AlertDialogPrimitive__namespace.Description,
104
- {
105
- ref,
106
- className: chunkSMX2JVU7_js.cn("sb-text-sm sb-text-muted-foreground", className),
107
- ...props
108
- }
109
- ));
110
- AlertDialogDescription.displayName = AlertDialogPrimitive__namespace.Description.displayName;
111
- var AlertDialogAction = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
112
- AlertDialogPrimitive__namespace.Action,
113
- {
114
- ref,
115
- className: chunkSMX2JVU7_js.cn(chunkQ2EMWEEZ_js.buttonVariants(), className),
116
- ...props
117
- }
118
- ));
119
- AlertDialogAction.displayName = AlertDialogPrimitive__namespace.Action.displayName;
120
- var AlertDialogCancel = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
121
- AlertDialogPrimitive__namespace.Cancel,
122
- {
123
- ref,
124
- className: chunkSMX2JVU7_js.cn(
125
- chunkQ2EMWEEZ_js.buttonVariants({ variant: "outline" }),
126
- "sb-mt-2 sm:sb-mt-0",
127
- className
128
- ),
129
- ...props
130
- }
131
- ));
132
- AlertDialogCancel.displayName = AlertDialogPrimitive__namespace.Cancel.displayName;
133
- var Popover = PopoverPrimitive__namespace.Root;
134
- var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
135
- var PopoverClose = PopoverPrimitive__namespace.Close;
136
- var PopoverContent = React17__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(PopoverPrimitive__namespace.Portal, null, /* @__PURE__ */ React17__namespace.createElement(
137
- PopoverPrimitive__namespace.Content,
138
- {
139
- ref,
140
- align,
141
- sideOffset,
142
- className: chunkSMX2JVU7_js.cn(
143
- "sb-z-50 sb-w-72 sb-font-roboto 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",
144
- className
145
- ),
146
- ...props
147
- }
148
- )));
149
- PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
150
- function Calendar({
151
- className,
152
- classNames,
153
- showOutsideDays = true,
154
- ...props
155
- }) {
156
- return /* @__PURE__ */ React17__namespace.createElement(
157
- reactDayPicker.DayPicker,
158
- {
159
- showOutsideDays,
160
- className: chunkSMX2JVU7_js.cn("sb-p-3 sb-font-roboto", className),
161
- classNames: {
162
- months: "sb-flex sb-flex-col sm:sb-flex-row sb-space-y-4 sm:sb-space-x-4 sm:sb-space-y-0",
163
- month: "sb-space-y-4",
164
- caption: "sb-flex sb-justify-center sb-pt-1 sb-relative sb-items-center",
165
- caption_label: "sb-text-sm sb-font-medium",
166
- nav: "sb-space-x-1 sb-flex sb-items-center",
167
- nav_button: chunkSMX2JVU7_js.cn(
168
- chunkQ2EMWEEZ_js.buttonVariants({ variant: "outline" }),
169
- "sb-h-7 sb-w-7 sb-bg-transparent sb-p-0 sb-opacity-50 hover:sb-opacity-100"
170
- ),
171
- nav_button_previous: "sb-absolute sb-left-1",
172
- nav_button_next: "sb-absolute sb-right-1",
173
- table: "sb-w-full sb-border-collapse sb-space-y-1",
174
- head_row: "sb-flex",
175
- head_cell: "sb-text-muted-foreground sb-rounded-md sb-w-8 sb-font-normal sb-text-[0.8rem]",
176
- row: "sb-flex sb-w-full sb-mt-2",
177
- cell: chunkSMX2JVU7_js.cn(
178
- "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",
179
- 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"
180
- ),
181
- day: chunkSMX2JVU7_js.cn(
182
- chunkQ2EMWEEZ_js.buttonVariants({ variant: "ghost" }),
183
- "sb-h-8 sb-w-8 sb-p-0 sb-font-normal aria-selected:sb-opacity-100"
184
- ),
185
- day_range_start: "day-range-start",
186
- day_range_end: "day-range-end",
187
- 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",
188
- day_today: "sb-bg-accent sb-text-accent-foreground",
189
- 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",
190
- day_disabled: "sb-text-muted-foreground sb-opacity-50",
191
- day_range_middle: "aria-selected:sb-bg-accent aria-selected:sb-text-accent-foreground",
192
- day_hidden: "invisible",
193
- ...classNames
194
- },
195
- components: {
196
- IconLeft: () => /* @__PURE__ */ React17__namespace.createElement(lucideReact.ChevronLeftIcon, { className: "sb-h-4 sb-w-4" }),
197
- IconRight: () => /* @__PURE__ */ React17__namespace.createElement(lucideReact.ChevronRightIcon, { className: "sb-h-4 sb-w-4" })
198
- },
199
- ...props
200
- }
201
- );
202
- }
203
- Calendar.displayName = "Calendar";
204
- var ColorPicker = (props) => {
205
- const { color, onColorChange, className } = props;
206
- const colors = props.colors ?? [
207
- "#000000",
208
- "#ffffff",
209
- "#0f172a",
210
- "#F1F5F9",
211
- "#64748B",
212
- "#E6007E",
213
- "#F8FAFC",
214
- "#009DD1",
215
- "#FF0000"
216
- ];
217
- return /* @__PURE__ */ React17__namespace.createElement(Popover, null, /* @__PURE__ */ React17__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React17__namespace.createElement(
218
- chunkQ2EMWEEZ_js.Button,
219
- {
220
- variant: "outline",
221
- size: "sm",
222
- className: chunkSMX2JVU7_js.cn(
223
- "sb-justify-start sb-text-left sb-font-normal sb-normal-case sb-w-full",
224
- !color && "sb-text-muted-foreground",
225
- className
226
- )
227
- },
228
- /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-w-full sb-flex sb-items-center sb-gap-2" }, color ? /* @__PURE__ */ React17__namespace.createElement(
229
- "div",
230
- {
231
- className: "sb-h-4 sb-w-4 sb-rounded !sb-bg-center !sb-bg-cover sb-transition-all sb-border",
232
- style: { background: color }
233
- }
234
- ) : /* @__PURE__ */ React17__namespace.createElement(lucideReact.PaintbrushIcon, { className: "sb-h-4 sb-w-4" }), /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-truncate sb-flex-1" }, color ? color : "Kies een kleur"))
235
- )), /* @__PURE__ */ React17__namespace.createElement(PopoverContent, { className: "sb-w-64 sb-p-4 sb-flex sb-flex-wrap sb-gap-1" }, colors.map((s) => /* @__PURE__ */ React17__namespace.createElement(
236
- "div",
237
- {
238
- key: s,
239
- style: { background: s },
240
- className: "sb-rounded-md sb-h-6 sb-w-6 sb-cursor-pointer active:sb-scale-105 sb-border",
241
- onClick: () => onColorChange(s)
242
- }
243
- ))));
244
- };
245
- var labelVariants = chunkSMX2JVU7_js.tv({
246
- base: "sb-text-sm sb-font-medium sb-font-roboto sb-leading-none peer-disabled:sb-cursor-not-allowed peer-disabled:sb-opacity-70"
247
- });
248
- var Label = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
249
- LabelPrimitive__namespace.Root,
250
- {
251
- ref,
252
- className: labelVariants({ className }),
253
- ...props
254
- }
255
- ));
256
- Label.displayName = LabelPrimitive__namespace.Root.displayName;
257
-
258
- // src/components/ui/form.tsx
259
- var Form = reactHookForm.FormProvider;
260
- var FormFieldContext = React17__namespace.createContext(
261
- {}
262
- );
263
- var FormField = ({
264
- ...props
265
- }) => {
266
- return /* @__PURE__ */ React17__namespace.createElement(FormFieldContext.Provider, { value: { name: props.name } }, /* @__PURE__ */ React17__namespace.createElement(reactHookForm.Controller, { ...props }));
267
- };
268
- var useFormField = () => {
269
- const fieldContext = React17__namespace.useContext(FormFieldContext);
270
- const itemContext = React17__namespace.useContext(FormItemContext);
271
- const { getFieldState, formState } = reactHookForm.useFormContext();
272
- const fieldState = getFieldState(fieldContext.name, formState);
273
- if (!fieldContext) {
274
- throw new Error("useFormField should be used within <FormField>");
275
- }
276
- const { id } = itemContext;
277
- return {
278
- id,
279
- name: fieldContext.name,
280
- formItemId: `${id}-form-item`,
281
- formDescriptionId: `${id}-form-item-description`,
282
- formMessageId: `${id}-form-item-message`,
283
- ...fieldState
284
- };
285
- };
286
- var FormItemContext = React17__namespace.createContext(
287
- {}
288
- );
289
- var FormItem = React17__namespace.forwardRef(({ className, ...props }, ref) => {
290
- const id = React17__namespace.useId();
291
- return /* @__PURE__ */ React17__namespace.createElement(FormItemContext.Provider, { value: { id } }, /* @__PURE__ */ React17__namespace.createElement("div", { ref, className: chunkSMX2JVU7_js.cn("sb-space-y-2", className), ...props }));
292
- });
293
- FormItem.displayName = "FormItem";
294
- var FormLabel = React17__namespace.forwardRef(({ className, ...props }, ref) => {
295
- const { error, formItemId } = useFormField();
296
- return /* @__PURE__ */ React17__namespace.createElement(
297
- Label,
298
- {
299
- ref,
300
- className: chunkSMX2JVU7_js.cn(error && "sb-text-destructive", className),
301
- htmlFor: formItemId,
302
- ...props
303
- }
304
- );
305
- });
306
- FormLabel.displayName = "FormLabel";
307
- var FormControl = React17__namespace.forwardRef(({ ...props }, ref) => {
308
- const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
309
- return /* @__PURE__ */ React17__namespace.createElement(
310
- reactSlot.Slot,
311
- {
312
- ref,
313
- id: formItemId,
314
- "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
315
- "aria-invalid": !!error,
316
- ...props
317
- }
318
- );
319
- });
320
- FormControl.displayName = "FormControl";
321
- var FormDescription = React17__namespace.forwardRef(({ className, ...props }, ref) => {
322
- const { formDescriptionId } = useFormField();
323
- return /* @__PURE__ */ React17__namespace.createElement(
324
- "p",
325
- {
326
- ref,
327
- id: formDescriptionId,
328
- className: chunkSMX2JVU7_js.cn(
329
- "sb-text-sm sb-font-roboto sb-text-muted-foreground",
330
- className
331
- ),
332
- ...props
333
- }
334
- );
335
- });
336
- FormDescription.displayName = "FormDescription";
337
- var FormMessage = React17__namespace.forwardRef(({ className, children, ...props }, ref) => {
338
- const { error, formMessageId } = useFormField();
339
- const body = error ? String(error?.message) : children;
340
- if (!body) {
341
- return null;
342
- }
343
- return /* @__PURE__ */ React17__namespace.createElement(
344
- "p",
345
- {
346
- ref,
347
- id: formMessageId,
348
- className: chunkSMX2JVU7_js.cn(
349
- "sb-text-sm sb-font-roboto sb-font-medium sb-text-destructive",
350
- className
351
- ),
352
- ...props
353
- },
354
- body
355
- );
356
- });
357
- FormMessage.displayName = "FormMessage";
358
- var Input = React17__namespace.forwardRef(
359
- ({ className, type, ...props }, ref) => {
360
- return /* @__PURE__ */ React17__namespace.createElement(
361
- "input",
362
- {
363
- type,
364
- className: chunkSMX2JVU7_js.cn(
365
- "sb-flex sb-h-8 sb-w-full sb-font-roboto sb-rounded-md sb-border sb-border-input sb-bg-background sb-px-3 sb-py-1 sb-text-sm sb-ring-offset-background file:sb-border-0 file:sb-bg-transparent file:sb-text-sm file:sb-font-medium placeholder:sb-text-muted-foreground focus-visible:sb-outline-none focus-visible:sb-ring-1 focus-visible:ring-sb-ring focus-visible:sb-ring-offset-2 disabled:sb-cursor-not-allowed disabled:sb-opacity-50",
366
- className
367
- ),
368
- ref,
369
- ...props
370
- }
371
- );
372
- }
373
- );
374
- Input.displayName = "Input";
375
- var AdvancedInput = React17__namespace.forwardRef(
376
- ({ prepend, append, ...props }, ref) => {
377
- return /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-relative" }, /* @__PURE__ */ React17__namespace.createElement(Input, { ref, className: "sb-pl-9 sb-pr-7 sb-text-right", ...props }), prepend && /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-absolute sb-font-roboto sb-top-1/2 sb-left-3 sb--translate-y-1/2" }, prepend), append && /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-absolute sb-font-roboto sb-top-1/2 sb-right-3 sb--translate-y-1/2" }, append));
378
- }
379
- );
380
- AdvancedInput.displayName = "AdvancedInput";
381
- var MediaInput = (props) => {
382
- const { onFilesChange, limit = 32, multiple = false, onError } = props;
383
- const id = React17__namespace.useId();
384
- const [queue, setQueue] = React17__namespace.useState([]);
385
- const [sources, setSources] = React17__namespace.useState(props.files ?? []);
386
- const maxConcurrentUploads = 3;
387
- const uploadingCountRef = React17__namespace.useRef(0);
388
- const handleFilesAdd = async (e) => {
389
- const files = e.target.files;
390
- if (!files || files.length === 0) {
391
- return;
392
- }
393
- if (files.length + sources.length > (multiple ? limit : 1)) {
394
- onError?.(
395
- new MediaInputError(
396
- `Maximaal ${limit} bestanden.`,
397
- `Je probeerde nu ${files.length + sources.length} bestanden toe te voegen, maar je mag er maximaal ${limit} toevoegen.`
398
- )
399
- );
400
- return;
401
- }
402
- const queue2 = Array.from(files);
403
- setQueue(queue2);
404
- for (const file of queue2) {
405
- try {
406
- while (uploadingCountRef.current >= maxConcurrentUploads && uploadingCountRef.current > 0) {
407
- await new Promise((resolve) => setTimeout(resolve, 300));
408
- }
409
- uploadingCountRef.current++;
410
- const formData = new FormData();
411
- formData.append("file", file);
412
- const res = await fetch("/api/simple-builder/file/upload", {
413
- method: "POST",
414
- body: formData
415
- });
416
- if (res === void 0 || !res.ok) {
417
- onError?.(
418
- new MediaInputError(
419
- "Bestand uploaden misulukt",
420
- `Bestand ${file.name} kon niet worden ge\xFCpload.`
421
- )
422
- );
423
- continue;
424
- }
425
- const { data: url } = await res.json();
426
- if (!url) {
427
- onError?.(
428
- new MediaInputError(
429
- "Bestand uploaden misulukt",
430
- `De URL van bestand ${file.name} kon niet worden opgehaald.`
431
- )
432
- );
433
- continue;
434
- }
435
- setSources((prev) => [...prev, url]);
436
- onFilesChange?.([...sources, url]);
437
- } catch (e2) {
438
- onError?.(
439
- new MediaInputError(
440
- "Bestand uploaden misulukt",
441
- `Bestand ${file.name} kon niet worden ge\xFCpload.`
442
- )
443
- );
444
- } finally {
445
- setQueue((prev) => prev.filter((f) => f !== file));
446
- uploadingCountRef.current--;
447
- }
448
- }
449
- };
450
- const handleSourceDelete = async (src) => {
451
- setSources((prev) => prev.filter((s) => s !== src));
452
- onFilesChange?.(sources.filter((s) => s !== src));
453
- await fetch("/api/uploadthing/delete", {
454
- method: "POST",
455
- body: JSON.stringify({ src })
456
- });
457
- };
458
- return /* @__PURE__ */ React17__namespace.createElement("div", { className: chunkSMX2JVU7_js.cn("flex flex-wrap gap-4", props.className) }, sources.map((src) => /* @__PURE__ */ React17__namespace.createElement(MediaInputItem, { key: src, className: chunkSMX2JVU7_js.cn("group", props.itemClassName) }, /* @__PURE__ */ React17__namespace.createElement(
459
- chunkSMX2JVU7_js.Image,
460
- {
461
- src,
462
- alt: "",
463
- fill: true,
464
- className: "sb-absolute sb-inset-0 sb-object-cover sb-pointer-events-none"
465
- }
466
- ), /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-absolute sb-right-1 sb-top-1 sb-z-30 sb-flex sb-items-center sb-justify-end sb-gap-3 sb-opacity-0 sb-transition-opacity group-hover:sb-opacity-100" }, /* @__PURE__ */ React17__namespace.createElement(
467
- "button",
468
- {
469
- 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",
470
- onClick: () => handleSourceDelete(src)
471
- },
472
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.Trash2Icon, { className: "sb-h-4 sb-w-4" })
473
- )))), queue.map((_, i) => /* @__PURE__ */ React17__namespace.createElement(
474
- MediaInputItem,
475
- {
476
- key: i,
477
- className: chunkSMX2JVU7_js.cn(
478
- "sb-flex sb-h-28 sb-w-28 sb-items-center sb-justify-center",
479
- props.itemClassName
480
- )
481
- },
482
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.Loader2Icon, { className: "sb-h-6 sb-w-6 sb-animate-spin" })
483
- )), multiple || !multiple && !sources.length && !queue.length ? /* @__PURE__ */ React17__namespace.createElement(
484
- "label",
485
- {
486
- htmlFor: id,
487
- className: chunkSMX2JVU7_js.cn(
488
- "sb-flex sb-h-28 sb-w-28 sb-cursor-pointer sb-items-center sb-justify-center sb-rounded-lg sb-border",
489
- props.itemClassName
490
- )
491
- },
492
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.PlusIcon, { className: "sb-h-6 sb-w-6" }),
493
- /* @__PURE__ */ React17__namespace.createElement(
494
- "input",
495
- {
496
- id,
497
- type: "file",
498
- onChange: handleFilesAdd,
499
- multiple,
500
- accept: ".png,.jpg,.jpeg,.webp,.gif,.svg",
501
- className: "sb-hidden"
502
- }
503
- )
504
- ) : null);
505
- };
506
- var MediaInputItem = (props) => {
507
- return /* @__PURE__ */ React17__namespace.createElement(
508
- "div",
509
- {
510
- className: chunkSMX2JVU7_js.cn(
511
- "sb-relative sb-h-28 sb-w-28 sb-overflow-hidden sb-rounded-lg sb-border",
512
- props.className
513
- )
514
- },
515
- props.children
516
- );
517
- };
518
- var MediaInputError = class extends Error {
519
- title;
520
- description;
521
- constructor(message, description) {
522
- super(message);
523
- this.title = message;
524
- this.description = description;
525
- }
526
- };
527
- var Select = SelectPrimitive__namespace.Root;
528
- var SelectValue = SelectPrimitive__namespace.Value;
529
- var SelectTrigger = React17__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
530
- SelectPrimitive__namespace.Trigger,
531
- {
532
- ref,
533
- className: chunkSMX2JVU7_js.cn(
534
- "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",
535
- className
536
- ),
537
- ...props
538
- },
539
- children,
540
- /* @__PURE__ */ React17__namespace.createElement(SelectPrimitive__namespace.Icon, { asChild: true }, /* @__PURE__ */ React17__namespace.createElement(lucideReact.ChevronDown, { className: "sb-h-4 sb-w-4 sb-opacity-50" }))
541
- ));
542
- SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
543
- var SelectScrollUpButton = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
544
- SelectPrimitive__namespace.ScrollUpButton,
545
- {
546
- ref,
547
- className: chunkSMX2JVU7_js.cn(
548
- "sb-flex sb-cursor-default sb-items-center sb-justify-center sb-py-1",
549
- className
550
- ),
551
- ...props
552
- },
553
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.ChevronUp, { className: "sb-h-4 sb-w-4" })
554
- ));
555
- SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
556
- var SelectScrollDownButton = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
557
- SelectPrimitive__namespace.ScrollDownButton,
558
- {
559
- ref,
560
- className: chunkSMX2JVU7_js.cn(
561
- "sb-flex sb-cursor-default sb-items-center sb-justify-center sb-py-1",
562
- className
563
- ),
564
- ...props
565
- },
566
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.ChevronDown, { className: "sb-h-4 sb-w-4" })
567
- ));
568
- SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
569
- var SelectContent = React17__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(SelectPrimitive__namespace.Portal, null, /* @__PURE__ */ React17__namespace.createElement(
570
- SelectPrimitive__namespace.Content,
571
- {
572
- ref,
573
- className: chunkSMX2JVU7_js.cn(
574
- "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",
575
- 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",
576
- className
577
- ),
578
- position,
579
- ...props
580
- },
581
- /* @__PURE__ */ React17__namespace.createElement(SelectScrollUpButton, null),
582
- /* @__PURE__ */ React17__namespace.createElement(
583
- SelectPrimitive__namespace.Viewport,
584
- {
585
- className: chunkSMX2JVU7_js.cn(
586
- "sb-p-1",
587
- position === "popper" && "sb-h-[var(--radix-select-trigger-height)] sb-w-full sb-min-w-[var(--radix-select-trigger-width)]"
588
- )
589
- },
590
- children
591
- ),
592
- /* @__PURE__ */ React17__namespace.createElement(SelectScrollDownButton, null)
593
- )));
594
- SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
595
- var SelectLabel = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
596
- SelectPrimitive__namespace.Label,
597
- {
598
- ref,
599
- className: chunkSMX2JVU7_js.cn(
600
- "sb-py-1.5 sb-pl-8 sb-pr-2 sb-text-sm sb-font-semibold",
601
- className
602
- ),
603
- ...props
604
- }
605
- ));
606
- SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
607
- var SelectItem = React17__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
608
- SelectPrimitive__namespace.Item,
609
- {
610
- ref,
611
- className: chunkSMX2JVU7_js.cn(
612
- "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",
613
- className
614
- ),
615
- ...props
616
- },
617
- /* @__PURE__ */ React17__namespace.createElement("span", { className: "sb-absolute sb-left-2 sb-flex sb-h-3.5 sb-w-3.5 sb-items-center sb-justify-center" }, /* @__PURE__ */ React17__namespace.createElement(SelectPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React17__namespace.createElement(lucideReact.Check, { className: "sb-h-4 sb-w-4" }))),
618
- /* @__PURE__ */ React17__namespace.createElement(SelectPrimitive__namespace.ItemText, null, children)
619
- ));
620
- SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
621
- var SelectSeparator = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
622
- SelectPrimitive__namespace.Separator,
623
- {
624
- ref,
625
- className: chunkSMX2JVU7_js.cn("sb--mx-1 sb-my-1 sb-h-px sb-bg-muted", className),
626
- ...props
627
- }
628
- ));
629
- SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
630
- var Switch = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
631
- SwitchPrimitives__namespace.Root,
632
- {
633
- className: chunkSMX2JVU7_js.cn(
634
- "peer sb-inline-flex sb-h-6 sb-w-11 sb-shrink-0 sb-cursor-pointer sb-items-center sb-rounded-full sb-border-2 sb-border-transparent 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",
635
- className
636
- ),
637
- ...props,
638
- ref
639
- },
640
- /* @__PURE__ */ React17__namespace.createElement(
641
- SwitchPrimitives__namespace.Thumb,
642
- {
643
- className: chunkSMX2JVU7_js.cn(
644
- "sb-pointer-events-none sb-block sb-h-5 sb-w-5 sb-rounded-full sb-bg-background sb-shadow-lg sb-ring-0 sb-transition-transform data-[state=checked]:sb-translate-x-5 data-[state=unchecked]:sb-translate-x-0"
645
- )
646
- }
647
- )
648
- ));
649
- Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
650
- var Textarea = React17__namespace.forwardRef(
651
- ({ className, ...props }, ref) => {
652
- return /* @__PURE__ */ React17__namespace.createElement(
653
- "textarea",
654
- {
655
- className: chunkSMX2JVU7_js.cn(
656
- "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",
657
- className
658
- ),
659
- ref,
660
- ...props
661
- }
662
- );
663
- }
664
- );
665
- Textarea.displayName = "Textarea";
666
-
667
- // src/components/container-item-form.tsx
668
- var ContainerItemForm = (props) => {
669
- const { item } = props;
670
- const { patchItem } = chunkQ2EMWEEZ_js.useBuilder();
671
- const component = chunkSMX2JVU7_js.builder.getComponent(item.component);
672
- if (!component) {
673
- throw new Error(
674
- `[simple-builder]: Component with id ${item.component} not found in container item form component`
675
- );
676
- }
677
- const form = reactHookForm.useForm({
678
- defaultValues: (component.inputs || []).reduce(
679
- (acc, input) => ({
680
- ...acc,
681
- [input.name]: item?.props?.[input.name] ?? input.defaultValue
682
- }),
683
- {}
684
- )
685
- });
686
- const onSubmit = (values) => {
687
- patchItem(item.id, {
688
- props: values
689
- });
690
- };
691
- React17__namespace.useEffect(() => {
692
- const subscription = form.watch(() => form.handleSubmit(onSubmit)());
693
- return () => subscription.unsubscribe();
694
- }, [form.watch, form.handleSubmit]);
695
- return /* @__PURE__ */ React17__namespace.createElement(Form, { ...form }, /* @__PURE__ */ React17__namespace.createElement("form", { onSubmit: form.handleSubmit(onSubmit) }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-space-y-4 sb-p-4" }, (component.inputs || []).map((input) => /* @__PURE__ */ React17__namespace.createElement(
696
- RenderFormField,
697
- {
698
- key: input.name,
699
- type: input.type,
700
- input,
701
- form
702
- }
703
- )))));
704
- };
705
- var RenderFormField = (props) => {
706
- const { type, input, form } = props;
707
- const fieldArray = reactHookForm.useFieldArray({
708
- control: form.control,
709
- name: input.name
710
- });
711
- if (input.multiple) {
712
- return /* @__PURE__ */ React17__namespace.createElement("fieldset", { className: "sb-space-y-2" }, /* @__PURE__ */ React17__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-space-y-4" }, fieldArray.fields.map(
713
- (field, i) => type !== "grouped" ? /* @__PURE__ */ React17__namespace.createElement(
714
- FormField,
715
- {
716
- key: field.id,
717
- control: form.control,
718
- name: `${input.name}.${i}`,
719
- render: ({ field: field2 }) => /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-flex sb-items-center sb-gap-3" }, /* @__PURE__ */ React17__namespace.createElement(RenderInput, { field: field2, type: input.type }), /* @__PURE__ */ React17__namespace.createElement("button", { type: "button", onClick: () => fieldArray.remove(i) }, /* @__PURE__ */ React17__namespace.createElement(lucideReact.XIcon, { className: "sb-h-4 sb-w-4" })))
720
- }
721
- ) : /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-flex sb-items-center sb-relative" }, /* @__PURE__ */ React17__namespace.createElement(
722
- RenderFormField,
723
- {
724
- key: field.id,
725
- form,
726
- type,
727
- input: {
728
- ...input,
729
- name: `${input.name}.${i}`,
730
- multiple: false,
731
- friendlyName: ""
732
- }
733
- }
734
- ), /* @__PURE__ */ React17__namespace.createElement(
735
- "button",
736
- {
737
- type: "button",
738
- onClick: () => fieldArray.remove(i),
739
- className: "sb-absolute sb-top-2 sb-right-2 sb-text-foreground/70 hover:sb-text-foreground"
740
- },
741
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.XIcon, { className: "sb-h-4 sb-w-4" })
742
- ))
743
- ), /* @__PURE__ */ React17__namespace.createElement(
744
- chunkQ2EMWEEZ_js.Button,
745
- {
746
- type: "button",
747
- variant: "outline",
748
- size: "sm",
749
- className: chunkSMX2JVU7_js.cn(
750
- "sb-w-[89%] sb-border-2 sb-border-dashed sb-text-muted-foreground",
751
- type === "grouped" && "sb-w-full"
752
- ),
753
- onClick: () => fieldArray.append(void 0)
754
- },
755
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.PlusCircleIcon, { className: "sb-h-4 sb-w-4" })
756
- )));
757
- }
758
- switch (type) {
759
- case "string":
760
- case "number":
761
- case "longText":
762
- case "richText":
763
- case "color":
764
- case "date":
765
- case "file":
766
- return /* @__PURE__ */ React17__namespace.createElement(
767
- FormField,
768
- {
769
- key: input.name,
770
- control: form.control,
771
- name: input.name,
772
- render: ({ field }) => /* @__PURE__ */ React17__namespace.createElement(FormItem, null, /* @__PURE__ */ React17__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React17__namespace.createElement(FormControl, null, /* @__PURE__ */ React17__namespace.createElement(RenderInput, { type, field, options: input?.enum })), input.helperText && /* @__PURE__ */ React17__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React17__namespace.createElement(FormMessage, null))
773
- }
774
- );
775
- case "boolean":
776
- return /* @__PURE__ */ React17__namespace.createElement(
777
- FormField,
778
- {
779
- key: input.name,
780
- control: form.control,
781
- name: input.name,
782
- render: ({ field }) => /* @__PURE__ */ React17__namespace.createElement(FormItem, { className: "sb-flex sb-flex-row sb-items-center sb-justify-between sb-space-y-0" }, /* @__PURE__ */ React17__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React17__namespace.createElement(FormControl, null, /* @__PURE__ */ React17__namespace.createElement(RenderInput, { type, field })), input.helperText && /* @__PURE__ */ React17__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React17__namespace.createElement(FormMessage, null))
783
- }
784
- );
785
- case "grouped":
786
- return /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-space-y-2 sb-w-full" }, input.friendlyName !== "" && /* @__PURE__ */ React17__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-space-y-2 sb-p-3 sb-w-full sb-border sb-rounded-lg" }, input.inputs.map((sub) => /* @__PURE__ */ React17__namespace.createElement(
787
- RenderFormField,
788
- {
789
- key: `${input.name}.${sub.name}`,
790
- type: sub.type,
791
- input: {
792
- ...sub,
793
- name: `${input.name}.${sub.name}`
794
- },
795
- form
796
- }
797
- ))));
798
- default:
799
- throw new Error(
800
- `[simple-builder]: Input type "${props.type}" not supported in render form field.`
801
- );
802
- }
803
- };
804
- var RenderInput = (props) => {
805
- const { type, options, field } = props;
806
- switch (type) {
807
- case "string":
808
- if (!options)
809
- return /* @__PURE__ */ React17__namespace.createElement(Input, { ...field });
810
- return /* @__PURE__ */ React17__namespace.createElement(Select, { onValueChange: field.onChange, defaultValue: field.value }, /* @__PURE__ */ React17__namespace.createElement(SelectTrigger, null, /* @__PURE__ */ React17__namespace.createElement(SelectValue, null)), /* @__PURE__ */ React17__namespace.createElement(SelectContent, null, options.map((option) => /* @__PURE__ */ React17__namespace.createElement(SelectItem, { key: option, value: option }, option))));
811
- case "longText":
812
- case "richText":
813
- return /* @__PURE__ */ React17__namespace.createElement(Textarea, { ...field });
814
- case "number":
815
- return /* @__PURE__ */ React17__namespace.createElement(Input, { type: "number", ...field });
816
- case "color":
817
- return /* @__PURE__ */ React17__namespace.createElement(ColorPicker, { color: field.value, onColorChange: field.onChange });
818
- case "date":
819
- return /* @__PURE__ */ React17__namespace.createElement(Popover, null, /* @__PURE__ */ React17__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React17__namespace.createElement(
820
- chunkQ2EMWEEZ_js.Button,
821
- {
822
- variant: "outline",
823
- size: "sm",
824
- className: chunkSMX2JVU7_js.cn(
825
- "sb-w-full sb-flex sb-justify-start sb-text-left sb-font-normal",
826
- !field.value && "sb-text-muted-foreground"
827
- )
828
- },
829
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.CalendarIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }),
830
- field.value && !Array.isArray(field.value) ? dateFns.format(field.value, "PPP") : /* @__PURE__ */ React17__namespace.createElement("span", null, "Pick a date")
831
- )), /* @__PURE__ */ React17__namespace.createElement(PopoverContent, { className: "sb-w-auto sb-p-0", align: "start" }, /* @__PURE__ */ React17__namespace.createElement(
832
- Calendar,
833
- {
834
- mode: "single",
835
- selected: field.value,
836
- onSelect: field.onChange,
837
- initialFocus: true
838
- }
839
- )));
840
- case "boolean":
841
- return /* @__PURE__ */ React17__namespace.createElement(Switch, { checked: field.value, onCheckedChange: field.onChange });
842
- case "file":
843
- return /* @__PURE__ */ React17__namespace.createElement(
844
- MediaInput,
845
- {
846
- className: "sb-grid sb-grid-cols-2 sb-gap-1",
847
- itemClassName: "sb-aspect-video sb-h-auto sb-w-full",
848
- multiple: false,
849
- files: field.value ? [field.value] : [],
850
- onFilesChange: (files) => field.onChange(files[0]),
851
- onError: (e) => console.error(
852
- "[media-input]: Title: " + e?.title,
853
- "media-input: Error: " + e?.description
854
- )
855
- }
856
- );
857
- default:
858
- throw new Error(
859
- `[simple-builder]: Input type "${props.type}" not supported in render input.`
860
- );
861
- }
862
- };
863
- var Tabs = TabsPrimitive__namespace.Root;
864
- var tabsListVariants = chunkSMX2JVU7_js.tv({
865
- variants: {
866
- variant: {
867
- 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",
868
- text: "sb-flex sb-items-center sb-border-b sb-px-4 sb-space-x-6"
869
- }
870
- },
871
- defaultVariants: {
872
- variant: "contained"
873
- }
874
- });
875
- var TabsList = React17__namespace.forwardRef(({ variant, className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
876
- TabsPrimitive__namespace.List,
877
- {
878
- ref,
879
- className: tabsListVariants({ variant, className }),
880
- ...props
881
- }
882
- ));
883
- TabsList.displayName = TabsPrimitive__namespace.List.displayName;
884
- var tabsTriggerVariants = chunkSMX2JVU7_js.tv({
885
- variants: {
886
- variant: {
887
- 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",
888
- 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"
889
- }
890
- },
891
- defaultVariants: {
892
- variant: "contained"
893
- }
894
- });
895
- var TabsTrigger = React17__namespace.forwardRef(({ variant, className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
896
- TabsPrimitive__namespace.Trigger,
897
- {
898
- ref,
899
- className: tabsTriggerVariants({ variant, className }),
900
- ...props
901
- }
902
- ));
903
- TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
904
- var TabsContent = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
905
- TabsPrimitive__namespace.Content,
906
- {
907
- ref,
908
- className: chunkSMX2JVU7_js.cn(
909
- "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",
910
- className
911
- ),
912
- ...props
913
- }
914
- ));
915
- TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
916
-
917
- // src/components/ui/background-picker.tsx
918
- var BackgroundPicker = (props) => {
919
- const { background, onBackgroundChange, className } = props;
920
- const solids = props.solids ?? [
921
- "#000000",
922
- "#ffffff",
923
- "#0f172a",
924
- "#F1F5F9",
925
- "#64748B",
926
- "#E6007E",
927
- "#F8FAFC",
928
- "#009DD1",
929
- "#FF0000"
930
- ];
931
- const gradients = props.gradients ?? [
932
- "linear-gradient(to top left,#accbee,#e7f0fd)",
933
- "linear-gradient(to top left,#d5d4d0,#d5d4d0,#eeeeec)"
934
- ];
935
- const images = props.images ?? [
936
- "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)",
937
- "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)"
938
- ];
939
- const defaultTab = React17__namespace.useMemo(() => {
940
- if (background.includes("url"))
941
- return "image";
942
- if (background.includes("gradient"))
943
- return "gradient";
944
- return "solid";
945
- }, [background]);
946
- return /* @__PURE__ */ React17__namespace.createElement(Popover, null, /* @__PURE__ */ React17__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React17__namespace.createElement(
947
- chunkQ2EMWEEZ_js.Button,
948
- {
949
- variant: "outline",
950
- size: "sm",
951
- className: chunkSMX2JVU7_js.cn(
952
- "sb-justify-start sb-text-left sb-font-normal sb-normal-case sb-w-full",
953
- !background && "sb-text-muted-foreground",
954
- className
955
- )
956
- },
957
- /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-w-full sb-flex sb-items-center sb-gap-2" }, background ? /* @__PURE__ */ React17__namespace.createElement(
958
- "div",
959
- {
960
- className: "sb-h-4 sb-w-4 sb-rounded !sb-bg-center !sb-bg-cover sb-transition-all sb-border",
961
- style: { background }
962
- }
963
- ) : /* @__PURE__ */ React17__namespace.createElement(lucideReact.PaintbrushIcon, { className: "sb-h-4 sb-w-4" }), /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-truncate sb-flex-1" }, background ? background : "Kies een achtergrond"))
964
- )), /* @__PURE__ */ React17__namespace.createElement(PopoverContent, { className: "sb-w-64 sb-p-0" }, /* @__PURE__ */ React17__namespace.createElement(Tabs, { defaultValue: defaultTab }, /* @__PURE__ */ React17__namespace.createElement(TabsList, { className: "sb-w-full" }, /* @__PURE__ */ React17__namespace.createElement(TabsTrigger, { className: "sb-flex-1", value: "solid" }, "Solid"), /* @__PURE__ */ React17__namespace.createElement(TabsTrigger, { className: "sb-flex-1", value: "gradient" }, "Gradient"), /* @__PURE__ */ React17__namespace.createElement(TabsTrigger, { className: "sb-flex-1", value: "image" }, "Image")), /* @__PURE__ */ React17__namespace.createElement(
965
- TabsContent,
966
- {
967
- value: "solid",
968
- className: "data-[state=active]:sb-flex sb-flex-wrap sb-gap-1 sb-p-4"
969
- },
970
- solids.map((s) => /* @__PURE__ */ React17__namespace.createElement(
971
- "div",
972
- {
973
- key: s,
974
- style: { background: s },
975
- className: "sb-rounded-md sb-h-6 sb-w-6 sb-cursor-pointer active:sb-scale-105 sb-border",
976
- onClick: () => onBackgroundChange(s)
977
- }
978
- ))
979
- ), /* @__PURE__ */ React17__namespace.createElement(
980
- TabsContent,
981
- {
982
- value: "gradient",
983
- className: "data-[state=active]:sb-flex sb-flex-wrap sb-gap-1 sb-p-4"
984
- },
985
- gradients.map((s) => /* @__PURE__ */ React17__namespace.createElement(
986
- "div",
987
- {
988
- key: s,
989
- style: { background: s },
990
- className: "rounded-md h-6 w-6 cursor-pointer active:scale-105 border",
991
- onClick: () => onBackgroundChange(s)
992
- }
993
- ))
994
- ), /* @__PURE__ */ React17__namespace.createElement(TabsContent, { value: "image" }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-p-4 sb-border-b" }, /* @__PURE__ */ React17__namespace.createElement(
995
- MediaInput,
996
- {
997
- className: "sb-grid sb-grid-cols-2 sb-gap-1",
998
- itemClassName: "sb-aspect-video sb-h-auto sb-w-full",
999
- multiple: false,
1000
- onFilesChange: (files) => {
1001
- if (!files.length)
1002
- return;
1003
- onBackgroundChange(`url(${files[0]})`);
1004
- },
1005
- onError: (e) => console.error(
1006
- "[media-input]: Title: " + e?.title,
1007
- "media-input: Error: " + e?.description
1008
- )
1009
- }
1010
- )), /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-gap-1 sb-p-4" }, images.map((s) => /* @__PURE__ */ React17__namespace.createElement(
1011
- "div",
1012
- {
1013
- key: s,
1014
- style: { backgroundImage: s },
1015
- 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",
1016
- onClick: () => onBackgroundChange(s)
1017
- }
1018
- )))))));
1019
- };
1020
- var toggleVariants = chunkSMX2JVU7_js.tv({
1021
- base: "sb-inline-flex sb-items-center sb-justify-center sb-rounded-md sb-text-sm sb-font-medium sb-ring-offset-background 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 focus-visible:sb-ring-offset-2 disabled:sb-pointer-events-none disabled:sb-opacity-50 data-[state=on]:sb-bg-accent data-[state=on]:sb-text-accent-foreground",
1022
- variants: {
1023
- variant: {
1024
- default: "sb-bg-transparent",
1025
- outline: "sb-border sb-border-input sb-bg-transparent hover:sb-bg-accent hover:sb-text-accent-foreground"
1026
- },
1027
- size: {
1028
- default: "sb-h-10 sb-px-3",
1029
- sm: "sb-h-9 sb-px-2.5",
1030
- lg: "sb-h-11 sb-px-5"
1031
- }
1032
- },
1033
- defaultVariants: {
1034
- variant: "default",
1035
- size: "default"
1036
- }
1037
- });
1038
- var Toggle = React17__namespace.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
1039
- TogglePrimitive__namespace.Root,
1040
- {
1041
- ref,
1042
- className: toggleVariants({ variant, size, className }),
1043
- ...props
1044
- }
1045
- ));
1046
- Toggle.displayName = TogglePrimitive__namespace.Root.displayName;
1047
-
1048
- // src/components/ui/spacing-input.tsx
1049
- var SpacingInput = (props) => {
1050
- const [value, setValue] = React17__namespace.useState(parse(props.value || "0px"));
1051
- const [indipendent, setIndipendent] = React17__namespace.useState(
1052
- isIndipendent(parse(props.value || "0px"))
1053
- );
1054
- React17__namespace.useEffect(() => {
1055
- if (!props.onChange)
1056
- return;
1057
- props.onChange(stringify(value));
1058
- }, [value, props.onChange]);
1059
- return /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-grid sb-grid-cols-[1fr,auto] sb-gap-3" }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-items-center sb-gap-3" }, !indipendent ? /* @__PURE__ */ React17__namespace.createElement(React17__namespace.Fragment, null, /* @__PURE__ */ React17__namespace.createElement(
1060
- AdvancedInput,
1061
- {
1062
- value: value.left,
1063
- pattern: "\\d+",
1064
- onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, left: +value2, right: +value2 })),
1065
- prepend: /* @__PURE__ */ React17__namespace.createElement(lucideReact.AlignHorizontalSpaceAroundIcon, { className: "sb-h-4 sb-w-4" }),
1066
- append: /* @__PURE__ */ React17__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1067
- }
1068
- ), /* @__PURE__ */ React17__namespace.createElement(
1069
- AdvancedInput,
1070
- {
1071
- value: value.top,
1072
- pattern: "\\d+",
1073
- onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, top: +value2, bottom: +value2 })),
1074
- prepend: /* @__PURE__ */ React17__namespace.createElement(lucideReact.AlignHorizontalSpaceAroundIcon, { className: "sb-h-4 sb-w-4 sb-rotate-90" }),
1075
- append: /* @__PURE__ */ React17__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1076
- }
1077
- )) : /* @__PURE__ */ React17__namespace.createElement(React17__namespace.Fragment, null, /* @__PURE__ */ React17__namespace.createElement(
1078
- AdvancedInput,
1079
- {
1080
- value: value.left,
1081
- pattern: "\\d+",
1082
- onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, left: +value2 })),
1083
- prepend: /* @__PURE__ */ React17__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4" }),
1084
- append: /* @__PURE__ */ React17__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1085
- }
1086
- ), /* @__PURE__ */ React17__namespace.createElement(
1087
- AdvancedInput,
1088
- {
1089
- value: value.top,
1090
- pattern: "\\d+",
1091
- onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, top: +value2 })),
1092
- prepend: /* @__PURE__ */ React17__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb-rotate-90" }),
1093
- append: /* @__PURE__ */ React17__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1094
- }
1095
- ), /* @__PURE__ */ React17__namespace.createElement(
1096
- AdvancedInput,
1097
- {
1098
- value: value.right,
1099
- pattern: "\\d+",
1100
- onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, right: +value2 })),
1101
- prepend: /* @__PURE__ */ React17__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb-rotate-180" }),
1102
- append: /* @__PURE__ */ React17__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1103
- }
1104
- ), /* @__PURE__ */ React17__namespace.createElement(
1105
- AdvancedInput,
1106
- {
1107
- value: value.bottom,
1108
- pattern: "\\d+",
1109
- onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, bottom: +value2 })),
1110
- prepend: /* @__PURE__ */ React17__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb--rotate-90" }),
1111
- append: /* @__PURE__ */ React17__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1112
- }
1113
- ))), /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-shrink-0" }, /* @__PURE__ */ React17__namespace.createElement(
1114
- Toggle,
1115
- {
1116
- className: "sb-shrink-0 sb-flex sb-w-8 sb-h-8 sb-p-0",
1117
- variant: "outline",
1118
- size: "sm",
1119
- pressed: indipendent,
1120
- onPressedChange: setIndipendent
1121
- },
1122
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.ScanIcon, { className: "sb-h-4 sb-w-4" })
1123
- )));
1124
- };
1125
- var isIndipendent = (value) => {
1126
- const { top, right, bottom, left } = value;
1127
- return top !== bottom || right !== left;
1128
- };
1129
- var parse = (value) => {
1130
- const matches = value.match(/(\d+)/gm);
1131
- const [top = 0, right = 0, bottom = 0, left = 0] = matches?.map((match) => +match) || [];
1132
- switch (matches?.length) {
1133
- case 1:
1134
- return { top, right: top, bottom: top, left: top };
1135
- case 2:
1136
- return { top, bottom: top, left: right, right };
1137
- case 3:
1138
- return { top, right, left: right, bottom };
1139
- default:
1140
- return { top, right, bottom, left };
1141
- }
1142
- };
1143
- var stringify = (value) => {
1144
- const { top, right, bottom, left } = value;
1145
- if (top === right && top === bottom && top === left) {
1146
- return `${top}px`;
1147
- }
1148
- if (top === bottom && right === left) {
1149
- return `${top}px ${right}px`;
1150
- }
1151
- if (right === left) {
1152
- return `${top}px ${right}px ${bottom}px`;
1153
- }
1154
- return `${top}px ${right}px ${bottom}px ${left}px`;
1155
- };
1156
-
1157
- // src/components/item-design-form.tsx
1158
- var designSchema = zod.z.object({
1159
- container: zod.z.coerce.boolean(),
1160
- hidden: zod.z.enum(["always", "mobile", "desktop", "never"]),
1161
- desktop: zod.z.object({
1162
- background: zod.z.string(),
1163
- color: zod.z.string(),
1164
- padding: zod.z.string(),
1165
- margin: zod.z.string()
1166
- }),
1167
- mobile: zod.z.object({
1168
- background: zod.z.string(),
1169
- color: zod.z.string(),
1170
- padding: zod.z.string(),
1171
- margin: zod.z.string()
1172
- })
1173
- });
1174
- var ItemDesignForm = (props) => {
1175
- const { item } = props;
1176
- const component = chunkSMX2JVU7_js.builder.getComponent(item.component);
1177
- if (!component) {
1178
- throw new Error(
1179
- `[simple-builder]: Component "${item.component}" not found`
1180
- );
1181
- }
1182
- const getDefaultDeviceValue = (params) => {
1183
- const { device: device2 = "desktop", key, fallback = "" } = params;
1184
- if (item.styles?.[device2]?.[key] !== void 0) {
1185
- return item.styles[device2][key];
1186
- }
1187
- if (component.defaultStyles?.[device2]?.[key] !== void 0) {
1188
- return component.defaultStyles[device2][key];
1189
- }
1190
- if (device2 === "mobile") {
1191
- const desktopValue = getDefaultDeviceValue({
1192
- ...params,
1193
- device: "desktop"
1194
- });
1195
- if (desktopValue !== void 0) {
1196
- return desktopValue;
1197
- }
1198
- }
1199
- return fallback;
1200
- };
1201
- const getDefaultDeviceValues = (device2) => {
1202
- return {
1203
- background: getDefaultDeviceValue({ device: device2, key: "background" }),
1204
- color: getDefaultDeviceValue({ device: device2, key: "color" }),
1205
- padding: getDefaultDeviceValue({ device: device2, key: "padding" }),
1206
- margin: getDefaultDeviceValue({ device: device2, key: "margin" })
1207
- };
1208
- };
1209
- const form = reactHookForm.useForm({
1210
- resolver: zod$1.zodResolver(designSchema),
1211
- values: {
1212
- container: item.styles?.container ?? true,
1213
- hidden: item.styles?.hidden ?? "never",
1214
- desktop: getDefaultDeviceValues("desktop"),
1215
- mobile: getDefaultDeviceValues("mobile")
1216
- }
1217
- });
1218
- const { patchItem } = chunkQ2EMWEEZ_js.useBuilder();
1219
- const onSubmit = (values) => {
1220
- const { container, hidden, desktop, mobile } = values;
1221
- const dirtyFields = form.formState.dirtyFields;
1222
- const desktopPatch = Object.entries(desktop).reduce(
1223
- (acc, [key, value]) => ({
1224
- ...acc,
1225
- ...value && { [key]: value }
1226
- }),
1227
- { ...item.styles?.desktop }
1228
- );
1229
- const mobilePatch = Object.entries(mobile).reduce(
1230
- (acc, [key, value]) => {
1231
- const desktopValue = desktop[key];
1232
- const isDirty = dirtyFields.desktop?.[key];
1233
- if (value === desktopValue || isDirty) {
1234
- return acc;
1235
- }
1236
- if (["padding", "margin"].includes(key)) {
1237
- if (value === "0px" && desktopValue === "0px") {
1238
- return acc;
1239
- }
1240
- }
1241
- return {
1242
- ...acc,
1243
- ...value && { [key]: value }
1244
- };
1245
- },
1246
- { ...item.styles?.mobile }
1247
- );
1248
- patchItem(item.id, {
1249
- styles: {
1250
- ...container === false && { container },
1251
- ...hidden !== "never" && { hidden },
1252
- ...Object.keys(desktopPatch).length && { desktop: desktopPatch },
1253
- ...Object.keys(mobilePatch).length && { mobile: mobilePatch }
1254
- }
1255
- });
1256
- };
1257
- const [device, setDevice] = React17__namespace.useState("desktop");
1258
- React17__namespace.useEffect(() => {
1259
- const subscription = form.watch(() => form.handleSubmit(onSubmit)());
1260
- return () => subscription.unsubscribe();
1261
- }, [form.watch, form.handleSubmit]);
1262
- return /* @__PURE__ */ React17__namespace.createElement(Form, { ...form }, /* @__PURE__ */ React17__namespace.createElement("form", { onSubmit: form.handleSubmit(onSubmit) }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-space-y-4 sb-p-4" }, /* @__PURE__ */ React17__namespace.createElement(
1263
- Tabs,
1264
- {
1265
- defaultValue: device,
1266
- onValueChange: (device2) => setDevice(device2)
1267
- },
1268
- /* @__PURE__ */ React17__namespace.createElement(TabsList, { className: "sb-h-9 sb-grid sb-w-full sb-grid-cols-2" }, /* @__PURE__ */ React17__namespace.createElement(TabsTrigger, { value: "desktop", className: "sb-text-xs" }, /* @__PURE__ */ React17__namespace.createElement(lucideReact.MonitorIcon, { className: "sb-h-4 sb-w-4 sb-mr-2" }), /* @__PURE__ */ React17__namespace.createElement("span", null, "Desktop")), /* @__PURE__ */ React17__namespace.createElement(TabsTrigger, { value: "mobile", className: "sb-text-xs" }, /* @__PURE__ */ React17__namespace.createElement(lucideReact.SmartphoneIcon, { className: "sb-h-4 sb-w-4 sb-mr-2" }), /* @__PURE__ */ React17__namespace.createElement("span", null, "Mobiel")))
1269
- ), /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-space-y-4" }, /* @__PURE__ */ React17__namespace.createElement(
1270
- FormField,
1271
- {
1272
- control: form.control,
1273
- key: `${device}.background`,
1274
- name: `${device}.background`,
1275
- render: ({ field }) => /* @__PURE__ */ React17__namespace.createElement(FormItem, null, /* @__PURE__ */ React17__namespace.createElement(FormLabel, null, "Achtergrond"), /* @__PURE__ */ React17__namespace.createElement(FormControl, null, /* @__PURE__ */ React17__namespace.createElement(
1276
- BackgroundPicker,
1277
- {
1278
- background: field.value,
1279
- onBackgroundChange: field.onChange
1280
- }
1281
- )), /* @__PURE__ */ React17__namespace.createElement(FormMessage, null))
1282
- }
1283
- ), /* @__PURE__ */ React17__namespace.createElement(
1284
- FormField,
1285
- {
1286
- control: form.control,
1287
- key: `${device}.color`,
1288
- name: `${device}.color`,
1289
- render: ({ field }) => /* @__PURE__ */ React17__namespace.createElement(FormItem, null, /* @__PURE__ */ React17__namespace.createElement(FormLabel, null, "Inhoud kleur"), /* @__PURE__ */ React17__namespace.createElement(FormControl, null, /* @__PURE__ */ React17__namespace.createElement(
1290
- ColorPicker,
1291
- {
1292
- color: field.value,
1293
- onColorChange: field.onChange
1294
- }
1295
- )), /* @__PURE__ */ React17__namespace.createElement(FormMessage, null))
1296
- }
1297
- ), /* @__PURE__ */ React17__namespace.createElement("hr", null), /* @__PURE__ */ React17__namespace.createElement(
1298
- FormField,
1299
- {
1300
- control: form.control,
1301
- name: "hidden",
1302
- render: ({ field }) => /* @__PURE__ */ React17__namespace.createElement(FormItem, null, /* @__PURE__ */ React17__namespace.createElement(FormLabel, null, "Verbergen"), /* @__PURE__ */ React17__namespace.createElement(FormControl, null, /* @__PURE__ */ React17__namespace.createElement(Select, { value: field.value, onValueChange: field.onChange }, /* @__PURE__ */ React17__namespace.createElement(SelectTrigger, null, /* @__PURE__ */ React17__namespace.createElement(SelectValue, null)), /* @__PURE__ */ React17__namespace.createElement(SelectContent, null, /* @__PURE__ */ React17__namespace.createElement(SelectItem, { value: "never" }, "Nooit"), /* @__PURE__ */ React17__namespace.createElement(SelectItem, { value: "desktop" }, "Op desktop"), /* @__PURE__ */ React17__namespace.createElement(SelectItem, { value: "mobile" }, "Op mobiel"), /* @__PURE__ */ React17__namespace.createElement(SelectItem, { value: "always" }, "Altijd")))), /* @__PURE__ */ React17__namespace.createElement(FormMessage, null))
1303
- }
1304
- ), /* @__PURE__ */ React17__namespace.createElement("hr", null), /* @__PURE__ */ React17__namespace.createElement(
1305
- FormField,
1306
- {
1307
- control: form.control,
1308
- name: "container",
1309
- render: ({ field }) => /* @__PURE__ */ React17__namespace.createElement(FormItem, { className: "sb-flex sb-flex-row sb-items-center sb-justify-between sb-space-y-0" }, /* @__PURE__ */ React17__namespace.createElement(FormLabel, null, "Volledige breedte"), /* @__PURE__ */ React17__namespace.createElement(FormControl, null, /* @__PURE__ */ React17__namespace.createElement(
1310
- Switch,
1311
- {
1312
- checked: !field.value,
1313
- onCheckedChange: (v) => field.onChange(!v)
1314
- }
1315
- )), /* @__PURE__ */ React17__namespace.createElement(FormMessage, null))
1316
- }
1317
- ), /* @__PURE__ */ React17__namespace.createElement("hr", null), /* @__PURE__ */ React17__namespace.createElement(
1318
- FormField,
1319
- {
1320
- control: form.control,
1321
- key: `${device}.padding`,
1322
- name: `${device}.padding`,
1323
- render: ({ field }) => /* @__PURE__ */ React17__namespace.createElement(FormItem, null, /* @__PURE__ */ React17__namespace.createElement(FormLabel, null, "Padding"), /* @__PURE__ */ React17__namespace.createElement(FormControl, null, /* @__PURE__ */ React17__namespace.createElement(
1324
- SpacingInput,
1325
- {
1326
- value: field.value,
1327
- onChange: field.onChange
1328
- }
1329
- )), /* @__PURE__ */ React17__namespace.createElement(FormMessage, null))
1330
- }
1331
- ), /* @__PURE__ */ React17__namespace.createElement(
1332
- FormField,
1333
- {
1334
- control: form.control,
1335
- key: `${device}.margin`,
1336
- name: `${device}.margin`,
1337
- render: ({ field }) => /* @__PURE__ */ React17__namespace.createElement(FormItem, null, /* @__PURE__ */ React17__namespace.createElement(FormLabel, null, "Margin"), /* @__PURE__ */ React17__namespace.createElement(FormControl, null, /* @__PURE__ */ React17__namespace.createElement(
1338
- SpacingInput,
1339
- {
1340
- value: field.value,
1341
- onChange: field.onChange
1342
- }
1343
- )), /* @__PURE__ */ React17__namespace.createElement(FormMessage, null))
1344
- }
1345
- )))));
1346
- };
1347
- var ScrollArea = React17__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
1348
- ScrollAreaPrimitive__namespace.Root,
1349
- {
1350
- ref,
1351
- className: chunkSMX2JVU7_js.cn("sb-relative sb-overflow-hidden", className),
1352
- ...props
1353
- },
1354
- /* @__PURE__ */ React17__namespace.createElement(ScrollAreaPrimitive__namespace.Viewport, { className: "sb-h-full sb-max-h-[80vh] sb-w-full sb-rounded-[inherit]" }, children),
1355
- /* @__PURE__ */ React17__namespace.createElement(ScrollBar, null),
1356
- /* @__PURE__ */ React17__namespace.createElement(ScrollAreaPrimitive__namespace.Corner, null)
1357
- ));
1358
- ScrollArea.displayName = ScrollAreaPrimitive__namespace.Root.displayName;
1359
- var ScrollBar = React17__namespace.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ React17__namespace.createElement(
1360
- ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
1361
- {
1362
- ref,
1363
- orientation,
1364
- className: chunkSMX2JVU7_js.cn(
1365
- "sb-flex sb-touch-none sb-select-none sb-transition-colors",
1366
- orientation === "vertical" && "sb-h-full sb-w-2.5 sb-border-l sb-border-l-transparent sb-p-[1px]",
1367
- orientation === "horizontal" && "sb-h-2.5 sb-flex-col sb-border-t sb-border-t-transparent sb-p-[1px]",
1368
- className
1369
- ),
1370
- ...props
1371
- },
1372
- /* @__PURE__ */ React17__namespace.createElement(ScrollAreaPrimitive__namespace.ScrollAreaThumb, { className: "sb-relative sb-flex-1 sb-rounded-full sb-bg-border" })
1373
- ));
1374
- ScrollBar.displayName = ScrollAreaPrimitive__namespace.ScrollAreaScrollbar.displayName;
1375
-
1376
- // src/components/container-item-toolbar.tsx
1377
- var ContainerItemToolbar = (props) => {
1378
- const { contentId, canBringUp = false, canBringDown = false } = props;
1379
- const { bringUp, bringDown } = chunkQ2EMWEEZ_js.useBuilder();
1380
- return /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-absolute sb-z-20 sb-top-1 sb-right-1 sb-rounded-md sb-shadow sb-flex sb-flex-col sb-gap-1 sb-p-1 sb-bg-card sb-text-card-foreground sb-item-toolbar sb-opacity-0 sb-transition-opacity" }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-h-10 sb-p-1 sb-border sb-border-input sb-bg-background sb-rounded-md sb-text-sm sb-font-medium sb-flex sb-gap-1 sb-items-center sb-justify-start" }, /* @__PURE__ */ React17__namespace.createElement(EditButton, { id: contentId }), /* @__PURE__ */ React17__namespace.createElement(
1381
- chunkQ2EMWEEZ_js.Button,
1382
- {
1383
- variant: "ghost",
1384
- className: "sb-w-8 sb-h-8 sb-p-0",
1385
- onClick: () => bringUp(contentId),
1386
- disabled: !canBringUp
1387
- },
1388
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.ArrowUp, { className: "sb-h-5 sb-w-5" })
1389
- ), /* @__PURE__ */ React17__namespace.createElement(
1390
- chunkQ2EMWEEZ_js.Button,
1391
- {
1392
- variant: "ghost",
1393
- className: "sb-w-8 sb-h-8 sb-p-0",
1394
- onClick: () => bringDown(contentId),
1395
- disabled: !canBringDown
1396
- },
1397
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.ArrowDown, { className: "sb-h-5 sb-w-5" })
1398
- ), /* @__PURE__ */ React17__namespace.createElement(DeleteButton, { contentId })));
1399
- };
1400
- var EditButton = ({ id }) => {
1401
- return /* @__PURE__ */ React17__namespace.createElement(Popover, { modal: true }, /* @__PURE__ */ React17__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React17__namespace.createElement(chunkQ2EMWEEZ_js.Button, { variant: "ghost", className: "sb-w-8 sb-h-8 sb-p-0" }, /* @__PURE__ */ React17__namespace.createElement(lucideReact.Edit2Icon, { className: "sb-h-5 sb-w-5" }))), /* @__PURE__ */ React17__namespace.createElement(
1402
- PopoverContent,
1403
- {
1404
- side: "left",
1405
- align: "start",
1406
- sideOffset: 16,
1407
- alignOffset: -8,
1408
- className: "sb-p-0 sb-relative",
1409
- collisionPadding: 16
1410
- },
1411
- /* @__PURE__ */ React17__namespace.createElement(EditPopoverInner, { id })
1412
- ));
1413
- };
1414
- var EditPopoverInner = (props) => {
1415
- const { id } = props;
1416
- const { getItem } = chunkQ2EMWEEZ_js.useBuilder();
1417
- const item = getItem(id);
1418
- if (!item) {
1419
- throw new Error(
1420
- `[simple-builder]: Item with id ${id} not found in container item form component`
1421
- );
1422
- }
1423
- return /* @__PURE__ */ React17__namespace.createElement(Tabs, null, /* @__PURE__ */ React17__namespace.createElement(TabsList, { variant: "text", defaultValue: "content" }, /* @__PURE__ */ React17__namespace.createElement(TabsTrigger, { variant: "text", value: "content" }, "Inhoud"), /* @__PURE__ */ React17__namespace.createElement(TabsTrigger, { variant: "text", value: "design" }, "Design")), /* @__PURE__ */ React17__namespace.createElement(TabsContent, { value: "content" }, /* @__PURE__ */ React17__namespace.createElement(ScrollArea, null, /* @__PURE__ */ React17__namespace.createElement(ContainerItemForm, { item }))), /* @__PURE__ */ React17__namespace.createElement(TabsContent, { value: "design" }, /* @__PURE__ */ React17__namespace.createElement(ItemDesignForm, { item })));
1424
- };
1425
- var DeleteButton = ({ contentId }) => {
1426
- const { deleteContent } = chunkQ2EMWEEZ_js.useBuilder();
1427
- return /* @__PURE__ */ React17__namespace.createElement(AlertDialog, null, /* @__PURE__ */ React17__namespace.createElement(AlertDialogTrigger, { asChild: true }, /* @__PURE__ */ React17__namespace.createElement(
1428
- chunkQ2EMWEEZ_js.Button,
1429
- {
1430
- variant: "ghost",
1431
- className: "sb-w-8 sb-h-8 sb-p-0 sb-text-destructive"
1432
- },
1433
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.Trash2Icon, { className: "sb-h-5 sb-w-5" })
1434
- )), /* @__PURE__ */ React17__namespace.createElement(AlertDialogContent, null, /* @__PURE__ */ React17__namespace.createElement(AlertDialogDescription, null, "Weet je zeker dat je dit blok wilt verwijderen?"), /* @__PURE__ */ React17__namespace.createElement(AlertDialogFooter, null, /* @__PURE__ */ React17__namespace.createElement(AlertDialogCancel, null, "Annuleren"), /* @__PURE__ */ React17__namespace.createElement(
1435
- AlertDialogAction,
1436
- {
1437
- className: chunkQ2EMWEEZ_js.buttonVariants({ variant: "destructive" }),
1438
- onClick: () => deleteContent(contentId)
1439
- },
1440
- "Verwijderen"
1441
- ))));
1442
- };
1443
-
1444
- // src/components/build-container-client.tsx
1445
- var BuildContainerInner = (props) => {
1446
- const { id, name, content, multiple = false } = props;
1447
- const items = Array.isArray(content) ? content : content?.[name] || [];
1448
- if (!multiple && items.length > 1) {
1449
- console.error(
1450
- "[simple-builder]: Multiple content blocks detected when using property multiple false."
1451
- );
1452
- }
1453
- return /* @__PURE__ */ React17__namespace.createElement("div", null, items.length <= 0 ? /* @__PURE__ */ React17__namespace.createElement(AddContentPlaceholder, { parent: id, container: name, index: 0 }) : multiple && /* @__PURE__ */ React17__namespace.createElement(AddContentDividerButton, { parent: id, container: name, index: 0 }), items.map((item, i) => /* @__PURE__ */ React17__namespace.createElement(React17__namespace.Fragment, { key: item.id }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-relative sb-container-item" }, /* @__PURE__ */ React17__namespace.createElement(chunkSMX2JVU7_js.DesignWrapper, { building: true, styles: item.styles }, chunkSMX2JVU7_js.builder.bindComponent(item, true)), /* @__PURE__ */ React17__namespace.createElement(
1454
- ContainerItemToolbar,
1455
- {
1456
- contentId: item.id,
1457
- canBringUp: i > 0,
1458
- canBringDown: i < items.length - 1
1459
- }
1460
- )), multiple && /* @__PURE__ */ React17__namespace.createElement(
1461
- AddContentDividerButton,
1462
- {
1463
- parent: id,
1464
- container: name,
1465
- index: i + 1
1466
- }
1467
- ))));
1468
- };
1469
- var build_container_client_default = BuildContainerInner;
1470
- var AddContentButton = (props) => {
1471
- const components = chunkSMX2JVU7_js.builder.getComponents();
1472
- const { addContent } = chunkQ2EMWEEZ_js.useBuilder();
1473
- return /* @__PURE__ */ React17__namespace.createElement(Popover, null, /* @__PURE__ */ React17__namespace.createElement(PopoverTrigger, { asChild: true }, props.children), /* @__PURE__ */ React17__namespace.createElement(PopoverContent, { className: "sb-p-1" }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-gap-2" }, components.map((component) => {
1474
- const Icon2 = component.icon ?? lucideReact.ImageIcon;
1475
- return /* @__PURE__ */ React17__namespace.createElement(PopoverClose, { key: component.name, asChild: true }, /* @__PURE__ */ React17__namespace.createElement(
1476
- chunkQ2EMWEEZ_js.Button,
1477
- {
1478
- variant: "ghost",
1479
- className: "sb-justify-start",
1480
- onClick: () => {
1481
- addContent(
1482
- component.name,
1483
- props.container,
1484
- props.parent,
1485
- props.index
1486
- );
1487
- }
1488
- },
1489
- /* @__PURE__ */ React17__namespace.createElement(Icon2, { className: "sb-mr-2 sb-h-4 sb-w-4 sb-shrink-0" }),
1490
- component.friendlyName ?? component.name
1491
- ));
1492
- }))));
1493
- };
1494
- var AddContentPlaceholder = (props) => {
1495
- return /* @__PURE__ */ React17__namespace.createElement(AddContentButton, { ...props }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-flex sb-justify-center sb-bg-primary/50 p-4" }, /* @__PURE__ */ React17__namespace.createElement(chunkQ2EMWEEZ_js.Button, { size: "sm" }, /* @__PURE__ */ React17__namespace.createElement(lucideReact.PlusIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }), "Blok Toevoegen")));
1496
- };
1497
- var AddContentDividerButton = (props) => {
1498
- return /* @__PURE__ */ React17__namespace.createElement(AddContentButton, { ...props }, /* @__PURE__ */ React17__namespace.createElement("div", { className: "sb-w-full sb-h-1 sb--my-[2px] sb-bg-primary sb-relative sb-z-20 sb-opacity-0 add-content-divider-button sb-transition-opacity" }, /* @__PURE__ */ React17__namespace.createElement(
1499
- chunkQ2EMWEEZ_js.Button,
1500
- {
1501
- size: "sm",
1502
- className: "sb-absolute sb-left-1/2 sb-top-1/2 sb--translate-y-1/2 sb--translate-x-1/2 sb-shadow"
1503
- },
1504
- /* @__PURE__ */ React17__namespace.createElement(lucideReact.PlusIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }),
1505
- "Blok Toevoegen"
1506
- )));
1507
- };
1508
-
1509
- module.exports = build_container_client_default;