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