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