@simple-builder/react 1.3.9 → 1.4.0

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