@thebuoyant-tsdev/mui-ts-library 3.2.1 → 3.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 (65) hide show
  1. package/README.de.md +15 -0
  2. package/README.md +15 -0
  3. package/dist/components/chord-chart/ChordChart.js +284 -0
  4. package/dist/components/chord-chart/ChordChart.types.js +4 -0
  5. package/dist/components/circle-packing-chart/CirclePackingChart.js +382 -0
  6. package/dist/components/circle-packing-chart/CirclePackingChart.types.js +4 -0
  7. package/dist/components/gantt-chart/GanttBarRow.js +202 -0
  8. package/dist/components/gantt-chart/GanttChart.constants.js +14 -0
  9. package/dist/components/gantt-chart/GanttChart.js +258 -0
  10. package/dist/components/gantt-chart/GanttChart.store.js +119 -0
  11. package/dist/components/gantt-chart/GanttChart.types.js +47 -0
  12. package/dist/components/gantt-chart/GanttDeleteDialog.js +30 -0
  13. package/dist/components/gantt-chart/GanttDependencyArrows.js +54 -0
  14. package/dist/components/gantt-chart/GanttStatusContextMenu.js +36 -0
  15. package/dist/components/gantt-chart/GanttTaskDialog.js +324 -0
  16. package/dist/components/gantt-chart/GanttTaskPanel.js +415 -0
  17. package/dist/components/gantt-chart/GanttTimeline.js +223 -0
  18. package/dist/components/gantt-chart/GanttTimelineHeader.js +90 -0
  19. package/dist/components/gantt-chart/GanttToolbar.js +157 -0
  20. package/dist/components/gantt-chart/GanttWeekendStrips.js +29 -0
  21. package/dist/components/gantt-chart/hooks/useGanttDrag.js +104 -0
  22. package/dist/components/gantt-chart/util/gantt-chart.util.js +150 -0
  23. package/dist/components/horizontal-tree-chart/HorizontalTreeChart.js +488 -0
  24. package/dist/components/horizontal-tree-chart/HorizontalTreeChart.types.js +8 -0
  25. package/dist/components/json-editor/JsonEditor.js +102 -0
  26. package/dist/components/json-editor/JsonEditor.types.js +21 -0
  27. package/dist/components/json-editor/JsonEditorContent.js +185 -0
  28. package/dist/components/json-editor/JsonEditorFooter.js +55 -0
  29. package/dist/components/json-editor/JsonEditorToolbar.js +148 -0
  30. package/dist/components/password-strength-meter/PasswordStrengthBar.js +66 -0
  31. package/dist/components/password-strength-meter/PasswordStrengthMeter.js +272 -0
  32. package/dist/components/password-strength-meter/PasswordStrengthMeter.types.js +27 -0
  33. package/dist/components/password-strength-meter/util/password-strength.util.js +38 -0
  34. package/dist/components/radial-tree-chart/RadialTreeChart.js +447 -0
  35. package/dist/components/radial-tree-chart/RadialTreeChart.types.js +8 -0
  36. package/dist/components/rich-text-editor/RichTextEditor.js +135 -0
  37. package/dist/components/rich-text-editor/RichTextEditor.types.js +74 -0
  38. package/dist/components/rich-text-editor/RichTextEditorColorPicker.js +185 -0
  39. package/dist/components/rich-text-editor/RichTextEditorContent.js +129 -0
  40. package/dist/components/rich-text-editor/RichTextEditorEmojiPicker.js +110 -0
  41. package/dist/components/rich-text-editor/RichTextEditorFooter.js +33 -0
  42. package/dist/components/rich-text-editor/RichTextEditorImageDialog.js +74 -0
  43. package/dist/components/rich-text-editor/RichTextEditorLinkDialog.js +70 -0
  44. package/dist/components/rich-text-editor/RichTextEditorTableMenu.js +97 -0
  45. package/dist/components/rich-text-editor/RichTextEditorToolbar.js +362 -0
  46. package/dist/components/rich-text-editor/util/emojis.js +739 -0
  47. package/dist/components/shared/ToolbarButton.js +22 -0
  48. package/dist/components/shared/normalizeSize.js +6 -0
  49. package/dist/components/sql-editor/SqlEditor.js +100 -0
  50. package/dist/components/sql-editor/SqlEditor.types.js +20 -0
  51. package/dist/components/sql-editor/SqlEditorContent.js +248 -0
  52. package/dist/components/sql-editor/SqlEditorFooter.js +45 -0
  53. package/dist/components/sql-editor/SqlEditorToolbar.js +151 -0
  54. package/dist/components/sunburst-chart/SunburstChart.js +292 -0
  55. package/dist/components/sunburst-chart/SunburstChart.types.js +4 -0
  56. package/dist/components/tag-selection/TagSelection.js +102 -0
  57. package/dist/components/tag-selection/TagSelection.store.js +40 -0
  58. package/dist/components/tag-selection/TagSelection.types.d.ts +2 -0
  59. package/dist/components/tag-selection/TagSelection.types.js +18 -0
  60. package/dist/components/tag-selection/TagSelectionAutocomplete.js +382 -0
  61. package/dist/components/tag-selection/TagSelectionChip.js +30 -0
  62. package/dist/components/tag-selection/TagSelectionSelectedTags.js +73 -0
  63. package/dist/index.cjs +2 -2
  64. package/dist/index.js +23 -8035
  65. package/package.json +1 -1
@@ -0,0 +1,447 @@
1
+ import { DEFAULT_RADIAL_TREE_CHART_TRANSLATION as e } from "./RadialTreeChart.types.js";
2
+ import { useCallback as t, useLayoutEffect as n, useMemo as r, useRef as i, useState as a } from "react";
3
+ import { Avatar as o, Box as s, Divider as c, Popover as ee, Tooltip as te, Typography as l, useTheme as u } from "@mui/material";
4
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
5
+ import * as m from "d3";
6
+ //#region src/components/radial-tree-chart/RadialTreeChart.tsx
7
+ var h = {
8
+ folder: "M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z",
9
+ person: "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"
10
+ };
11
+ function ne({ path: e, size: t }) {
12
+ let n = t / 2;
13
+ return /* @__PURE__ */ f("g", {
14
+ transform: `translate(${-n},${-n})`,
15
+ pointerEvents: "none",
16
+ children: /* @__PURE__ */ f("svg", {
17
+ width: t,
18
+ height: t,
19
+ viewBox: "0 0 24 24",
20
+ overflow: "visible",
21
+ children: /* @__PURE__ */ f("path", {
22
+ d: e,
23
+ fill: "white"
24
+ })
25
+ })
26
+ });
27
+ }
28
+ function re({ info: e, labelA: t, labelB: n }) {
29
+ return /* @__PURE__ */ p(s, {
30
+ sx: {
31
+ p: 2,
32
+ minWidth: 200,
33
+ maxWidth: 280
34
+ },
35
+ children: [/* @__PURE__ */ p(s, {
36
+ sx: {
37
+ display: "flex",
38
+ alignItems: "center",
39
+ gap: 1.5,
40
+ mb: 1.5
41
+ },
42
+ children: [/* @__PURE__ */ f(o, {
43
+ sx: {
44
+ bgcolor: "primary.main",
45
+ width: 40,
46
+ height: 40
47
+ },
48
+ children: e.name.charAt(0).toUpperCase()
49
+ }), /* @__PURE__ */ p(s, { children: [/* @__PURE__ */ f(l, {
50
+ variant: "body2",
51
+ sx: { fontWeight: "bold" },
52
+ children: e.name
53
+ }), e.subname && /* @__PURE__ */ f(l, {
54
+ variant: "caption",
55
+ color: "text.secondary",
56
+ children: e.subname
57
+ })] })]
58
+ }), (e.specialValueA != null || e.specialValueB != null) && /* @__PURE__ */ p(d, { children: [
59
+ /* @__PURE__ */ f(c, { sx: { mb: 1.5 } }),
60
+ e.specialValueA != null && /* @__PURE__ */ p(s, {
61
+ sx: {
62
+ display: "flex",
63
+ justifyContent: "space-between",
64
+ mb: .5
65
+ },
66
+ children: [/* @__PURE__ */ f(l, {
67
+ variant: "caption",
68
+ color: "text.secondary",
69
+ children: t
70
+ }), /* @__PURE__ */ f(l, {
71
+ variant: "caption",
72
+ children: String(e.specialValueA)
73
+ })]
74
+ }),
75
+ e.specialValueB != null && /* @__PURE__ */ p(s, {
76
+ sx: {
77
+ display: "flex",
78
+ justifyContent: "space-between"
79
+ },
80
+ children: [/* @__PURE__ */ f(l, {
81
+ variant: "caption",
82
+ color: "text.secondary",
83
+ children: n
84
+ }), /* @__PURE__ */ f(l, {
85
+ variant: "caption",
86
+ children: String(e.specialValueB)
87
+ })]
88
+ })
89
+ ] })]
90
+ });
91
+ }
92
+ function g({ data: o, size: c = 600, autoFit: d = !0, sortBy: g = "name", showLabels: _ = !0, showIcons: ie = !0, chartColors: v, rootNodeRadius: y = 22, branchNodeRadius: b = 16, leafNodeRadius: x = 11, linkColor: ae, linkStrokeOpacity: oe = 1, linkStrokeWidth: se = 1.5, labelFontSize: ce = 12, labelColor: le, separationSibling: S = 1, separationCousin: C = 2, zoomable: w = !1, drillable: T = !1, onFocusChange: E, showNodePopover: D = !1, renderNodePopoverContent: O, onNodeClick: ue, disabled: k = !1, translation: de }) {
93
+ let A = u(), j = {
94
+ ...e,
95
+ ...de
96
+ }, fe = [
97
+ A.palette.primary.main,
98
+ A.palette.secondary.main,
99
+ A.palette.info.main,
100
+ A.palette.success.main,
101
+ A.palette.warning.main,
102
+ A.palette.error.main
103
+ ], M = v && v.length > 0 ? v : fe, N = t((e) => e.depth === 0 ? y : e.children ? b : x, [
104
+ y,
105
+ b,
106
+ x
107
+ ]), pe = t((e) => e.data.colorConfig?.fill ?? M[e.depth % M.length], [M]), [P, F] = a([o]), I = P[P.length - 1], [me, he] = a(o);
108
+ me !== o && (he(o), F([o]));
109
+ let L = Math.max(1, c / 2 - 70), R = r(() => {
110
+ let e = m.hierarchy(I);
111
+ return g === "value" ? (e.sum((e) => e.value ?? 0), e.sort((e, t) => (t.value ?? 0) - (e.value ?? 0))) : e.sort((e, t) => m.ascending(e.data.name, t.data.name)), m.tree().size([2 * Math.PI, L]).separation((e, t) => (e.parent === t.parent ? S : C) * 1.4 / Math.max(1, e.depth))(e);
112
+ }, [
113
+ I,
114
+ g,
115
+ L,
116
+ S,
117
+ C
118
+ ]), ge = R.links(), z = R.descendants(), _e = r(() => m.linkRadial().angle((e) => e.x).radius((e) => e.y), []), B = t((e) => ({
119
+ id: e.data.id,
120
+ name: e.data.name,
121
+ subname: e.data.subname ?? null,
122
+ value: (typeof e.value == "number" ? e.value : null) ?? e.data.value ?? null,
123
+ specialValueA: e.data.specialValueA ?? null,
124
+ specialValueB: e.data.specialValueB ?? null,
125
+ depth: e.depth,
126
+ path: e.ancestors().map((e) => e.data.name).reverse(),
127
+ childrenCount: e.children?.length ?? 0,
128
+ data: e.data
129
+ }), []), V = i(null), [H, U] = a(`-${c / 2} -${c / 2} ${c} ${c}`), [W, G] = a(1);
130
+ n(() => {
131
+ let e = V.current;
132
+ if (!e) return;
133
+ let t = requestAnimationFrame(() => {
134
+ try {
135
+ let t = e.getBBox();
136
+ U(`${t.x - 20} ${t.y - 20} ${t.width + 40} ${t.height + 40}`);
137
+ } catch {
138
+ U(`-${c / 2} -${c / 2} ${c} ${c}`);
139
+ }
140
+ });
141
+ return () => cancelAnimationFrame(t);
142
+ }, [
143
+ c,
144
+ R,
145
+ _,
146
+ d
147
+ ]);
148
+ let ve = r(() => {
149
+ if (W === 1) return H;
150
+ let [e, t, n, r] = H.split(" ").map(Number), i = n / W, a = r / W;
151
+ return `${e + (n - i) / 2} ${t + (r - a) / 2} ${i} ${a}`;
152
+ }, [H, W]), ye = t((e) => {
153
+ if (!w || k || !e.ctrlKey) return;
154
+ e.preventDefault();
155
+ let t = e.deltaY < 0 ? 1.15 : 1 / 1.15;
156
+ G((e) => Math.max(.25, Math.min(8, e * t)));
157
+ }, [w, k]);
158
+ n(() => {
159
+ if (!w && !T) return;
160
+ let e = (e) => {
161
+ e.key === "Escape" && (w && G(1), T && (F([o]), E?.(null)));
162
+ };
163
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
164
+ }, [
165
+ w,
166
+ T,
167
+ o,
168
+ E
169
+ ]);
170
+ let K = i(null), be = (e) => {
171
+ K.current &&= (clearTimeout(K.current), null), K.current = setTimeout(() => {
172
+ e(), K.current = null;
173
+ }, 250);
174
+ }, xe = () => {
175
+ K.current &&= (clearTimeout(K.current), null);
176
+ }, [Se, q] = a(null), J = i(null), Y = i(null), [Ce, X] = a(!1), [we, Te] = a(null), [Z, Ee] = a({
177
+ left: 0,
178
+ top: 0
179
+ }), [Q, De] = a(null), Oe = t(() => {
180
+ F((e) => {
181
+ if (e.length <= 1) return e;
182
+ let t = e.slice(0, -1);
183
+ return E?.(t.length <= 1 ? null : {
184
+ id: t[t.length - 1].id,
185
+ name: t[t.length - 1].name,
186
+ subname: t[t.length - 1].subname ?? null,
187
+ value: null,
188
+ specialValueA: null,
189
+ specialValueB: null,
190
+ depth: t.length - 1,
191
+ path: t.map((e) => e.name),
192
+ childrenCount: t[t.length - 1].children?.length ?? 0,
193
+ data: t[t.length - 1]
194
+ }), t;
195
+ });
196
+ }, [E]), ke = (e) => {
197
+ k || !T || (e.ctrlKey || e.metaKey) && (xe(), Oe());
198
+ }, Ae = (e) => {
199
+ if (k) return;
200
+ let t = z[Number(e.currentTarget.getAttribute("data-idx"))];
201
+ if (!t) return;
202
+ let n = B(t);
203
+ if ((e.ctrlKey || e.metaKey) && T && t.children) {
204
+ be(() => {
205
+ F((e) => [...e, t.data]), E?.(n);
206
+ });
207
+ return;
208
+ }
209
+ if (D) {
210
+ let t = J.current?.getBoundingClientRect();
211
+ Ee({
212
+ left: t ? e.clientX - t.left : e.clientX,
213
+ top: t ? e.clientY - t.top : e.clientY
214
+ }), Te(Y.current), De(n), X(!0);
215
+ }
216
+ ue?.(n, e);
217
+ }, $ = le || A.palette.text.primary, je = ae || A.palette.text.secondary, Me = A.palette.background.paper, Ne = A.typography.fontFamily;
218
+ return /* @__PURE__ */ p(s, {
219
+ ref: J,
220
+ sx: {
221
+ display: "inline-flex",
222
+ position: "relative",
223
+ opacity: k ? .5 : 1,
224
+ cursor: k ? "not-allowed" : "default",
225
+ userSelect: "none"
226
+ },
227
+ children: [
228
+ T && P.length > 1 && /* @__PURE__ */ f(s, {
229
+ sx: {
230
+ position: "absolute",
231
+ top: 4,
232
+ left: 0,
233
+ right: 0,
234
+ display: "flex",
235
+ justifyContent: "center",
236
+ gap: .5,
237
+ pointerEvents: "none",
238
+ zIndex: 1
239
+ },
240
+ children: /* @__PURE__ */ f(l, {
241
+ variant: "caption",
242
+ sx: {
243
+ bgcolor: "action.hover",
244
+ borderRadius: 1,
245
+ px: 1,
246
+ py: .25,
247
+ color: "text.secondary",
248
+ fontSize: "0.7rem"
249
+ },
250
+ children: P.map((e) => e.name).join(" › ")
251
+ })
252
+ }),
253
+ /* @__PURE__ */ f(s, {
254
+ ref: Y,
255
+ sx: {
256
+ position: "absolute",
257
+ left: Z.left,
258
+ top: Z.top,
259
+ width: 0,
260
+ height: 0
261
+ }
262
+ }),
263
+ /* @__PURE__ */ f("svg", {
264
+ width: c,
265
+ height: c,
266
+ viewBox: ve,
267
+ onWheel: ye,
268
+ style: {
269
+ fontFamily: Ne ?? "sans-serif",
270
+ overflow: w && W > 1 ? "hidden" : "visible"
271
+ },
272
+ role: "img",
273
+ "aria-label": o.name,
274
+ children: /* @__PURE__ */ p("g", {
275
+ ref: V,
276
+ children: [
277
+ /* @__PURE__ */ f("g", {
278
+ fill: "none",
279
+ stroke: je,
280
+ strokeOpacity: oe,
281
+ strokeWidth: se,
282
+ children: ge.map((e, t) => /* @__PURE__ */ f("path", { d: _e(e) }, `link-${t}`))
283
+ }),
284
+ /* @__PURE__ */ f("g", { children: z.map((e, t) => {
285
+ let n = N(e), r = pe(e), i = B(e), a = Se === t, o = e.children ? h.folder : h.person, c = Math.round(n * 1.3);
286
+ return /* @__PURE__ */ f(te, {
287
+ title: /* @__PURE__ */ p(s, {
288
+ sx: {
289
+ py: .5,
290
+ minWidth: 160
291
+ },
292
+ children: [
293
+ /* @__PURE__ */ f(l, {
294
+ variant: "caption",
295
+ sx: {
296
+ fontWeight: "bold",
297
+ display: "block",
298
+ fontSize: "0.8rem"
299
+ },
300
+ children: e.data.name
301
+ }),
302
+ e.data.subname && /* @__PURE__ */ f(l, {
303
+ variant: "caption",
304
+ sx: {
305
+ display: "block",
306
+ opacity: .85
307
+ },
308
+ children: e.data.subname
309
+ }),
310
+ (i.specialValueA != null || i.specialValueB != null || e.children) && /* @__PURE__ */ p(s, {
311
+ sx: {
312
+ mt: .75,
313
+ borderTop: "1px solid rgba(255,255,255,0.2)",
314
+ pt: .75
315
+ },
316
+ children: [
317
+ i.specialValueA != null && /* @__PURE__ */ p(s, {
318
+ sx: {
319
+ display: "flex",
320
+ justifyContent: "space-between",
321
+ gap: 2
322
+ },
323
+ children: [/* @__PURE__ */ f(l, {
324
+ variant: "caption",
325
+ sx: { opacity: .6 },
326
+ children: j.specialValueA ?? "A"
327
+ }), /* @__PURE__ */ f(l, {
328
+ variant: "caption",
329
+ children: String(i.specialValueA)
330
+ })]
331
+ }),
332
+ i.specialValueB != null && /* @__PURE__ */ p(s, {
333
+ sx: {
334
+ display: "flex",
335
+ justifyContent: "space-between",
336
+ gap: 2
337
+ },
338
+ children: [/* @__PURE__ */ f(l, {
339
+ variant: "caption",
340
+ sx: { opacity: .6 },
341
+ children: j.specialValueB ?? "B"
342
+ }), /* @__PURE__ */ f(l, {
343
+ variant: "caption",
344
+ children: String(i.specialValueB)
345
+ })]
346
+ }),
347
+ e.children && /* @__PURE__ */ p(s, {
348
+ sx: {
349
+ display: "flex",
350
+ justifyContent: "space-between",
351
+ gap: 2
352
+ },
353
+ children: [/* @__PURE__ */ f(l, {
354
+ variant: "caption",
355
+ sx: { opacity: .6 },
356
+ children: "Reports"
357
+ }), /* @__PURE__ */ f(l, {
358
+ variant: "caption",
359
+ children: e.children.length
360
+ })]
361
+ })
362
+ ]
363
+ })
364
+ ]
365
+ }),
366
+ followCursor: !0,
367
+ enterDelay: 50,
368
+ enterNextDelay: 0,
369
+ disableHoverListener: k,
370
+ slotProps: { tooltip: { sx: { maxWidth: 260 } } },
371
+ children: /* @__PURE__ */ p("g", {
372
+ "data-idx": t,
373
+ transform: `rotate(${e.x * 180 / Math.PI - 90}) translate(${e.y},0)`,
374
+ onClick: Ae,
375
+ onDoubleClick: ke,
376
+ onMouseEnter: () => !k && q(t),
377
+ onMouseLeave: () => q(null),
378
+ style: { cursor: k ? "not-allowed" : "pointer" },
379
+ children: [
380
+ /* @__PURE__ */ f("circle", {
381
+ r: Math.max(n + 8, 24),
382
+ fill: "transparent"
383
+ }),
384
+ /* @__PURE__ */ f("circle", {
385
+ r: n + 2,
386
+ fill: r,
387
+ fillOpacity: .15
388
+ }),
389
+ /* @__PURE__ */ f("circle", {
390
+ r: n,
391
+ fill: r,
392
+ fillOpacity: a ? .85 : 1,
393
+ style: { transition: "fill-opacity 0.15s" }
394
+ }),
395
+ ie && /* @__PURE__ */ f(ne, {
396
+ path: o,
397
+ size: c
398
+ })
399
+ ]
400
+ })
401
+ }, `node-${e.data.id}-${t}`);
402
+ }) }),
403
+ _ && /* @__PURE__ */ f("g", { children: z.map((e, t) => {
404
+ let n = N(e), r = e.x < Math.PI == !e.children, i = n + 6, a = r ? i : -i, o = r ? "start" : "end";
405
+ return /* @__PURE__ */ f("text", {
406
+ transform: `rotate(${e.x * 180 / Math.PI - 90}) translate(${e.y},0) rotate(${e.x >= Math.PI ? 180 : 0})`,
407
+ dy: "0.35em",
408
+ x: a,
409
+ textAnchor: o,
410
+ paintOrder: "stroke",
411
+ stroke: Me,
412
+ strokeWidth: 3,
413
+ fill: $,
414
+ fontSize: ce,
415
+ fontWeight: e.depth === 0 ? "bold" : "normal",
416
+ pointerEvents: "none",
417
+ children: e.data.name
418
+ }, `lbl-${e.data.id}-${t}`);
419
+ }) })
420
+ ]
421
+ })
422
+ }),
423
+ D && /* @__PURE__ */ f(ee, {
424
+ open: Ce,
425
+ anchorEl: we,
426
+ onClose: () => X(!1),
427
+ anchorOrigin: {
428
+ vertical: "top",
429
+ horizontal: "right"
430
+ },
431
+ transformOrigin: {
432
+ vertical: "top",
433
+ horizontal: "left"
434
+ },
435
+ slotProps: { paper: { elevation: 4 } },
436
+ children: Q && (O ? O(Q) : /* @__PURE__ */ f(re, {
437
+ info: Q,
438
+ labelA: j.specialValueA ?? "Value A",
439
+ labelB: j.specialValueB ?? "Value B"
440
+ }))
441
+ })
442
+ ]
443
+ });
444
+ }
445
+ g.displayName = "RadialTreeChart";
446
+ //#endregion
447
+ export { g as RadialTreeChart };
@@ -0,0 +1,8 @@
1
+ //#region src/components/radial-tree-chart/RadialTreeChart.types.ts
2
+ var e = {
3
+ noData: "No data",
4
+ specialValueA: "Value A",
5
+ specialValueB: "Value B"
6
+ };
7
+ //#endregion
8
+ export { e as DEFAULT_RADIAL_TREE_CHART_TRANSLATION };
@@ -0,0 +1,135 @@
1
+ import { normalizeSize as e } from "../shared/normalizeSize.js";
2
+ import { DEFAULT_RICH_TEXT_EDITOR_TOOLBAR_CONFIG as t, DEFAULT_RICH_TEXT_EDITOR_TRANSLATION as n } from "./RichTextEditor.types.js";
3
+ import { RichTextEditorContent as r } from "./RichTextEditorContent.js";
4
+ import { RichTextEditorToolbar as i } from "./RichTextEditorToolbar.js";
5
+ import { RichTextEditorFooter as a } from "./RichTextEditorFooter.js";
6
+ import { useEffect as o, useState as s } from "react";
7
+ import { Box as c, Divider as l, Paper as u } from "@mui/material";
8
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
9
+ import { useEditor as m } from "@tiptap/react";
10
+ import { StarterKit as h } from "@tiptap/starter-kit";
11
+ import { TextStyle as ee } from "@tiptap/extension-text-style";
12
+ import { Color as g } from "@tiptap/extension-color";
13
+ import { Highlight as _ } from "@tiptap/extension-highlight";
14
+ import { Placeholder as v } from "@tiptap/extension-placeholder";
15
+ import { CharacterCount as y } from "@tiptap/extension-character-count";
16
+ import { TableKit as b } from "@tiptap/extension-table";
17
+ import { Image as x } from "@tiptap/extension-image";
18
+ import { Markdown as S } from "tiptap-markdown";
19
+ //#region src/components/rich-text-editor/RichTextEditor.tsx
20
+ function C({ disabled: C = !1, error: w = !1, height: T, helperText: E, maxCharacters: D, name: O, placeholder: k, readonly: A = !1, showCharacterCount: j = !1, showToolbar: M = !0, showWordCount: N = !1, toolbarConfig: P, translation: F, value: I, width: L, onBlur: R, onChange: z, onFocus: B }) {
21
+ let V = {
22
+ ...n,
23
+ ...F
24
+ }, H = {
25
+ ...t,
26
+ ...P
27
+ }, [U, W] = s(!1), G = e(T), K = e(L), q = G === "auto", J = q ? void 0 : G ?? 200, Y = D !== void 0 && D > 0 || j || N, X = m({
28
+ shouldRerenderOnTransaction: !0,
29
+ extensions: [
30
+ h.configure({ link: { openOnClick: !1 } }),
31
+ ee,
32
+ g,
33
+ _.configure({ multicolor: !0 }),
34
+ S.configure({
35
+ transformPastedText: !0,
36
+ transformCopiedText: !1
37
+ }),
38
+ v.configure({ placeholder: k ?? "" }),
39
+ ...H.showTableButton ? [b] : [],
40
+ ...H.showImageButton ? [x.configure({
41
+ inline: !1,
42
+ allowBase64: !0
43
+ })] : [],
44
+ ...Y ? D !== void 0 && D > 0 ? [y.configure({ limit: D })] : [y] : []
45
+ ],
46
+ content: I ?? "",
47
+ editable: !C && !A,
48
+ onUpdate({ editor: e }) {
49
+ z?.(e.getHTML());
50
+ },
51
+ onBlur() {
52
+ R?.();
53
+ },
54
+ onFocus() {
55
+ B?.();
56
+ }
57
+ });
58
+ o(() => {
59
+ !X || I === void 0 || X.getHTML() !== I && X.commands.setContent(I, { emitUpdate: !1 });
60
+ }, [X, I]), o(() => {
61
+ X && X.setEditable(!C && !A);
62
+ }, [
63
+ X,
64
+ C,
65
+ A
66
+ ]);
67
+ let Z = X?.storage.characterCount?.characters?.() ?? 0, Q = X?.storage.characterCount?.words?.() ?? 0, $ = j || D !== void 0 && D > 0 || N || !!E;
68
+ return /* @__PURE__ */ p(c, {
69
+ sx: U ? {
70
+ position: "fixed",
71
+ top: 0,
72
+ left: 0,
73
+ width: "100vw",
74
+ height: "100vh",
75
+ zIndex: 1300,
76
+ display: "flex",
77
+ flexDirection: "column",
78
+ bgcolor: "background.default",
79
+ p: 1
80
+ } : {
81
+ width: K ?? "100%",
82
+ ...q ? {
83
+ display: "flex",
84
+ flexDirection: "column",
85
+ flex: 1
86
+ } : {}
87
+ },
88
+ children: [
89
+ /* @__PURE__ */ p(u, {
90
+ variant: "outlined",
91
+ sx: {
92
+ display: "flex",
93
+ flexDirection: "column",
94
+ overflow: "hidden",
95
+ ...U || q ? { flex: 1 } : { height: J },
96
+ borderColor: w ? "error.main" : void 0,
97
+ "&:focus-within": {
98
+ borderColor: w ? "error.main" : "primary.main",
99
+ borderWidth: 2
100
+ }
101
+ },
102
+ children: [M && !A && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(i, {
103
+ editor: X,
104
+ toolbarConfig: H,
105
+ translation: V,
106
+ disabled: C,
107
+ isFullscreen: U,
108
+ onToggleFullscreen: () => W((e) => !e)
109
+ }), /* @__PURE__ */ f(l, {})] }), /* @__PURE__ */ f(r, {
110
+ editor: X,
111
+ error: w,
112
+ disabled: C,
113
+ readonly: A
114
+ })]
115
+ }),
116
+ $ && /* @__PURE__ */ f(a, {
117
+ helperText: E,
118
+ error: w,
119
+ showCharacterCount: j || D !== void 0 && D > 0,
120
+ charCount: Z,
121
+ maxCharacters: D && D > 0 ? D : void 0,
122
+ showWordCount: N,
123
+ wordCount: Q,
124
+ translation: V
125
+ }),
126
+ O && /* @__PURE__ */ f("input", {
127
+ type: "hidden",
128
+ name: O,
129
+ value: X ? X.getHTML() : ""
130
+ })
131
+ ]
132
+ });
133
+ }
134
+ //#endregion
135
+ export { C as RichTextEditor };
@@ -0,0 +1,74 @@
1
+ //#region src/components/rich-text-editor/RichTextEditor.types.ts
2
+ var e = {
3
+ showBold: !0,
4
+ showItalic: !0,
5
+ showUnderline: !0,
6
+ showStrike: !0,
7
+ showHeading1: !0,
8
+ showHeading2: !0,
9
+ showHeading3: !0,
10
+ showBulletList: !0,
11
+ showOrderedList: !0,
12
+ showBlockquote: !0,
13
+ showCodeBlock: !0,
14
+ showLink: !0,
15
+ showHorizontalRule: !0,
16
+ showTextColor: !0,
17
+ showHighlight: !0,
18
+ showUndoRedo: !0,
19
+ showClearFormat: !0,
20
+ showFullscreenButton: !1,
21
+ showTableButton: !1,
22
+ showImageButton: !1,
23
+ showEmojiButton: !1
24
+ }, t = {
25
+ bold: "Bold",
26
+ italic: "Italic",
27
+ underline: "Underline",
28
+ strike: "Strikethrough",
29
+ heading1: "Heading 1",
30
+ heading2: "Heading 2",
31
+ heading3: "Heading 3",
32
+ bulletList: "Bullet list",
33
+ orderedList: "Numbered list",
34
+ blockquote: "Blockquote",
35
+ codeBlock: "Code block",
36
+ link: "Insert link",
37
+ horizontalRule: "Horizontal rule",
38
+ textColor: "Text color",
39
+ removeTextColor: "Remove text color",
40
+ highlight: "Highlight",
41
+ removeHighlight: "Remove highlight",
42
+ undo: "Undo",
43
+ redo: "Redo",
44
+ clearFormat: "Clear formatting",
45
+ linkDialogTitle: "Insert link",
46
+ linkDialogUrlLabel: "URL",
47
+ linkDialogSave: "Save",
48
+ linkDialogCancel: "Cancel",
49
+ linkDialogRemove: "Remove link",
50
+ characterCount: "{count} characters",
51
+ characterCountMax: "{count} / {max} characters",
52
+ wordCount: "{count} words",
53
+ fullscreen: "Full screen",
54
+ exitFullscreen: "Exit full screen",
55
+ table: "Table",
56
+ insertTable: "Insert 3×3 table",
57
+ addRowBefore: "Add row before",
58
+ addRowAfter: "Add row after",
59
+ deleteRow: "Delete row",
60
+ addColumnBefore: "Add column before",
61
+ addColumnAfter: "Add column after",
62
+ deleteColumn: "Delete column",
63
+ deleteTable: "Delete table",
64
+ image: "Insert image",
65
+ imageDialogTitle: "Insert image",
66
+ imageDialogUrlLabel: "Image URL",
67
+ imageDialogAltLabel: "Alt text (optional)",
68
+ imageDialogSave: "Insert",
69
+ imageDialogCancel: "Cancel",
70
+ emoji: "Emoji",
71
+ emojiSearchPlaceholder: "Search emoji…"
72
+ };
73
+ //#endregion
74
+ export { e as DEFAULT_RICH_TEXT_EDITOR_TOOLBAR_CONFIG, t as DEFAULT_RICH_TEXT_EDITOR_TRANSLATION };