@simple-builder/react 1.3.8 → 1.4.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 (102) hide show
  1. package/dist/{build-container-client-NXIMV3RF.js → build-container-client-EQBL556Y.js} +148 -115
  2. package/dist/{build-container-client-5QC5KVS3.mjs → build-container-client-LMZUWEUI.mjs} +53 -20
  3. package/dist/{builder-content-4ZNXUE7D.mjs → builder-content-OR2VTIUY.mjs} +2 -2
  4. package/dist/{builder-content-2MA6BKJ5.js → builder-content-XNIM2YVG.js} +7 -7
  5. package/dist/{chunk-EVMN5SX2.js → chunk-4SFXTFFU.js} +5 -5
  6. package/dist/{chunk-4TVSMCQU.js → chunk-7I4RGF45.js} +3 -3
  7. package/dist/{chunk-5OV6KPTF.mjs → chunk-MXIMMIPT.mjs} +1 -1
  8. package/dist/{chunk-5Q4KJW4A.mjs → chunk-UA2CNH3R.mjs} +2 -2
  9. package/dist/{chunk-2CPAROZB.js → chunk-YFRFNRKR.js} +1 -1
  10. package/dist/{chunk-B5R6QY7N.mjs → chunk-ZQBKKI2S.mjs} +1 -1
  11. package/dist/index.css +0 -3
  12. package/dist/index.d.mts +6 -12
  13. package/dist/index.d.ts +6 -12
  14. package/dist/index.js +6 -6
  15. package/dist/index.mjs +2 -2
  16. package/package.json +2 -2
  17. package/dist/build-container-client-7Z6WZVBX.js +0 -2294
  18. package/dist/build-container-client-DWKVE65B.mjs +0 -2261
  19. package/dist/build-container-client-FN3PZMM7.mjs +0 -2256
  20. package/dist/build-container-client-FVDRMOZ7.mjs +0 -2254
  21. package/dist/build-container-client-GV52F5RP.js +0 -2297
  22. package/dist/build-container-client-J56NWFBF.mjs +0 -2260
  23. package/dist/build-container-client-L3WD4CG7.mjs +0 -2258
  24. package/dist/build-container-client-RSJ4H3SB.js +0 -2289
  25. package/dist/build-container-client-THZHNQ5S.mjs +0 -2263
  26. package/dist/build-container-client-WGVIYK47.css +0 -1968
  27. package/dist/build-container-client-WHIUDBOZ.mjs +0 -2262
  28. package/dist/build-container-client-WIGFVNOW.css +0 -1971
  29. package/dist/build-container-client-WN35X6JD.js +0 -2290
  30. package/dist/build-container-client-WYIHRPSW.js +0 -2298
  31. package/dist/build-container-client-XAQDWWKB.mjs +0 -2253
  32. package/dist/build-container-client-XOHYMPBB.js +0 -2292
  33. package/dist/build-container-client-YDRPPWCU.js +0 -2296
  34. package/dist/build-container-client-YWNDWXO2.css +0 -1967
  35. package/dist/build-container-client-ZXO66OL5.js +0 -2299
  36. package/dist/builder-content-2ZXIEMS3.js +0 -42
  37. package/dist/builder-content-3H7GF3KF.mjs +0 -20
  38. package/dist/builder-content-3HENFCB5.js +0 -42
  39. package/dist/builder-content-6PIBXDPE.mjs +0 -20
  40. package/dist/builder-content-73ZKCEIT.mjs +0 -20
  41. package/dist/builder-content-BIVYFWCC.js +0 -42
  42. package/dist/builder-content-BKE4JZ75.js +0 -42
  43. package/dist/builder-content-BU4BXER7.mjs +0 -20
  44. package/dist/builder-content-CP5VLMVD.mjs +0 -20
  45. package/dist/builder-content-CY43LFAA.js +0 -42
  46. package/dist/builder-content-FMTTH7R2.js +0 -42
  47. package/dist/builder-content-GBSIY2Z7.js +0 -42
  48. package/dist/builder-content-GJ4HYIOA.mjs +0 -20
  49. package/dist/builder-content-HQXSXBFZ.mjs +0 -20
  50. package/dist/builder-content-MI55X5HA.css +0 -1971
  51. package/dist/builder-content-PWV6LNFT.mjs +0 -20
  52. package/dist/builder-content-RROSPBT4.css +0 -1968
  53. package/dist/builder-content-RV3DPWFH.js +0 -42
  54. package/dist/builder-content-V2MDRHJI.css +0 -1967
  55. package/dist/chunk-2GOYHVMW.mjs +0 -123
  56. package/dist/chunk-2OHBCAZQ.mjs +0 -244
  57. package/dist/chunk-2OYBZSJQ.mjs +0 -123
  58. package/dist/chunk-3QWMKMTN.js +0 -269
  59. package/dist/chunk-454D7NIH.js +0 -153
  60. package/dist/chunk-6GCMYFBT.mjs +0 -20
  61. package/dist/chunk-6GCUWI4L.mjs +0 -135
  62. package/dist/chunk-6KNCX5O5.mjs +0 -123
  63. package/dist/chunk-6VINC5E2.mjs +0 -244
  64. package/dist/chunk-7X5S5JRE.js +0 -42
  65. package/dist/chunk-C5GHD62W.mjs +0 -20
  66. package/dist/chunk-CARNMQP6.mjs +0 -20
  67. package/dist/chunk-CJGHP5Q7.mjs +0 -244
  68. package/dist/chunk-CJNSRJNF.js +0 -42
  69. package/dist/chunk-DZLUIOVD.js +0 -153
  70. package/dist/chunk-EZFQOJHG.mjs +0 -244
  71. package/dist/chunk-F5JWY4CM.mjs +0 -20
  72. package/dist/chunk-H357GPTV.mjs +0 -244
  73. package/dist/chunk-H6OM2V2U.mjs +0 -20
  74. package/dist/chunk-HCM5NR6G.js +0 -269
  75. package/dist/chunk-IQX5LONG.js +0 -153
  76. package/dist/chunk-LEIASP7E.js +0 -153
  77. package/dist/chunk-MBISMJDL.js +0 -269
  78. package/dist/chunk-NDE4WSBA.js +0 -269
  79. package/dist/chunk-NUDE6YTK.js +0 -165
  80. package/dist/chunk-NZ4ZQMIS.js +0 -42
  81. package/dist/chunk-OWZPAOR6.mjs +0 -244
  82. package/dist/chunk-PADTJYXB.mjs +0 -20
  83. package/dist/chunk-QZQRUNAY.js +0 -153
  84. package/dist/chunk-RGBUK5SR.js +0 -269
  85. package/dist/chunk-RNGHWAPZ.js +0 -269
  86. package/dist/chunk-RZFAIM2Q.mjs +0 -123
  87. package/dist/chunk-SFYJAJOD.js +0 -42
  88. package/dist/chunk-SLWJHIVH.mjs +0 -123
  89. package/dist/chunk-TMDKQB2L.js +0 -153
  90. package/dist/chunk-TQQ4WVQU.mjs +0 -123
  91. package/dist/chunk-VCXFPTGD.js +0 -42
  92. package/dist/chunk-VNNNLYSW.js +0 -42
  93. package/dist/chunk-WA7TKN6M.js +0 -42
  94. package/dist/chunk-WI3YU7TV.js +0 -42
  95. package/dist/chunk-WPBR7BJZ.js +0 -269
  96. package/dist/chunk-X5A4S44V.mjs +0 -244
  97. package/dist/chunk-X5GVLHI2.mjs +0 -20
  98. package/dist/chunk-XLE7GSYM.mjs +0 -244
  99. package/dist/chunk-XSG7W73Z.mjs +0 -20
  100. package/dist/chunk-XZNO7DXS.js +0 -153
  101. package/dist/chunk-YKPZPQ5D.js +0 -269
  102. package/dist/chunk-ZZT7HGAM.mjs +0 -123
@@ -1,2299 +0,0 @@
1
- 'use client';
2
- 'use client';
3
- 'use client';
4
- 'use client';
5
- 'use client';
6
- 'use client';
7
- 'use client';
8
- 'use client';
9
- 'use client';
10
- 'use client';
11
- 'use client';
12
- 'use strict';
13
-
14
- require('./chunk-4TVSMCQU.js');
15
- var chunkMBISMJDL_js = require('./chunk-MBISMJDL.js');
16
- var chunkIQX5LONG_js = require('./chunk-IQX5LONG.js');
17
- var React25 = require('react');
18
- var lucideReact = require('lucide-react');
19
- var AlertDialogPrimitive = require('@radix-ui/react-alert-dialog');
20
- var PopoverPrimitive = require('@radix-ui/react-popover');
21
- var react = require('@tiptap/react');
22
- var extensionColor = require('@tiptap/extension-color');
23
- var extensionTextStyle = require('@tiptap/extension-text-style');
24
- var extensionUnderline = require('@tiptap/extension-underline');
25
- var starterKit = require('@tiptap/starter-kit');
26
- var TiptapLink = require('@tiptap/extension-link');
27
- var state = require('@tiptap/pm/state');
28
- var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
29
- var SeparatorPrimitive = require('@radix-ui/react-separator');
30
- var TogglePrimitive = require('@radix-ui/react-toggle');
31
- var classVarianceAuthority = require('class-variance-authority');
32
- var lu = require('react-icons/lu');
33
- var ToggleGroupPrimitive = require('@radix-ui/react-toggle-group');
34
- var DialogPrimitive = require('@radix-ui/react-dialog');
35
- var reactSlot = require('@radix-ui/react-slot');
36
- var reactHookForm = require('react-hook-form');
37
- var LabelPrimitive = require('@radix-ui/react-label');
38
- var SwitchPrimitives = require('@radix-ui/react-switch');
39
- var zod$1 = require('@hookform/resolvers/zod');
40
- var zod = require('zod');
41
- var dateFns = require('date-fns');
42
- var reactDayPicker = require('react-day-picker');
43
- var SelectPrimitive = require('@radix-ui/react-select');
44
- var TabsPrimitive = require('@radix-ui/react-tabs');
45
- var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
46
-
47
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
48
-
49
- function _interopNamespace(e) {
50
- if (e && e.__esModule) return e;
51
- var n = Object.create(null);
52
- if (e) {
53
- Object.keys(e).forEach(function (k) {
54
- if (k !== 'default') {
55
- var d = Object.getOwnPropertyDescriptor(e, k);
56
- Object.defineProperty(n, k, d.get ? d : {
57
- enumerable: true,
58
- get: function () { return e[k]; }
59
- });
60
- }
61
- });
62
- }
63
- n.default = e;
64
- return Object.freeze(n);
65
- }
66
-
67
- var React25__namespace = /*#__PURE__*/_interopNamespace(React25);
68
- var AlertDialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(AlertDialogPrimitive);
69
- var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
70
- var TiptapLink__default = /*#__PURE__*/_interopDefault(TiptapLink);
71
- var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
72
- var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
73
- var TogglePrimitive__namespace = /*#__PURE__*/_interopNamespace(TogglePrimitive);
74
- var ToggleGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(ToggleGroupPrimitive);
75
- var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
76
- var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
77
- var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
78
- var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
79
- var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
80
- var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
81
-
82
- var AlertDialog = AlertDialogPrimitive__namespace.Root;
83
- var AlertDialogTrigger = AlertDialogPrimitive__namespace.Trigger;
84
- var AlertDialogPortal = AlertDialogPrimitive__namespace.Portal;
85
- var AlertDialogOverlay = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
86
- AlertDialogPrimitive__namespace.Overlay,
87
- {
88
- className: chunkIQX5LONG_js.cn(
89
- "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",
90
- className
91
- ),
92
- ...props,
93
- ref
94
- }
95
- ));
96
- AlertDialogOverlay.displayName = AlertDialogPrimitive__namespace.Overlay.displayName;
97
- var AlertDialogContent = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(AlertDialogPortal, null, /* @__PURE__ */ React25__namespace.createElement(AlertDialogOverlay, null), /* @__PURE__ */ React25__namespace.createElement(
98
- AlertDialogPrimitive__namespace.Content,
99
- {
100
- ref,
101
- className: chunkIQX5LONG_js.cn(
102
- "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%] sb:sm:rounded-lg",
103
- className
104
- ),
105
- ...props
106
- }
107
- )));
108
- AlertDialogContent.displayName = AlertDialogPrimitive__namespace.Content.displayName;
109
- var AlertDialogFooter = ({
110
- className,
111
- ...props
112
- }) => /* @__PURE__ */ React25__namespace.createElement(
113
- "div",
114
- {
115
- className: chunkIQX5LONG_js.cn(
116
- "sb:flex sb:flex-col-reverse sb:sm:flex-row sb:sm:justify-end sb:sm:gap-2",
117
- className
118
- ),
119
- ...props
120
- }
121
- );
122
- AlertDialogFooter.displayName = "AlertDialogFooter";
123
- var AlertDialogTitle = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
124
- AlertDialogPrimitive__namespace.Title,
125
- {
126
- ref,
127
- className: chunkIQX5LONG_js.cn("sb:text-lg sb:font-semibold", className),
128
- ...props
129
- }
130
- ));
131
- AlertDialogTitle.displayName = AlertDialogPrimitive__namespace.Title.displayName;
132
- var AlertDialogDescription = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
133
- AlertDialogPrimitive__namespace.Description,
134
- {
135
- ref,
136
- className: chunkIQX5LONG_js.cn("sb:text-sm sb:text-muted-foreground", className),
137
- ...props
138
- }
139
- ));
140
- AlertDialogDescription.displayName = AlertDialogPrimitive__namespace.Description.displayName;
141
- var AlertDialogAction = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
142
- AlertDialogPrimitive__namespace.Action,
143
- {
144
- ref,
145
- className: chunkIQX5LONG_js.cn(chunkMBISMJDL_js.buttonVariants(), className),
146
- ...props
147
- }
148
- ));
149
- AlertDialogAction.displayName = AlertDialogPrimitive__namespace.Action.displayName;
150
- var AlertDialogCancel = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
151
- AlertDialogPrimitive__namespace.Cancel,
152
- {
153
- ref,
154
- className: chunkIQX5LONG_js.cn(
155
- chunkMBISMJDL_js.buttonVariants({ variant: "outline" }),
156
- "sb:mt-2 sb:sm:mt-0",
157
- className
158
- ),
159
- ...props
160
- }
161
- ));
162
- AlertDialogCancel.displayName = AlertDialogPrimitive__namespace.Cancel.displayName;
163
- var Popover = PopoverPrimitive__namespace.Root;
164
- var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
165
- var PopoverClose = PopoverPrimitive__namespace.Close;
166
- var PopoverContent = React25__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(PopoverPrimitive__namespace.Portal, null, /* @__PURE__ */ React25__namespace.createElement(
167
- PopoverPrimitive__namespace.Content,
168
- {
169
- ref,
170
- align,
171
- sideOffset,
172
- className: chunkIQX5LONG_js.cn(
173
- "sb:z-50 sb:w-72 sb:rounded-md sb:border sb:bg-popover sb:text-popover-foreground sb:shadow-md sb:outline-hidden 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)",
174
- className
175
- ),
176
- ...props
177
- }
178
- )));
179
- PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
180
- var Link = TiptapLink__default.default.extend({
181
- inclusive: false,
182
- parseHTML() {
183
- return [{ tag: 'a[href]:not([data-type="button"]):not([href *= "javascript:" i])' }];
184
- },
185
- renderHTML({ HTMLAttributes }) {
186
- return ["a", react.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
187
- },
188
- addOptions() {
189
- return {
190
- ...this.parent?.(),
191
- openOnClick: false
192
- };
193
- },
194
- addProseMirrorPlugins() {
195
- return [
196
- ...this.parent?.() || [],
197
- new state.Plugin({
198
- props: {
199
- handleClick(view, pos) {
200
- const { schema: schema2, doc, tr } = view.state;
201
- const range = react.getMarkRange(doc.resolve(pos), schema2.marks.link);
202
- if (!range) {
203
- return;
204
- }
205
- const { from, to } = range;
206
- const start = Math.min(from, to);
207
- const end = Math.max(from, to);
208
- if (pos < start || pos > end) {
209
- return;
210
- }
211
- const $start = doc.resolve(start);
212
- const $end = doc.resolve(end);
213
- const transaction = tr.setSelection(new state.TextSelection($start, $end));
214
- view.dispatch(transaction);
215
- }
216
- }
217
- })
218
- ];
219
- }
220
- });
221
-
222
- // src/features/rich-text-editor/utils/get-output.ts
223
- var getOutput = (editor, format2) => {
224
- switch (format2) {
225
- case "json":
226
- return editor.getJSON();
227
- case "html":
228
- return editor.isEmpty ? "" : editor.getHTML();
229
- default:
230
- return editor.getText();
231
- }
232
- };
233
-
234
- // src/features/rich-text-editor/hooks/useRichTextEditor.ts
235
- var useRichTextEditor = ({
236
- value,
237
- output = "html",
238
- editorClassName,
239
- onUpdate,
240
- onBlur,
241
- ...options
242
- }) => {
243
- const handleCreate = React25.useCallback(
244
- (editor2) => {
245
- console.count("useRichTextEditor:handleCreate");
246
- if (value && editor2.isEmpty) {
247
- editor2.commands.setContent(value);
248
- }
249
- },
250
- [value]
251
- );
252
- const handleUpdate = React25.useCallback(
253
- (editor2) => {
254
- console.count("useRichTextEditor:handleUpdate");
255
- onUpdate?.(getOutput(editor2, output));
256
- },
257
- [output, onUpdate]
258
- );
259
- const handleBlur = React25.useCallback(
260
- (editor2) => {
261
- console.count("useRichTextEditor:handleBlur");
262
- onBlur?.(getOutput(editor2, output));
263
- },
264
- [output, onBlur]
265
- );
266
- const editor = react.useEditor({
267
- extensions: [starterKit.StarterKit, extensionUnderline.Underline, extensionColor.Color, extensionTextStyle.TextStyle, Link],
268
- editorProps: {
269
- attributes: {
270
- autocomplete: "off",
271
- autocorrect: "off",
272
- autocapitalize: "off",
273
- class: chunkIQX5LONG_js.cn("sb-focus:outline-none", editorClassName)
274
- }
275
- },
276
- onCreate: ({ editor: editor2 }) => handleCreate(editor2),
277
- onUpdate: ({ editor: editor2 }) => handleUpdate(editor2),
278
- onBlur: ({ editor: editor2 }) => handleBlur(editor2),
279
- ...options
280
- });
281
- console.count("useRichTextEditor");
282
- return editor;
283
- };
284
- var DropdownMenu = DropdownMenuPrimitive__namespace.Root;
285
- var DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
286
- var DropdownMenuSubTrigger = React25__namespace.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
287
- DropdownMenuPrimitive__namespace.SubTrigger,
288
- {
289
- ref,
290
- className: chunkIQX5LONG_js.cn(
291
- "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-hidden sb:focus:bg-accent sb:data-[state=open]:bg-accent sb:[&_svg]:pointer-events-none sb:[&_svg]:size-4 sb:[&_svg]:shrink-0",
292
- inset && "sb:pl-8",
293
- className
294
- ),
295
- ...props
296
- },
297
- children,
298
- /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronRight, { className: "sb:ml-auto" })
299
- ));
300
- DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive__namespace.SubTrigger.displayName;
301
- var DropdownMenuSubContent = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
302
- DropdownMenuPrimitive__namespace.SubContent,
303
- {
304
- ref,
305
- className: chunkIQX5LONG_js.cn(
306
- "sb:z-50 sb:min-w-32 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)",
307
- className
308
- ),
309
- ...props
310
- }
311
- ));
312
- DropdownMenuSubContent.displayName = DropdownMenuPrimitive__namespace.SubContent.displayName;
313
- var DropdownMenuContent = React25__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.Portal, null, /* @__PURE__ */ React25__namespace.createElement(
314
- DropdownMenuPrimitive__namespace.Content,
315
- {
316
- ref,
317
- sideOffset,
318
- className: chunkIQX5LONG_js.cn(
319
- "sb:z-50 sb:max-h-(--radix-dropdown-menu-content-available-height) sb:min-w-32 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",
320
- "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)",
321
- className
322
- ),
323
- ...props
324
- }
325
- )));
326
- DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
327
- var DropdownMenuItem = React25__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
328
- DropdownMenuPrimitive__namespace.Item,
329
- {
330
- ref,
331
- className: chunkIQX5LONG_js.cn(
332
- "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-hidden sb:transition-colors sb:focus:bg-accent sb:focus:text-accent-foreground sb:data-disabled:pointer-events-none sb:data-disabled:opacity-50 sb:[&>svg]:size-4 sb:[&>svg]:shrink-0",
333
- inset && "sb:pl-8",
334
- className
335
- ),
336
- ...props
337
- }
338
- ));
339
- DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
340
- var DropdownMenuCheckboxItem = React25__namespace.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
341
- DropdownMenuPrimitive__namespace.CheckboxItem,
342
- {
343
- ref,
344
- className: chunkIQX5LONG_js.cn(
345
- "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-hidden sb:transition-colors sb:focus:bg-accent sb:focus:text-accent-foreground sb:data-disabled:pointer-events-none sb:data-disabled:opacity-50",
346
- className
347
- ),
348
- checked,
349
- ...props
350
- },
351
- /* @__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" }))),
352
- children
353
- ));
354
- DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
355
- var DropdownMenuRadioItem = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
356
- DropdownMenuPrimitive__namespace.RadioItem,
357
- {
358
- ref,
359
- className: chunkIQX5LONG_js.cn(
360
- "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-hidden sb:transition-colors sb:focus:bg-accent sb:focus:text-accent-foreground sb:data-disabled:pointer-events-none sb:data-disabled:opacity-50",
361
- className
362
- ),
363
- ...props
364
- },
365
- /* @__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" }))),
366
- children
367
- ));
368
- DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
369
- var DropdownMenuLabel = React25__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
370
- DropdownMenuPrimitive__namespace.Label,
371
- {
372
- ref,
373
- className: chunkIQX5LONG_js.cn(
374
- "sb:px-2 sb:py-1.5 sb:text-sm sb:font-semibold",
375
- inset && "sb:pl-8",
376
- className
377
- ),
378
- ...props
379
- }
380
- ));
381
- DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
382
- var DropdownMenuSeparator = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
383
- DropdownMenuPrimitive__namespace.Separator,
384
- {
385
- ref,
386
- className: chunkIQX5LONG_js.cn("sb:-mx-1 sb:my-1 sb:h-px sb:bg-muted", className),
387
- ...props
388
- }
389
- ));
390
- DropdownMenuSeparator.displayName = DropdownMenuPrimitive__namespace.Separator.displayName;
391
- var Separator2 = React25__namespace.forwardRef(
392
- ({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
393
- SeparatorPrimitive__namespace.Root,
394
- {
395
- ref,
396
- decorative,
397
- orientation,
398
- className: chunkIQX5LONG_js.cn(
399
- "sb:shrink-0 sb:bg-border",
400
- orientation === "horizontal" ? "sb:h-px sb:w-full" : "sb:h-full sb:w-px",
401
- className
402
- ),
403
- ...props
404
- }
405
- )
406
- );
407
- Separator2.displayName = SeparatorPrimitive__namespace.Root.displayName;
408
- var toggleVariants = classVarianceAuthority.cva(
409
- "sb:inline-flex sb:items-center sb:justify-center sb:gap-2 sb:rounded-md sb:text-sm sb:font-medium sb:transition-colors sb:hover:bg-muted sb:hover:text-muted-foreground sb:focus-visible:outline-hidden sb:focus-visible:ring-1 sb:focus-visible:ring-ring sb:disabled:pointer-events-none sb:disabled:opacity-50 sb:data-[state=on]:bg-accent sb:data-[state=on]:text-accent-foreground sb:[&_svg]:pointer-events-none sb:[&_svg]:size-4 sb:[&_svg]:shrink-0",
410
- {
411
- variants: {
412
- variant: {
413
- default: "sb:bg-transparent",
414
- outline: "sb:border sb:border-input sb:bg-transparent sb:shadow-sm sb:hover:bg-accent sb:hover:text-accent-foreground"
415
- },
416
- size: {
417
- default: "sb:h-9 sb:px-2 sb:min-w-9",
418
- sm: "sb:h-8 sb:px-1.5 sb:min-w-8",
419
- lg: "sb:h-10 sb:px-2.5 sb:min-w-10"
420
- }
421
- },
422
- defaultVariants: {
423
- variant: "default",
424
- size: "default"
425
- }
426
- }
427
- );
428
- var Toggle = React25__namespace.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
429
- TogglePrimitive__namespace.Root,
430
- {
431
- ref,
432
- className: chunkIQX5LONG_js.cn(toggleVariants({ variant, size, className })),
433
- ...props
434
- }
435
- ));
436
- Toggle.displayName = TogglePrimitive__namespace.Root.displayName;
437
- var ToggleGroupContext = React25__namespace.createContext({
438
- size: "default",
439
- variant: "default"
440
- });
441
- var ToggleGroup = React25__namespace.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
442
- ToggleGroupPrimitive__namespace.Root,
443
- {
444
- ref,
445
- className: chunkIQX5LONG_js.cn("sb:flex sb:items-center sb:justify-center sb:gap-1", className),
446
- ...props
447
- },
448
- /* @__PURE__ */ React25__namespace.createElement(ToggleGroupContext.Provider, { value: { variant, size } }, children)
449
- ));
450
- ToggleGroup.displayName = ToggleGroupPrimitive__namespace.Root.displayName;
451
- var ToggleGroupItem = React25__namespace.forwardRef(({ className, children, variant, size, ...props }, ref) => {
452
- const context = React25__namespace.useContext(ToggleGroupContext);
453
- return /* @__PURE__ */ React25__namespace.createElement(
454
- ToggleGroupPrimitive__namespace.Item,
455
- {
456
- ref,
457
- className: chunkIQX5LONG_js.cn(
458
- toggleVariants({
459
- variant: context.variant || variant,
460
- size: context.size || size
461
- }),
462
- className
463
- ),
464
- ...props
465
- },
466
- children
467
- );
468
- });
469
- ToggleGroupItem.displayName = ToggleGroupPrimitive__namespace.Item.displayName;
470
- var PALETTES = [
471
- {
472
- inverse: "hsl(var(--background))",
473
- colors: [
474
- { cssVar: "hsl(var(--foreground))" },
475
- { cssVar: "hsl(var(--primary-foreground))" },
476
- { cssVar: "hsl(var(--secondary-foreground))" },
477
- { cssVar: "hsl(var(--tertiary-foreground))" },
478
- { cssVar: "hsl(var(--muted-foreground))" },
479
- { cssVar: "hsl(var(--accent-foreground))" },
480
- { cssVar: "hsl(var(--destructive-foreground))" }
481
- ]
482
- },
483
- {
484
- inverse: "hsl(var(--foreground))",
485
- colors: [
486
- { cssVar: "hsl(var(--background))" },
487
- { cssVar: "hsl(var(--primary))" },
488
- { cssVar: "hsl(var(--secondary))" },
489
- { cssVar: "hsl(var(--tertiary))" },
490
- { cssVar: "hsl(var(--muted))" },
491
- { cssVar: "hsl(var(--accent))" },
492
- { cssVar: "hsl(var(--destructive))" }
493
- ]
494
- }
495
- ];
496
- var ColorTool = ({ editor }) => {
497
- const color = editor.getAttributes("textStyle")?.color || "hsl(var(--foreground))";
498
- const [selectedColor, setSelectedColor] = React25__namespace.useState(color);
499
- React25__namespace.useEffect(() => {
500
- setSelectedColor(color);
501
- }, [color]);
502
- const handleColorChange = React25__namespace.useCallback(
503
- (value) => {
504
- setSelectedColor(value);
505
- editor.chain().focus().setColor(value).run();
506
- },
507
- [editor]
508
- );
509
- 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(
510
- "svg",
511
- {
512
- xmlns: "http://www.w3.org/2000/svg",
513
- width: "24",
514
- height: "24",
515
- viewBox: "0 0 24 24",
516
- fill: "none",
517
- stroke: "currentColor",
518
- strokeWidth: "2",
519
- strokeLinecap: "round",
520
- strokeLinejoin: "round",
521
- className: "sb:size-5",
522
- style: { color: selectedColor }
523
- },
524
- /* @__PURE__ */ React25__namespace.createElement("path", { d: "M4 20h16" }),
525
- /* @__PURE__ */ React25__namespace.createElement("path", { d: "m6 16 6-12 6 12" }),
526
- /* @__PURE__ */ React25__namespace.createElement("path", { d: "M8 12h8" })
527
- ), /* @__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(
528
- ToggleGroup,
529
- {
530
- type: "single",
531
- value: selectedColor,
532
- onValueChange: handleColorChange,
533
- className: "sb:flex-col sb:gap-1.5"
534
- },
535
- 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(
536
- ToggleGroupItem,
537
- {
538
- tabIndex: 0,
539
- key: j,
540
- className: "sb:relative sb:size-7 sb:rounded-md sb:border sb:p-0",
541
- value: color2.cssVar,
542
- style: { backgroundColor: color2.cssVar }
543
- },
544
- selectedColor === color2.cssVar && /* @__PURE__ */ React25__namespace.createElement(
545
- lu.LuCheck,
546
- {
547
- className: "sb:absolute sb:inset-0 sb:m-auto sb:size-6",
548
- style: { color: pallete.inverse }
549
- }
550
- )
551
- ))))
552
- )));
553
- };
554
- var formatActions = [
555
- {
556
- label: "Normal Text",
557
- element: "span",
558
- className: "sb:grow"
559
- },
560
- {
561
- label: "Heading 1",
562
- element: "h1",
563
- level: 1,
564
- className: "sb:m-0 sb:grow sb:text-3xl sb:font-extrabold"
565
- },
566
- {
567
- label: "Heading 2",
568
- element: "h2",
569
- level: 2,
570
- className: "sb:m-0 sb:grow sb:text-xl sb:font-bold"
571
- },
572
- {
573
- label: "Heading 3",
574
- element: "h3",
575
- level: 3,
576
- className: "sb:m-0 sb:grow sb:text-lg sb:font-semibold"
577
- },
578
- {
579
- label: "Heading 4",
580
- element: "h4",
581
- level: 4,
582
- className: "sb:m-0 sb:grow sb:text-base sb:font-semibold"
583
- }
584
- ];
585
- var ElementTool = ({ editor }) => {
586
- const isActive = editor.isActive("heading");
587
- const handleFormatChange = React25__namespace.useCallback(
588
- (level) => {
589
- if (level) {
590
- editor.chain().focus().toggleHeading({ level }).run();
591
- } else {
592
- editor.chain().focus().setParagraph().run();
593
- }
594
- },
595
- [editor]
596
- );
597
- return /* @__PURE__ */ React25__namespace.createElement(DropdownMenu, null, /* @__PURE__ */ React25__namespace.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(
598
- ToolbarButton,
599
- {
600
- className: "sb:w-12 sb:data-[state=open]:bg-accent",
601
- pressed: isActive
602
- },
603
- /* @__PURE__ */ React25__namespace.createElement(lu.LuHeading, { className: "sb:size-5" }),
604
- /* @__PURE__ */ React25__namespace.createElement(lu.LuChevronDown, { className: "sb:size-5" })
605
- )), /* @__PURE__ */ React25__namespace.createElement(DropdownMenuContent, { align: "start" }, formatActions.map(({ element: Element, ...action }) => /* @__PURE__ */ React25__namespace.createElement(
606
- DropdownMenuItem,
607
- {
608
- key: action.label,
609
- className: chunkIQX5LONG_js.cn({
610
- "sb:bg-accent": action.level ? editor.isActive("heading", { level: action.level }) : editor.isActive("paragraph")
611
- }),
612
- onClick: () => handleFormatChange(action.level)
613
- },
614
- /* @__PURE__ */ React25__namespace.createElement(Element, { className: action.className }, action.label)
615
- ))));
616
- };
617
- var actions = [
618
- {
619
- value: "bold",
620
- label: "Bold",
621
- icon: lu.LuBold,
622
- action: (editor) => editor.chain().focus().toggleBold().run(),
623
- isActive: (editor) => editor.isActive("bold"),
624
- canExecute: (editor) => editor.can().chain().focus().toggleBold().run() && !editor.isActive("codeBlock")
625
- },
626
- {
627
- value: "italic",
628
- label: "Italic",
629
- icon: lu.LuItalic,
630
- action: (editor) => editor.chain().focus().toggleItalic().run(),
631
- isActive: (editor) => editor.isActive("italic"),
632
- canExecute: (editor) => editor.can().chain().focus().toggleItalic().run() && !editor.isActive("codeBlock")
633
- },
634
- {
635
- value: "underline",
636
- label: "Underline",
637
- icon: lu.LuUnderline,
638
- action: (editor) => editor.chain().focus().toggleUnderline().run(),
639
- isActive: (editor) => editor.isActive("underline"),
640
- canExecute: (editor) => editor.can().chain().focus().toggleUnderline().run() && !editor.isActive("codeBlock")
641
- },
642
- {
643
- value: "strikethrough",
644
- label: "Strikethrough",
645
- icon: lu.LuStrikethrough,
646
- action: (editor) => editor.chain().focus().toggleStrike().run(),
647
- isActive: (editor) => editor.isActive("strike"),
648
- canExecute: (editor) => editor.can().chain().focus().toggleStrike().run() && !editor.isActive("codeBlock")
649
- },
650
- {
651
- value: "code",
652
- label: "Code",
653
- icon: lu.LuCode,
654
- action: (editor) => editor.chain().focus().toggleCode().run(),
655
- isActive: (editor) => editor.isActive("code"),
656
- canExecute: (editor) => editor.can().chain().focus().toggleCode().run() && !editor.isActive("codeBlock")
657
- },
658
- {
659
- value: "clearFormatting",
660
- label: "Clear formatting",
661
- icon: lu.LuRemoveFormatting,
662
- action: (editor) => editor.chain().focus().unsetAllMarks().run(),
663
- isActive: () => false,
664
- canExecute: (editor) => editor.can().chain().focus().unsetAllMarks().run() && !editor.isActive("codeBlock")
665
- }
666
- ];
667
- var FormatTool = ({ editor }) => {
668
- return /* @__PURE__ */ React25__namespace.createElement(ToolbarSection, { editor, actions, mainActionCount: 1 });
669
- };
670
- var actions2 = [
671
- {
672
- value: "codeBlock",
673
- label: "Code block",
674
- icon: lu.LuCode,
675
- action: (editor) => editor.chain().focus().toggleCodeBlock().run(),
676
- isActive: (editor) => editor.isActive("codeBlock"),
677
- canExecute: (editor) => editor.can().chain().focus().toggleCodeBlock().run()
678
- },
679
- {
680
- value: "blockquote",
681
- label: "Blockquote",
682
- icon: lu.LuQuote,
683
- action: (editor) => editor.chain().focus().toggleBlockquote().run(),
684
- isActive: (editor) => editor.isActive("blockquote"),
685
- canExecute: (editor) => editor.can().chain().focus().toggleBlockquote().run()
686
- },
687
- {
688
- value: "horizontalRule",
689
- label: "Divider",
690
- icon: lu.LuMinus,
691
- action: (editor) => editor.chain().focus().setHorizontalRule().run(),
692
- isActive: () => false,
693
- canExecute: (editor) => editor.can().chain().focus().setHorizontalRule().run()
694
- }
695
- ];
696
- var InsertTool = ({ editor }) => {
697
- return /* @__PURE__ */ React25__namespace.createElement(ToolbarSection, { editor, actions: actions2, mainActionCount: 0 });
698
- };
699
- var Dialog = DialogPrimitive__namespace.Root;
700
- var DialogTrigger = DialogPrimitive__namespace.Trigger;
701
- var DialogPortal = DialogPrimitive__namespace.Portal;
702
- var DialogOverlay = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
703
- DialogPrimitive__namespace.Overlay,
704
- {
705
- ref,
706
- className: chunkIQX5LONG_js.cn(
707
- "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",
708
- className
709
- ),
710
- ...props
711
- }
712
- ));
713
- DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
714
- 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(
715
- DialogPrimitive__namespace.Content,
716
- {
717
- ref,
718
- className: chunkIQX5LONG_js.cn(
719
- "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%] sb:sm:rounded-lg",
720
- className
721
- ),
722
- ...props
723
- },
724
- children,
725
- /* @__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 sb:hover:opacity-100 sb:focus:outline-hidden sb:focus:ring-2 sb:focus:ring-ring sb:focus:ring-offset-2 sb:disabled:pointer-events-none sb:data-[state=open]:bg-accent sb:data-[state=open]: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"))
726
- )));
727
- DialogContent.displayName = DialogPrimitive__namespace.Content.displayName;
728
- var DialogHeader = ({
729
- className,
730
- ...props
731
- }) => /* @__PURE__ */ React25__namespace.createElement(
732
- "div",
733
- {
734
- className: chunkIQX5LONG_js.cn(
735
- "sb:flex sb:flex-col sb:gap-1.5 sb:text-center sb:sm:text-left",
736
- className
737
- ),
738
- ...props
739
- }
740
- );
741
- DialogHeader.displayName = "DialogHeader";
742
- var DialogTitle = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
743
- DialogPrimitive__namespace.Title,
744
- {
745
- ref,
746
- className: chunkIQX5LONG_js.cn(
747
- "sb:text-lg sb:font-semibold sb:leading-none sb:tracking-tight",
748
- className
749
- ),
750
- ...props
751
- }
752
- ));
753
- DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
754
- var DialogDescription = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
755
- DialogPrimitive__namespace.Description,
756
- {
757
- ref,
758
- className: chunkIQX5LONG_js.cn("sb:text-sm sb:text-muted-foreground", className),
759
- ...props
760
- }
761
- ));
762
- DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
763
- var labelVariants = classVarianceAuthority.cva(
764
- "sb:text-sm sb:font-medium sb:leading-none sb:peer-disabled:cursor-not-allowed sb:peer-disabled:opacity-70"
765
- );
766
- var Label2 = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
767
- LabelPrimitive__namespace.Root,
768
- {
769
- ref,
770
- className: chunkIQX5LONG_js.cn(labelVariants(), className),
771
- ...props
772
- }
773
- ));
774
- Label2.displayName = LabelPrimitive__namespace.Root.displayName;
775
-
776
- // src/components/ui/form.tsx
777
- var Form = reactHookForm.FormProvider;
778
- var FormFieldContext = React25__namespace.createContext(
779
- {}
780
- );
781
- var FormField = ({
782
- ...props
783
- }) => {
784
- return /* @__PURE__ */ React25__namespace.createElement(FormFieldContext.Provider, { value: { name: props.name } }, /* @__PURE__ */ React25__namespace.createElement(reactHookForm.Controller, { ...props }));
785
- };
786
- var useFormField = () => {
787
- const fieldContext = React25__namespace.useContext(FormFieldContext);
788
- const itemContext = React25__namespace.useContext(FormItemContext);
789
- const { getFieldState, formState } = reactHookForm.useFormContext();
790
- const fieldState = getFieldState(fieldContext.name, formState);
791
- if (!fieldContext) {
792
- throw new Error("useFormField should be used within <FormField>");
793
- }
794
- const { id } = itemContext;
795
- return {
796
- id,
797
- name: fieldContext.name,
798
- formItemId: `${id}-form-item`,
799
- formDescriptionId: `${id}-form-item-description`,
800
- formMessageId: `${id}-form-item-message`,
801
- ...fieldState
802
- };
803
- };
804
- var FormItemContext = React25__namespace.createContext(
805
- {}
806
- );
807
- var FormItem = React25__namespace.forwardRef(({ className, ...props }, ref) => {
808
- const id = React25__namespace.useId();
809
- return /* @__PURE__ */ React25__namespace.createElement(FormItemContext.Provider, { value: { id } }, /* @__PURE__ */ React25__namespace.createElement("div", { ref, className: chunkIQX5LONG_js.cn("sb:flex sb:flex-col sb:gap-2", className), ...props }));
810
- });
811
- FormItem.displayName = "FormItem";
812
- var FormLabel = React25__namespace.forwardRef(({ className, ...props }, ref) => {
813
- const { error, formItemId } = useFormField();
814
- return /* @__PURE__ */ React25__namespace.createElement(
815
- Label2,
816
- {
817
- ref,
818
- className: chunkIQX5LONG_js.cn(error && "sb:text-destructive", className),
819
- htmlFor: formItemId,
820
- ...props
821
- }
822
- );
823
- });
824
- FormLabel.displayName = "FormLabel";
825
- var FormControl = React25__namespace.forwardRef(({ ...props }, ref) => {
826
- const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
827
- return /* @__PURE__ */ React25__namespace.createElement(
828
- reactSlot.Slot,
829
- {
830
- ref,
831
- id: formItemId,
832
- "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
833
- "aria-invalid": !!error,
834
- ...props
835
- }
836
- );
837
- });
838
- FormControl.displayName = "FormControl";
839
- var FormDescription = React25__namespace.forwardRef(({ className, ...props }, ref) => {
840
- const { formDescriptionId } = useFormField();
841
- return /* @__PURE__ */ React25__namespace.createElement(
842
- "p",
843
- {
844
- ref,
845
- id: formDescriptionId,
846
- className: chunkIQX5LONG_js.cn("sb:text-[0.8rem] sb:text-muted-foreground", className),
847
- ...props
848
- }
849
- );
850
- });
851
- FormDescription.displayName = "FormDescription";
852
- var FormMessage = React25__namespace.forwardRef(({ className, children, ...props }, ref) => {
853
- const { error, formMessageId } = useFormField();
854
- const body = error ? String(error?.message ?? "") : children;
855
- if (!body) {
856
- return null;
857
- }
858
- return /* @__PURE__ */ React25__namespace.createElement(
859
- "p",
860
- {
861
- ref,
862
- id: formMessageId,
863
- className: chunkIQX5LONG_js.cn("sb:text-[0.8rem] sb:font-medium sb:text-destructive", className),
864
- ...props
865
- },
866
- body
867
- );
868
- });
869
- FormMessage.displayName = "FormMessage";
870
- var Input = React25__namespace.forwardRef(
871
- ({ className, type, ...props }, ref) => {
872
- return /* @__PURE__ */ React25__namespace.createElement(
873
- "input",
874
- {
875
- type,
876
- className: chunkIQX5LONG_js.cn(
877
- "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 sb:file:border-0 sb:file:bg-transparent sb:file:text-sm sb:file:font-medium sb:file:text-foreground sb:placeholder:text-muted-foreground sb:focus-visible:outline-hidden sb:focus-visible:ring-1 sb:focus-visible:ring-ring sb:disabled:cursor-not-allowed sb:disabled:opacity-50 sb:md:text-sm",
878
- className
879
- ),
880
- ref,
881
- ...props
882
- }
883
- );
884
- }
885
- );
886
- Input.displayName = "Input";
887
- var AdvancedInput = React25__namespace.forwardRef(
888
- ({ prepend, append, ...props }, ref) => {
889
- 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));
890
- }
891
- );
892
- AdvancedInput.displayName = "AdvancedInput";
893
- var Switch = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
894
- SwitchPrimitives__namespace.Root,
895
- {
896
- className: chunkIQX5LONG_js.cn(
897
- "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 sb:focus-visible:outline-hidden sb:focus-visible:ring-2 sb:focus-visible:ring-ring sb:focus-visible:ring-offset-2 sb:focus-visible:ring-offset-background sb:disabled:cursor-not-allowed sb:disabled:opacity-50 sb:data-[state=checked]:bg-primary sb:data-[state=unchecked]:bg-input",
898
- className
899
- ),
900
- ...props,
901
- ref
902
- },
903
- /* @__PURE__ */ React25__namespace.createElement(
904
- SwitchPrimitives__namespace.Thumb,
905
- {
906
- className: chunkIQX5LONG_js.cn(
907
- "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 sb:data-[state=checked]:translate-x-4 sb:data-[state=unchecked]:translate-x-0"
908
- )
909
- }
910
- )
911
- ));
912
- Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
913
- var LinkTool = ({ editor }) => {
914
- const [open, setOpen] = React25__namespace.useState(false);
915
- const { from, to } = editor.state.selection;
916
- const text = editor.state.doc.textBetween(from, to, " ");
917
- const handleSetLink = React25__namespace.useCallback(
918
- (url, text2, openInNewTab) => {
919
- editor.chain().focus().extendMarkRange("link").insertContent({
920
- type: "text",
921
- text: text2 || url,
922
- marks: [
923
- {
924
- type: "link",
925
- attrs: {
926
- href: url,
927
- target: openInNewTab ? "_blank" : ""
928
- }
929
- }
930
- ]
931
- }).setLink({ href: url }).run();
932
- editor.commands.enter();
933
- setOpen(false);
934
- },
935
- [editor]
936
- );
937
- return /* @__PURE__ */ React25__namespace.createElement(Dialog, { open, onOpenChange: setOpen }, /* @__PURE__ */ React25__namespace.createElement(DialogTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(
938
- ToolbarButton,
939
- {
940
- pressed: editor.isActive("link"),
941
- disabled: editor.isActive("codeBlock")
942
- },
943
- /* @__PURE__ */ React25__namespace.createElement(lu.LuLink2, { className: "sb:size-5" })
944
- )), /* @__PURE__ */ React25__namespace.createElement(DialogContent, { className: "sb:w-full sb:min-w-80" }, /* @__PURE__ */ React25__namespace.createElement(LinkForm, { onSave: handleSetLink, defaultText: text })));
945
- };
946
- var schema = zod.z.object({
947
- url: zod.z.string().min(0),
948
- text: zod.z.string().optional(),
949
- isNewTab: zod.z.boolean().optional()
950
- });
951
- var LinkForm = ({
952
- onSave,
953
- defaultIsNewTab,
954
- defaultUrl,
955
- defaultText
956
- }) => {
957
- const form = reactHookForm.useForm({
958
- resolver: zod$1.zodResolver(schema),
959
- defaultValues: {
960
- url: defaultUrl || "",
961
- text: defaultText || "",
962
- isNewTab: defaultIsNewTab || false
963
- }
964
- });
965
- const handleSubmit = (values) => {
966
- onSave(values.url, values.text, values.isNewTab);
967
- };
968
- return /* @__PURE__ */ React25__namespace.createElement(Form, { ...form }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-6" }, /* @__PURE__ */ React25__namespace.createElement(
969
- FormField,
970
- {
971
- control: form.control,
972
- name: "url",
973
- 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))
974
- }
975
- ), /* @__PURE__ */ React25__namespace.createElement(
976
- FormField,
977
- {
978
- control: form.control,
979
- name: "text",
980
- 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))
981
- }
982
- ), /* @__PURE__ */ React25__namespace.createElement(
983
- FormField,
984
- {
985
- control: form.control,
986
- name: "isNewTab",
987
- render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:items-center sb:gap-2" }, /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(
988
- Switch,
989
- {
990
- checked: field.value,
991
- onCheckedChange: field.onChange
992
- }
993
- )), /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Open in new tab")), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
994
- }
995
- ), /* @__PURE__ */ React25__namespace.createElement(chunkMBISMJDL_js.Button, { type: "button", onClick: form.handleSubmit(handleSubmit) }, "Save")));
996
- };
997
- var actions3 = [
998
- {
999
- value: "orderedList",
1000
- label: "Numbered list",
1001
- icon: lu.LuListOrdered,
1002
- action: (editor) => editor.chain().focus().toggleOrderedList().run(),
1003
- isActive: (editor) => editor.isActive("orderedList"),
1004
- canExecute: (editor) => editor.can().chain().focus().toggleOrderedList().run()
1005
- },
1006
- {
1007
- value: "bulletList",
1008
- label: "Bullet list",
1009
- icon: lu.LuList,
1010
- action: (editor) => editor.chain().focus().toggleBulletList().run(),
1011
- isActive: (editor) => editor.isActive("bulletList"),
1012
- canExecute: (editor) => editor.can().chain().focus().toggleBulletList().run()
1013
- }
1014
- ];
1015
- var ListTool = ({ editor }) => {
1016
- return /* @__PURE__ */ React25__namespace.createElement(ToolbarSection, { editor, actions: actions3, mainActionCount: 2 });
1017
- };
1018
-
1019
- // src/features/rich-text-editor/components/toolbar.tsx
1020
- var Toolbar = ({ editor }) => {
1021
- 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 })));
1022
- };
1023
- var ToolbarSection = ({
1024
- editor,
1025
- actions: actions4,
1026
- mainActionCount = 0
1027
- }) => {
1028
- const { mainActions, dropdownActions } = React25__namespace.useMemo(() => {
1029
- return {
1030
- mainActions: actions4.slice(0, mainActionCount),
1031
- dropdownActions: actions4.slice(mainActionCount)
1032
- };
1033
- }, [actions4, mainActionCount]);
1034
- const isDropdownActive = React25__namespace.useMemo(() => {
1035
- return dropdownActions.some((action) => action.isActive(editor));
1036
- }, [dropdownActions, editor]);
1037
- return /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, null, mainActions.map((action) => /* @__PURE__ */ React25__namespace.createElement(
1038
- ToolbarButton,
1039
- {
1040
- key: action.label,
1041
- onClick: () => action.action(editor),
1042
- disabled: !action.canExecute(editor),
1043
- pressed: action.isActive(editor)
1044
- },
1045
- /* @__PURE__ */ React25__namespace.createElement(action.icon, { className: "sb:size-5" })
1046
- )), 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(
1047
- DropdownMenuItem,
1048
- {
1049
- key: action.label,
1050
- className: chunkIQX5LONG_js.cn("sb:flex sb:flex-row sb:items-center sb:gap-2", {
1051
- "sb:bg-accent": action.isActive(editor)
1052
- }),
1053
- onClick: () => action.action(editor),
1054
- disabled: !action.canExecute(editor)
1055
- },
1056
- /* @__PURE__ */ React25__namespace.createElement(action.icon, { className: "sb:size-4" }),
1057
- /* @__PURE__ */ React25__namespace.createElement("span", null, action.label)
1058
- )))));
1059
- };
1060
- var ToolbarButton = React25__namespace.forwardRef(({ className, ...props }, ref) => {
1061
- return /* @__PURE__ */ React25__namespace.createElement(
1062
- Toggle,
1063
- {
1064
- size: "sm",
1065
- className: chunkIQX5LONG_js.cn(
1066
- "sb:size-8 sb:p-0 sb:data-[state=on]:bg-accent",
1067
- { "sb:bg-accent": props.pressed },
1068
- className
1069
- ),
1070
- ref,
1071
- ...props
1072
- }
1073
- );
1074
- });
1075
- ToolbarButton.displayName = "ToolbarButton";
1076
-
1077
- // src/features/rich-text-editor/components/rich-text-editor.tsx
1078
- var RichTextEditor = ({
1079
- value,
1080
- onChange,
1081
- className,
1082
- editorClassName,
1083
- editorContentClassName,
1084
- ...props
1085
- }) => {
1086
- console.count("re-render RichTextEditor");
1087
- const editor = useRichTextEditor({
1088
- value,
1089
- onUpdate: onChange,
1090
- editorClassName: chunkIQX5LONG_js.cn("sb:flex-1 sb:px-3 sb:py-1", editorClassName),
1091
- ...props
1092
- });
1093
- if (!editor) {
1094
- return null;
1095
- }
1096
- return /* @__PURE__ */ React25__namespace.createElement(
1097
- "div",
1098
- {
1099
- className: chunkIQX5LONG_js.cn(
1100
- "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 sb:focus-within:border-primary",
1101
- className
1102
- )
1103
- },
1104
- /* @__PURE__ */ React25__namespace.createElement(Toolbar, { editor }),
1105
- /* @__PURE__ */ React25__namespace.createElement(
1106
- react.EditorContent,
1107
- {
1108
- editor,
1109
- className: chunkIQX5LONG_js.cn(
1110
- "sb-editflow prose sb:flex sb:flex-1",
1111
- editorContentClassName
1112
- )
1113
- }
1114
- )
1115
- );
1116
- };
1117
- function Calendar({
1118
- className,
1119
- classNames,
1120
- showOutsideDays = true,
1121
- ...props
1122
- }) {
1123
- return /* @__PURE__ */ React25__namespace.createElement(
1124
- reactDayPicker.DayPicker,
1125
- {
1126
- showOutsideDays,
1127
- className: chunkIQX5LONG_js.cn("sb:p-3 sb:font-roboto", className),
1128
- classNames: {
1129
- months: "sb:flex sb:flex-col sb:sm:flex-row sb:gap-y-4 sb:sm:gap-x-4 sb:sm:gap-y-0",
1130
- month: "sb:gap-y-4",
1131
- caption: "sb:flex sb:justify-center sb:pt-1 sb:relative sb:items-center",
1132
- caption_label: "sb:text-sm sb:font-medium",
1133
- nav: "sb:gap-x-1 sb:flex sb:items-center",
1134
- nav_button: chunkIQX5LONG_js.cn(
1135
- chunkMBISMJDL_js.buttonVariants({ variant: "outline" }),
1136
- "sb:h-7 sb:w-7 sb:bg-transparent sb:p-0 sb:opacity-50 sb:hover:opacity-100"
1137
- ),
1138
- nav_button_previous: "sb:absolute sb:left-1",
1139
- nav_button_next: "sb:absolute sb:right-1",
1140
- table: "sb:w-full sb:border-collapse sb:flex sb:flex-col sb:gap-y-1",
1141
- head_row: "sb:flex",
1142
- head_cell: "sb:text-muted-foreground sb:rounded-md sb:w-8 sb:font-normal sb:text-[0.8rem]",
1143
- row: "sb:flex sb:w-full sb:mt-2",
1144
- cell: chunkIQX5LONG_js.cn(
1145
- "sb:relative sb:p-0 sb:text-center sb:text-sm sb:focus-within:relative sb:focus-within:z-20 sb:[&:has([aria-selected])]:bg-accent sb:[&:has([aria-selected].day-outside)]:bg-accent/50 sb:[&:has([aria-selected].day-range-end)]:rounded-r-md",
1146
- props.mode === "range" ? "sb:[&:has(>.day-range-end)]:rounded-r-md sb:[&:has(>.day-range-start)]:rounded-l-md sb:first:[&:has([aria-selected])]:rounded-l-md sb:last:[&:has([aria-selected])]:rounded-r-md" : "sb:[&:has([aria-selected])]:rounded-md"
1147
- ),
1148
- day: chunkIQX5LONG_js.cn(
1149
- chunkMBISMJDL_js.buttonVariants({ variant: "ghost" }),
1150
- "sb:h-8 sb:w-8 sb:p-0 sb:font-normal sb:aria-selected:opacity-100"
1151
- ),
1152
- day_range_start: "day-range-start",
1153
- day_range_end: "day-range-end",
1154
- day_selected: "sb:bg-primary sb:text-primary-foreground sb:hover:bg-primary sb:hover:text-primary-foreground sb:focus:bg-primary sb:focus:text-primary-foreground",
1155
- day_today: "sb:bg-accent sb:text-accent-foreground",
1156
- day_outside: "day-outside sb:text-muted-foreground sb:opacity-50 sb:aria-selected:bg-accent/50 sb:aria-selected:text-muted-foreground sb:aria-selected:opacity-30",
1157
- day_disabled: "sb:text-muted-foreground sb:opacity-50",
1158
- day_range_middle: "sb:aria-selected:bg-accent sb:aria-selected:text-accent-foreground",
1159
- day_hidden: "invisible",
1160
- ...classNames
1161
- },
1162
- components: {
1163
- IconLeft: () => /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronLeftIcon, { className: "sb:h-4 sb:w-4" }),
1164
- IconRight: () => /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronRightIcon, { className: "sb:h-4 sb:w-4" })
1165
- },
1166
- ...props
1167
- }
1168
- );
1169
- }
1170
- Calendar.displayName = "Calendar";
1171
- var ColorPicker = (props) => {
1172
- const { color, onColorChange, className } = props;
1173
- const colors = props.colors ?? [
1174
- "#000000",
1175
- "#ffffff",
1176
- "#0f172a",
1177
- "#F1F5F9",
1178
- "#64748B",
1179
- "#E6007E",
1180
- "#F8FAFC",
1181
- "#009DD1",
1182
- "#FF0000"
1183
- ];
1184
- return /* @__PURE__ */ React25__namespace.createElement(Popover, null, /* @__PURE__ */ React25__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(
1185
- chunkMBISMJDL_js.Button,
1186
- {
1187
- variant: "outline",
1188
- size: "sm",
1189
- className: chunkIQX5LONG_js.cn(
1190
- "sb:justify-start sb:text-left sb:font-normal sb:normal-case sb:w-full",
1191
- !color && "sb:text-muted-foreground",
1192
- className
1193
- )
1194
- },
1195
- /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:w-full sb:flex sb:items-center sb:gap-2" }, color ? /* @__PURE__ */ React25__namespace.createElement(
1196
- "div",
1197
- {
1198
- className: "sb:h-4 sb:w-4 sb:rounded sb:bg-center! sb:bg-cover! sb:transition-all sb:border",
1199
- style: { background: color }
1200
- }
1201
- ) : /* @__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"))
1202
- )), /* @__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(
1203
- "div",
1204
- {
1205
- key: s,
1206
- style: { background: s },
1207
- className: "sb:rounded-md sb:h-6 sb:w-6 sb:cursor-pointer sb:active:scale-105 sb:border",
1208
- onClick: () => onColorChange(s)
1209
- }
1210
- ))));
1211
- };
1212
- var MediaInput = (props) => {
1213
- const { onFilesChange, limit = 32, multiple = false, onError } = props;
1214
- const id = React25__namespace.useId();
1215
- const [queue, setQueue] = React25__namespace.useState([]);
1216
- const [sources, setSources] = React25__namespace.useState(props.files ?? []);
1217
- const maxConcurrentUploads = 3;
1218
- const uploadingCountRef = React25__namespace.useRef(0);
1219
- const handleFilesAdd = async (e) => {
1220
- const files = e.target.files;
1221
- if (!files || files.length === 0) {
1222
- return;
1223
- }
1224
- if (files.length + sources.length > (multiple ? limit : 1)) {
1225
- onError?.(
1226
- new MediaInputError(
1227
- `Maximaal ${limit} bestanden.`,
1228
- `Je probeerde nu ${files.length + sources.length} bestanden toe te voegen, maar je mag er maximaal ${limit} toevoegen.`
1229
- )
1230
- );
1231
- return;
1232
- }
1233
- const queue2 = Array.from(files);
1234
- setQueue(queue2);
1235
- for (const file of queue2) {
1236
- try {
1237
- while (uploadingCountRef.current >= maxConcurrentUploads && uploadingCountRef.current > 0) {
1238
- await new Promise((resolve) => setTimeout(resolve, 300));
1239
- }
1240
- uploadingCountRef.current++;
1241
- const formData = new FormData();
1242
- formData.append("file", file);
1243
- const res = await fetch("/api/simple-builder/file/upload", {
1244
- method: "POST",
1245
- body: formData
1246
- });
1247
- if (res === void 0 || !res.ok) {
1248
- onError?.(
1249
- new MediaInputError(
1250
- "Bestand uploaden misulukt",
1251
- `Bestand ${file.name} kon niet worden ge\xFCpload.`
1252
- )
1253
- );
1254
- continue;
1255
- }
1256
- const { data: url } = await res.json();
1257
- if (!url) {
1258
- onError?.(
1259
- new MediaInputError(
1260
- "Bestand uploaden misulukt",
1261
- `De URL van bestand ${file.name} kon niet worden opgehaald.`
1262
- )
1263
- );
1264
- continue;
1265
- }
1266
- setSources((prev) => [...prev, url]);
1267
- onFilesChange?.([...sources, url]);
1268
- } catch (e2) {
1269
- onError?.(
1270
- new MediaInputError(
1271
- "Bestand uploaden misulukt",
1272
- `Bestand ${file.name} kon niet worden ge\xFCpload.`
1273
- )
1274
- );
1275
- } finally {
1276
- setQueue((prev) => prev.filter((f) => f !== file));
1277
- uploadingCountRef.current--;
1278
- }
1279
- }
1280
- };
1281
- const handleSourceDelete = async (src) => {
1282
- setSources((prev) => prev.filter((s) => s !== src));
1283
- onFilesChange?.(sources.filter((s) => s !== src));
1284
- await fetch("/api/uploadthing/delete", {
1285
- method: "POST",
1286
- body: JSON.stringify({ src })
1287
- });
1288
- };
1289
- return /* @__PURE__ */ React25__namespace.createElement("div", { className: chunkIQX5LONG_js.cn("flex flex-wrap gap-4", props.className) }, sources.map((src) => /* @__PURE__ */ React25__namespace.createElement(MediaInputItem, { key: src, className: chunkIQX5LONG_js.cn("group", props.itemClassName) }, /* @__PURE__ */ React25__namespace.createElement(
1290
- chunkIQX5LONG_js.Image,
1291
- {
1292
- src,
1293
- alt: "",
1294
- fill: true,
1295
- className: "sb:absolute sb:inset-0 sb:object-cover sb:pointer-events-none"
1296
- }
1297
- ), /* @__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 sb:group-hover:opacity-100" }, /* @__PURE__ */ React25__namespace.createElement(
1298
- "button",
1299
- {
1300
- 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 sb:hover:opacity-100",
1301
- onClick: () => handleSourceDelete(src)
1302
- },
1303
- /* @__PURE__ */ React25__namespace.createElement(lucideReact.Trash2Icon, { className: "sb:h-4 sb:w-4" })
1304
- )))), queue.map((_, i) => /* @__PURE__ */ React25__namespace.createElement(
1305
- MediaInputItem,
1306
- {
1307
- key: i,
1308
- className: chunkIQX5LONG_js.cn(
1309
- "sb:flex sb:h-28 sb:w-28 sb:items-center sb:justify-center",
1310
- props.itemClassName
1311
- )
1312
- },
1313
- /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2Icon, { className: "sb:h-6 sb:w-6 sb:animate-spin" })
1314
- )), multiple || !multiple && !sources.length && !queue.length ? /* @__PURE__ */ React25__namespace.createElement(
1315
- "label",
1316
- {
1317
- htmlFor: id,
1318
- className: chunkIQX5LONG_js.cn(
1319
- "sb:flex sb:h-28 sb:w-28 sb:cursor-pointer sb:items-center sb:justify-center sb:rounded-lg sb:border",
1320
- props.itemClassName
1321
- )
1322
- },
1323
- /* @__PURE__ */ React25__namespace.createElement(lucideReact.PlusIcon, { className: "sb:h-6 sb:w-6" }),
1324
- /* @__PURE__ */ React25__namespace.createElement(
1325
- "input",
1326
- {
1327
- id,
1328
- type: "file",
1329
- onChange: handleFilesAdd,
1330
- multiple,
1331
- accept: ".png,.jpg,.jpeg,.webp,.gif,.svg",
1332
- className: "sb:hidden"
1333
- }
1334
- )
1335
- ) : null);
1336
- };
1337
- var MediaInputItem = (props) => {
1338
- return /* @__PURE__ */ React25__namespace.createElement(
1339
- "div",
1340
- {
1341
- className: chunkIQX5LONG_js.cn(
1342
- "sb:relative sb:h-28 sb:w-28 sb:overflow-hidden sb:rounded-lg sb:border",
1343
- props.className
1344
- )
1345
- },
1346
- props.children
1347
- );
1348
- };
1349
- var MediaInputError = class extends Error {
1350
- title;
1351
- description;
1352
- constructor(message, description) {
1353
- super(message);
1354
- this.title = message;
1355
- this.description = description;
1356
- }
1357
- };
1358
- var Select = SelectPrimitive__namespace.Root;
1359
- var SelectValue = SelectPrimitive__namespace.Value;
1360
- var SelectTrigger = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1361
- SelectPrimitive__namespace.Trigger,
1362
- {
1363
- ref,
1364
- className: chunkIQX5LONG_js.cn(
1365
- "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 sb:placeholder:text-muted-foreground sb:focus:outline-hidden sb:focus:ring-2 sb:focus:ring-ring sb:focus:ring-offset-2 sb:disabled:cursor-not-allowed sb:disabled:opacity-50 sb:[&>span]:line-clamp-1",
1366
- className
1367
- ),
1368
- ...props
1369
- },
1370
- children,
1371
- /* @__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" }))
1372
- ));
1373
- SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
1374
- var SelectScrollUpButton = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1375
- SelectPrimitive__namespace.ScrollUpButton,
1376
- {
1377
- ref,
1378
- className: chunkIQX5LONG_js.cn(
1379
- "sb:flex sb:cursor-default sb:items-center sb:justify-center sb:py-1",
1380
- className
1381
- ),
1382
- ...props
1383
- },
1384
- /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronUp, { className: "sb:h-4 sb:w-4" })
1385
- ));
1386
- SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
1387
- var SelectScrollDownButton = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1388
- SelectPrimitive__namespace.ScrollDownButton,
1389
- {
1390
- ref,
1391
- className: chunkIQX5LONG_js.cn(
1392
- "sb:flex sb:cursor-default sb:items-center sb:justify-center sb:py-1",
1393
- className
1394
- ),
1395
- ...props
1396
- },
1397
- /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronDown, { className: "sb:h-4 sb:w-4" })
1398
- ));
1399
- SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
1400
- var SelectContent = React25__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Portal, null, /* @__PURE__ */ React25__namespace.createElement(
1401
- SelectPrimitive__namespace.Content,
1402
- {
1403
- ref,
1404
- className: chunkIQX5LONG_js.cn(
1405
- "sb:relative sb:z-50 sb:max-h-96 sb:min-w-32 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",
1406
- position === "popper" && "sb:data-[side=bottom]:translate-y-1 sb:data-[side=left]:-translate-x-1 sb:data-[side=right]:translate-x-1 sb:data-[side=top]:-translate-y-1",
1407
- className
1408
- ),
1409
- position,
1410
- ...props
1411
- },
1412
- /* @__PURE__ */ React25__namespace.createElement(SelectScrollUpButton, null),
1413
- /* @__PURE__ */ React25__namespace.createElement(
1414
- SelectPrimitive__namespace.Viewport,
1415
- {
1416
- className: chunkIQX5LONG_js.cn(
1417
- "sb:p-1",
1418
- position === "popper" && "sb:h-(--radix-select-trigger-height) sb:w-full sb:min-w-(--radix-select-trigger-width)"
1419
- )
1420
- },
1421
- children
1422
- ),
1423
- /* @__PURE__ */ React25__namespace.createElement(SelectScrollDownButton, null)
1424
- )));
1425
- SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
1426
- var SelectLabel = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1427
- SelectPrimitive__namespace.Label,
1428
- {
1429
- ref,
1430
- className: chunkIQX5LONG_js.cn(
1431
- "sb:py-1.5 sb:pl-8 sb:pr-2 sb:text-sm sb:font-semibold",
1432
- className
1433
- ),
1434
- ...props
1435
- }
1436
- ));
1437
- SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
1438
- var SelectItem = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1439
- SelectPrimitive__namespace.Item,
1440
- {
1441
- ref,
1442
- className: chunkIQX5LONG_js.cn(
1443
- "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-hidden sb:focus:bg-accent sb:focus:text-accent-foreground sb:data-disabled:pointer-events-none sb:data-disabled:opacity-50",
1444
- className
1445
- ),
1446
- ...props
1447
- },
1448
- /* @__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" }))),
1449
- /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.ItemText, null, children)
1450
- ));
1451
- SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
1452
- var SelectSeparator = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1453
- SelectPrimitive__namespace.Separator,
1454
- {
1455
- ref,
1456
- className: chunkIQX5LONG_js.cn("sb:-mx-1 sb:my-1 sb:h-px sb:bg-muted", className),
1457
- ...props
1458
- }
1459
- ));
1460
- SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
1461
- var Textarea = React25__namespace.forwardRef(
1462
- ({ className, ...props }, ref) => {
1463
- return /* @__PURE__ */ React25__namespace.createElement(
1464
- "textarea",
1465
- {
1466
- className: chunkIQX5LONG_js.cn(
1467
- "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 sb:placeholder:text-muted-foreground sb:focus-visible:outline-hidden sb:focus-visible:ring-1 sb:focus-visible:ring-ring sb:disabled:cursor-not-allowed sb:disabled:opacity-50",
1468
- className
1469
- ),
1470
- ref,
1471
- ...props
1472
- }
1473
- );
1474
- }
1475
- );
1476
- Textarea.displayName = "Textarea";
1477
-
1478
- // src/components/container-item-form.tsx
1479
- var ContainerItemForm = (props) => {
1480
- const { item } = props;
1481
- const { patchItem } = chunkMBISMJDL_js.useBuilder();
1482
- const component = chunkIQX5LONG_js.builder.getComponent(item.component);
1483
- if (!component) {
1484
- throw new Error(
1485
- `[simple-builder]: Component with id ${item.component} not found in container item form component`
1486
- );
1487
- }
1488
- const form = reactHookForm.useForm({
1489
- defaultValues: (component.inputs || []).reduce(
1490
- (acc, input) => ({
1491
- ...acc,
1492
- [input.name]: item?.props?.[input.name] ?? input.defaultValue
1493
- }),
1494
- {}
1495
- )
1496
- });
1497
- const onSubmit = React25__namespace.useCallback(
1498
- (values) => {
1499
- patchItem(item.id, {
1500
- props: values
1501
- });
1502
- },
1503
- [patchItem, item.id]
1504
- );
1505
- return /* @__PURE__ */ React25__namespace.createElement(Form, { ...form }, /* @__PURE__ */ React25__namespace.createElement("form", { onSubmit: form.handleSubmit(onSubmit) }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-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
- )), /* @__PURE__ */ React25__namespace.createElement(chunkMBISMJDL_js.Button, { type: "submit", className: "w-full" }, "Opslaan"))));
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:flex sb:flex-col sb:gap-2" }, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-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 sb:hover:text-foreground"
1550
- },
1551
- /* @__PURE__ */ React25__namespace.createElement(lucideReact.XIcon, { className: "sb:h-4 sb:w-4" })
1552
- ))
1553
- ), /* @__PURE__ */ React25__namespace.createElement(
1554
- chunkMBISMJDL_js.Button,
1555
- {
1556
- type: "button",
1557
- variant: "outline",
1558
- size: "sm",
1559
- className: chunkIQX5LONG_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:flex sb:flex-col sb:gap-2" }, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25__namespace.createElement(DialogTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(chunkMBISMJDL_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 sb:sm: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:flex sb:flex-col sb:gap-2 sb:w-full" }, input.friendlyName !== "" && /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-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
- chunkMBISMJDL_js.Button,
1641
- {
1642
- variant: "outline",
1643
- size: "sm",
1644
- className: chunkIQX5LONG_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 = chunkIQX5LONG_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:gap-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 = chunkIQX5LONG_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 sb:focus-visible:outline-hidden sb:focus-visible:ring-2 sb:focus-visible:ring-ring sb:focus-visible:ring-offset-2 sb:disabled:pointer-events-none sb:disabled:opacity-50 sb:data-[state=active]:bg-background sb:data-[state=active]:text-foreground sb:data-[state=active]: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 sb:focus-visible:outline-hidden sb:disabled:pointer-events-none sb:disabled:opacity-50 sb:data-[state=active]:border-black sb:border-b-2 sb:border-transparent sb:data-[state=active]: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: chunkIQX5LONG_js.cn(
1729
- "sb:ring-offset-background sb:font-roboto sb:focus-visible:outline-hidden sb:focus-visible:ring-2 sb:focus-visible:ring-ring sb:focus-visible: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
- chunkMBISMJDL_js.Button,
1768
- {
1769
- variant: "outline",
1770
- size: "sm",
1771
- className: chunkIQX5LONG_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: "sb:data-[state=active]: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 sb:active:scale-105 sb:border",
1796
- onClick: () => onBackgroundChange(s)
1797
- }
1798
- ))
1799
- ), /* @__PURE__ */ React25__namespace.createElement(
1800
- TabsContent,
1801
- {
1802
- value: "gradient",
1803
- className: "sb:data-[state=active]: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 sb:active: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 = chunkIQX5LONG_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 } = chunkMBISMJDL_js.useBuilder();
2010
- const onSubmit = React25__namespace.useCallback(
2011
- (values) => {
2012
- const { container, hidden, desktop, mobile } = values;
2013
- const dirtyFields = form.formState.dirtyFields;
2014
- const desktopPatch = Object.entries(desktop).reduce(
2015
- (acc, [key, value]) => ({
2016
- ...acc,
2017
- ...value && { [key]: value }
2018
- }),
2019
- { ...item.styles?.desktop }
2020
- );
2021
- const mobilePatch = Object.entries(mobile).reduce(
2022
- (acc, [key, value]) => {
2023
- const desktopValue = desktop[key];
2024
- const isDirty = dirtyFields.desktop?.[key];
2025
- if (value === desktopValue || isDirty) {
2026
- return acc;
2027
- }
2028
- if (["padding", "margin"].includes(key)) {
2029
- if (value === "0px" && desktopValue === "0px") {
2030
- return acc;
2031
- }
2032
- }
2033
- return {
2034
- ...acc,
2035
- ...value && { [key]: value }
2036
- };
2037
- },
2038
- { ...item.styles?.mobile }
2039
- );
2040
- patchItem(item.id, {
2041
- styles: {
2042
- ...container === false && { container },
2043
- ...hidden !== "never" && { hidden },
2044
- ...Object.keys(desktopPatch).length && { desktop: desktopPatch },
2045
- ...Object.keys(mobilePatch).length && { mobile: mobilePatch }
2046
- }
2047
- });
2048
- },
2049
- [patchItem, item.id, form.formState.dirtyFields]
2050
- );
2051
- const [device, setDevice] = React25__namespace.useState("desktop");
2052
- return /* @__PURE__ */ React25__namespace.createElement(Form, { ...form }, /* @__PURE__ */ React25__namespace.createElement("form", { onSubmit: form.handleSubmit(onSubmit) }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-4 sb:p-4" }, /* @__PURE__ */ React25__namespace.createElement(
2053
- Tabs,
2054
- {
2055
- defaultValue: device,
2056
- onValueChange: (device2) => setDevice(device2)
2057
- },
2058
- /* @__PURE__ */ React25__namespace.createElement(TabsList, { className: "sb:h-9 sb:grid sb:w-full sb:grid-cols-2" }, /* @__PURE__ */ React25__namespace.createElement(TabsTrigger, { value: "desktop", className: "sb:text-xs" }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.MonitorIcon, { className: "sb:h-4 sb:w-4 sb:mr-2" }), /* @__PURE__ */ React25__namespace.createElement("span", null, "Desktop")), /* @__PURE__ */ React25__namespace.createElement(TabsTrigger, { value: "mobile", className: "sb:text-xs" }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.SmartphoneIcon, { className: "sb:h-4 sb:w-4 sb:mr-2" }), /* @__PURE__ */ React25__namespace.createElement("span", null, "Mobiel")))
2059
- ), /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-4" }, /* @__PURE__ */ React25__namespace.createElement(
2060
- FormField,
2061
- {
2062
- control: form.control,
2063
- key: `${device}.background`,
2064
- name: `${device}.background`,
2065
- render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Achtergrond"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(
2066
- BackgroundPicker,
2067
- {
2068
- background: field.value,
2069
- onBackgroundChange: field.onChange
2070
- }
2071
- )), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
2072
- }
2073
- ), /* @__PURE__ */ React25__namespace.createElement(
2074
- FormField,
2075
- {
2076
- control: form.control,
2077
- key: `${device}.color`,
2078
- name: `${device}.color`,
2079
- render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Inhoud kleur"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(
2080
- ColorPicker,
2081
- {
2082
- color: field.value,
2083
- onColorChange: field.onChange
2084
- }
2085
- )), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
2086
- }
2087
- ), /* @__PURE__ */ React25__namespace.createElement("hr", null), /* @__PURE__ */ React25__namespace.createElement(
2088
- FormField,
2089
- {
2090
- control: form.control,
2091
- name: "hidden",
2092
- render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Verbergen"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(Select, { value: field.value, onValueChange: field.onChange }, /* @__PURE__ */ React25__namespace.createElement(SelectTrigger, null, /* @__PURE__ */ React25__namespace.createElement(SelectValue, null)), /* @__PURE__ */ React25__namespace.createElement(SelectContent, null, /* @__PURE__ */ React25__namespace.createElement(SelectItem, { value: "never" }, "Nooit"), /* @__PURE__ */ React25__namespace.createElement(SelectItem, { value: "desktop" }, "Op desktop"), /* @__PURE__ */ React25__namespace.createElement(SelectItem, { value: "mobile" }, "Op mobiel"), /* @__PURE__ */ React25__namespace.createElement(SelectItem, { value: "always" }, "Altijd")))), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
2093
- }
2094
- ), /* @__PURE__ */ React25__namespace.createElement("hr", null), /* @__PURE__ */ React25__namespace.createElement(
2095
- FormField,
2096
- {
2097
- control: form.control,
2098
- name: "container",
2099
- render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, { className: "sb:flex sb:flex-row sb:items-center sb:justify-between sb:space-y-0" }, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Volledige breedte"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(
2100
- Switch,
2101
- {
2102
- checked: !field.value,
2103
- onCheckedChange: (v) => field.onChange(!v)
2104
- }
2105
- )), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
2106
- }
2107
- ), /* @__PURE__ */ React25__namespace.createElement("hr", null), /* @__PURE__ */ React25__namespace.createElement(
2108
- FormField,
2109
- {
2110
- control: form.control,
2111
- key: `${device}.padding`,
2112
- name: `${device}.padding`,
2113
- render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Padding"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(
2114
- SpacingInput,
2115
- {
2116
- value: field.value,
2117
- onChange: field.onChange
2118
- }
2119
- )), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
2120
- }
2121
- ), /* @__PURE__ */ React25__namespace.createElement(
2122
- FormField,
2123
- {
2124
- control: form.control,
2125
- key: `${device}.margin`,
2126
- name: `${device}.margin`,
2127
- render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Margin"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(
2128
- SpacingInput,
2129
- {
2130
- value: field.value,
2131
- onChange: field.onChange
2132
- }
2133
- )), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
2134
- }
2135
- )), /* @__PURE__ */ React25__namespace.createElement(chunkMBISMJDL_js.Button, { type: "submit", className: "w-full" }, "Opslaan"))));
2136
- };
2137
- var ScrollArea = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
2138
- ScrollAreaPrimitive__namespace.Root,
2139
- {
2140
- ref,
2141
- className: chunkIQX5LONG_js.cn("sb:relative sb:overflow-hidden", className),
2142
- ...props
2143
- },
2144
- /* @__PURE__ */ React25__namespace.createElement(ScrollAreaPrimitive__namespace.Viewport, { className: "sb:h-full sb:max-h-[80vh] sb:w-full sb:rounded-[inherit]" }, children),
2145
- /* @__PURE__ */ React25__namespace.createElement(ScrollBar, null),
2146
- /* @__PURE__ */ React25__namespace.createElement(ScrollAreaPrimitive__namespace.Corner, null)
2147
- ));
2148
- ScrollArea.displayName = ScrollAreaPrimitive__namespace.Root.displayName;
2149
- var ScrollBar = React25__namespace.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
2150
- ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
2151
- {
2152
- ref,
2153
- orientation,
2154
- className: chunkIQX5LONG_js.cn(
2155
- "sb:flex sb:touch-none sb:select-none sb:transition-colors",
2156
- orientation === "vertical" && "sb:h-full sb:w-2.5 sb:border-l sb:border-l-transparent sb:p-px",
2157
- orientation === "horizontal" && "sb:h-2.5 sb:flex-col sb:border-t sb:border-t-transparent sb:p-px",
2158
- className
2159
- ),
2160
- ...props
2161
- },
2162
- /* @__PURE__ */ React25__namespace.createElement(ScrollAreaPrimitive__namespace.ScrollAreaThumb, { className: "sb:relative sb:flex-1 sb:rounded-full sb:bg-border" })
2163
- ));
2164
- ScrollBar.displayName = ScrollAreaPrimitive__namespace.ScrollAreaScrollbar.displayName;
2165
-
2166
- // src/components/container-item-toolbar.tsx
2167
- var ContainerItemToolbar = (props) => {
2168
- const { contentId, canBringUp = false, canBringDown = false } = props;
2169
- const { bringUp, bringDown } = chunkMBISMJDL_js.useBuilder();
2170
- return /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:absolute sb:z-20 sb:top-1 sb:right-1 sb:rounded-md sb:shadow sb:flex sb:flex-col sb:gap-1 sb:p-1 sb:bg-card sb:text-card-foreground sb-item-toolbar sb:opacity-0 sb:transition-opacity" }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:h-10 sb:p-1 sb:border sb:border-input sb:bg-background sb:rounded-md sb:text-sm sb:font-medium sb:flex sb:gap-1 sb:items-center sb:justify-start" }, /* @__PURE__ */ React25__namespace.createElement(EditButton, { id: contentId }), /* @__PURE__ */ React25__namespace.createElement(
2171
- chunkMBISMJDL_js.Button,
2172
- {
2173
- variant: "ghost",
2174
- className: "sb:w-8 sb:h-8 sb:p-0",
2175
- onClick: () => bringUp(contentId),
2176
- disabled: !canBringUp
2177
- },
2178
- /* @__PURE__ */ React25__namespace.createElement(lucideReact.ArrowUp, { className: "sb:h-5 sb:w-5" })
2179
- ), /* @__PURE__ */ React25__namespace.createElement(
2180
- chunkMBISMJDL_js.Button,
2181
- {
2182
- variant: "ghost",
2183
- className: "sb:w-8 sb:h-8 sb:p-0",
2184
- onClick: () => bringDown(contentId),
2185
- disabled: !canBringDown
2186
- },
2187
- /* @__PURE__ */ React25__namespace.createElement(lucideReact.ArrowDown, { className: "sb:h-5 sb:w-5" })
2188
- ), /* @__PURE__ */ React25__namespace.createElement(DeleteButton, { contentId })));
2189
- };
2190
- var EditButton = ({ id }) => {
2191
- return /* @__PURE__ */ React25__namespace.createElement(Popover, { modal: true }, /* @__PURE__ */ React25__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(chunkMBISMJDL_js.Button, { variant: "ghost", className: "sb:w-8 sb:h-8 sb:p-0" }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Edit2Icon, { className: "sb:h-5 sb:w-5" }))), /* @__PURE__ */ React25__namespace.createElement(
2192
- PopoverContent,
2193
- {
2194
- side: "left",
2195
- align: "start",
2196
- sideOffset: 16,
2197
- alignOffset: -8,
2198
- className: "sb:p-0 sb:relative",
2199
- collisionPadding: 16
2200
- },
2201
- /* @__PURE__ */ React25__namespace.createElement(EditPopoverInner, { id })
2202
- ));
2203
- };
2204
- var EditPopoverInner = (props) => {
2205
- const { id } = props;
2206
- const { getItem } = chunkMBISMJDL_js.useBuilder();
2207
- const item = getItem(id);
2208
- if (!item) {
2209
- throw new Error(
2210
- `[simple-builder]: Item with id ${id} not found in container item form component`
2211
- );
2212
- }
2213
- return /* @__PURE__ */ React25__namespace.createElement(Tabs, null, /* @__PURE__ */ React25__namespace.createElement(TabsList, { variant: "text", defaultValue: "content" }, /* @__PURE__ */ React25__namespace.createElement(TabsTrigger, { variant: "text", value: "content" }, "Inhoud"), /* @__PURE__ */ React25__namespace.createElement(TabsTrigger, { variant: "text", value: "design" }, "Design")), /* @__PURE__ */ React25__namespace.createElement(TabsContent, { value: "content" }, /* @__PURE__ */ React25__namespace.createElement(ScrollArea, null, /* @__PURE__ */ React25__namespace.createElement(ContainerItemForm, { item }))), /* @__PURE__ */ React25__namespace.createElement(TabsContent, { value: "design" }, /* @__PURE__ */ React25__namespace.createElement(ItemDesignForm, { item })));
2214
- };
2215
- var DeleteButton = ({ contentId }) => {
2216
- const { deleteContent } = chunkMBISMJDL_js.useBuilder();
2217
- return /* @__PURE__ */ React25__namespace.createElement(AlertDialog, null, /* @__PURE__ */ React25__namespace.createElement(AlertDialogTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(
2218
- chunkMBISMJDL_js.Button,
2219
- {
2220
- variant: "ghost",
2221
- className: "sb:w-8 sb:h-8 sb:p-0 sb:text-destructive"
2222
- },
2223
- /* @__PURE__ */ React25__namespace.createElement(lucideReact.Trash2Icon, { className: "sb:h-5 sb:w-5" })
2224
- )), /* @__PURE__ */ React25__namespace.createElement(AlertDialogContent, null, /* @__PURE__ */ React25__namespace.createElement(AlertDialogDescription, null, "Weet je zeker dat je dit blok wilt verwijderen?"), /* @__PURE__ */ React25__namespace.createElement(AlertDialogFooter, null, /* @__PURE__ */ React25__namespace.createElement(AlertDialogCancel, null, "Annuleren"), /* @__PURE__ */ React25__namespace.createElement(
2225
- AlertDialogAction,
2226
- {
2227
- className: chunkMBISMJDL_js.buttonVariants({ variant: "destructive" }),
2228
- onClick: () => deleteContent(contentId)
2229
- },
2230
- "Verwijderen"
2231
- ))));
2232
- };
2233
-
2234
- // src/components/build-container-client.tsx
2235
- var BuildContainerInner = (props) => {
2236
- const { id, name, content, multiple = false } = props;
2237
- const items = Array.isArray(content) ? content : content?.[name] || [];
2238
- if (!multiple && items.length > 1) {
2239
- console.error(
2240
- "[simple-builder]: Multiple content blocks detected when using property multiple false."
2241
- );
2242
- }
2243
- return /* @__PURE__ */ React25__namespace.createElement("div", null, items.length <= 0 ? /* @__PURE__ */ React25__namespace.createElement(AddContentPlaceholder, { parent: id, container: name, index: 0 }) : multiple && /* @__PURE__ */ React25__namespace.createElement(AddContentDividerButton, { parent: id, container: name, index: 0 }), items.map((item, i) => /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, { key: item.id }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:relative sb-container-item" }, /* @__PURE__ */ React25__namespace.createElement(chunkIQX5LONG_js.DesignWrapper, { building: true, styles: item.styles }, chunkIQX5LONG_js.builder.bindComponent(item, true)), /* @__PURE__ */ React25__namespace.createElement(
2244
- ContainerItemToolbar,
2245
- {
2246
- contentId: item.id,
2247
- canBringUp: i > 0,
2248
- canBringDown: i < items.length - 1
2249
- }
2250
- )), multiple && /* @__PURE__ */ React25__namespace.createElement(
2251
- AddContentDividerButton,
2252
- {
2253
- parent: id,
2254
- container: name,
2255
- index: i + 1
2256
- }
2257
- ))));
2258
- };
2259
- var build_container_client_default = BuildContainerInner;
2260
- var AddContentButton = (props) => {
2261
- const components = chunkIQX5LONG_js.builder.getComponents();
2262
- const { addContent } = chunkMBISMJDL_js.useBuilder();
2263
- return /* @__PURE__ */ React25__namespace.createElement(Popover, null, /* @__PURE__ */ React25__namespace.createElement(PopoverTrigger, { asChild: true }, props.children), /* @__PURE__ */ React25__namespace.createElement(PopoverContent, { className: "sb:p-1 sb:w-full sb:max-w-xl" }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:grid sb:grid-cols-2 sb:gap-2" }, components.map((component) => {
2264
- const Icon2 = component.icon ?? lucideReact.ImageIcon;
2265
- return /* @__PURE__ */ React25__namespace.createElement(PopoverClose, { key: component.name, asChild: true }, /* @__PURE__ */ React25__namespace.createElement(
2266
- chunkMBISMJDL_js.Button,
2267
- {
2268
- variant: "ghost",
2269
- className: "sb:justify-start",
2270
- onClick: () => {
2271
- addContent(
2272
- component.name,
2273
- props.container,
2274
- props.parent,
2275
- props.index
2276
- );
2277
- }
2278
- },
2279
- /* @__PURE__ */ React25__namespace.createElement(Icon2, { className: "sb:mr-2 sb:h-4 sb:w-4 sb:shrink-0" }),
2280
- component.friendlyName ?? component.name
2281
- ));
2282
- }))));
2283
- };
2284
- var AddContentPlaceholder = (props) => {
2285
- return /* @__PURE__ */ React25__namespace.createElement(AddContentButton, { ...props }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:justify-center sb:bg-primary/50 p-4" }, /* @__PURE__ */ React25__namespace.createElement(chunkMBISMJDL_js.Button, { size: "sm" }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.PlusIcon, { className: "sb:mr-2 sb:h-4 sb:w-4" }), "Blok Toevoegen")));
2286
- };
2287
- var AddContentDividerButton = (props) => {
2288
- return /* @__PURE__ */ React25__namespace.createElement(AddContentButton, { ...props }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:w-full sb:h-1 sb:-my-[2px] sb:bg-primary sb:relative sb:z-20 sb:opacity-0 add-content-divider-button sb:transition-opacity" }, /* @__PURE__ */ React25__namespace.createElement(
2289
- chunkMBISMJDL_js.Button,
2290
- {
2291
- size: "sm",
2292
- className: "sb:absolute sb:left-1/2 sb:top-1/2 sb:-translate-y-1/2 sb:-translate-x-1/2 sb:shadow"
2293
- },
2294
- /* @__PURE__ */ React25__namespace.createElement(lucideReact.PlusIcon, { className: "sb:mr-2 sb:h-4 sb:w-4" }),
2295
- "Blok Toevoegen"
2296
- )));
2297
- };
2298
-
2299
- module.exports = build_container_client_default;