@simple-builder/react 1.3.8 → 1.4.0

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