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