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