@thebuoyant-tsdev/mui-ts-library 3.2.1 → 3.6.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.
- package/README.de.md +31 -0
- package/README.md +31 -0
- package/dist/components/chord-chart/ChordChart.js +284 -0
- package/dist/components/chord-chart/ChordChart.types.js +4 -0
- package/dist/components/circle-packing-chart/CirclePackingChart.js +382 -0
- package/dist/components/circle-packing-chart/CirclePackingChart.types.js +4 -0
- package/dist/components/gantt-chart/GanttBarRow.js +202 -0
- package/dist/components/gantt-chart/GanttChart.constants.js +14 -0
- package/dist/components/gantt-chart/GanttChart.js +258 -0
- package/dist/components/gantt-chart/GanttChart.store.js +119 -0
- package/dist/components/gantt-chart/GanttChart.types.js +47 -0
- package/dist/components/gantt-chart/GanttDeleteDialog.js +30 -0
- package/dist/components/gantt-chart/GanttDependencyArrows.js +54 -0
- package/dist/components/gantt-chart/GanttStatusContextMenu.js +36 -0
- package/dist/components/gantt-chart/GanttTaskDialog.js +324 -0
- package/dist/components/gantt-chart/GanttTaskPanel.js +415 -0
- package/dist/components/gantt-chart/GanttTimeline.js +223 -0
- package/dist/components/gantt-chart/GanttTimelineHeader.js +90 -0
- package/dist/components/gantt-chart/GanttToolbar.js +157 -0
- package/dist/components/gantt-chart/GanttWeekendStrips.js +29 -0
- package/dist/components/gantt-chart/hooks/useGanttDrag.js +104 -0
- package/dist/components/gantt-chart/util/gantt-chart.util.js +150 -0
- package/dist/components/horizontal-tree-chart/HorizontalTreeChart.js +488 -0
- package/dist/components/horizontal-tree-chart/HorizontalTreeChart.types.js +8 -0
- package/dist/components/json-editor/JsonEditor.js +102 -0
- package/dist/components/json-editor/JsonEditor.types.js +21 -0
- package/dist/components/json-editor/JsonEditorContent.js +185 -0
- package/dist/components/json-editor/JsonEditorFooter.js +55 -0
- package/dist/components/json-editor/JsonEditorToolbar.js +148 -0
- package/dist/components/password-strength-meter/PasswordStrengthBar.js +66 -0
- package/dist/components/password-strength-meter/PasswordStrengthMeter.js +272 -0
- package/dist/components/password-strength-meter/PasswordStrengthMeter.types.js +27 -0
- package/dist/components/password-strength-meter/util/password-strength.util.js +38 -0
- package/dist/components/radial-tree-chart/RadialTreeChart.js +447 -0
- package/dist/components/radial-tree-chart/RadialTreeChart.types.js +8 -0
- package/dist/components/rich-text-editor/RichTextEditor.js +135 -0
- package/dist/components/rich-text-editor/RichTextEditor.types.js +74 -0
- package/dist/components/rich-text-editor/RichTextEditorColorPicker.js +185 -0
- package/dist/components/rich-text-editor/RichTextEditorContent.js +129 -0
- package/dist/components/rich-text-editor/RichTextEditorEmojiPicker.js +110 -0
- package/dist/components/rich-text-editor/RichTextEditorFooter.js +33 -0
- package/dist/components/rich-text-editor/RichTextEditorImageDialog.js +74 -0
- package/dist/components/rich-text-editor/RichTextEditorLinkDialog.js +70 -0
- package/dist/components/rich-text-editor/RichTextEditorTableMenu.js +97 -0
- package/dist/components/rich-text-editor/RichTextEditorToolbar.js +362 -0
- package/dist/components/rich-text-editor/util/emojis.js +739 -0
- package/dist/components/shared/ToolbarButton.js +22 -0
- package/dist/components/shared/normalizeSize.js +6 -0
- package/dist/components/sql-editor/SqlEditor.d.ts +1 -1
- package/dist/components/sql-editor/SqlEditor.js +113 -0
- package/dist/components/sql-editor/SqlEditor.types.d.ts +9 -0
- package/dist/components/sql-editor/SqlEditor.types.js +24 -0
- package/dist/components/sql-editor/SqlEditorContent.js +248 -0
- package/dist/components/sql-editor/SqlEditorFooter.js +45 -0
- package/dist/components/sql-editor/SqlEditorHistoryMenu.d.ts +11 -0
- package/dist/components/sql-editor/SqlEditorHistoryMenu.js +75 -0
- package/dist/components/sql-editor/SqlEditorToolbar.d.ts +5 -1
- package/dist/components/sql-editor/SqlEditorToolbar.js +163 -0
- package/dist/components/sql-editor/useSqlQueryHistory.d.ts +6 -0
- package/dist/components/sql-editor/useSqlQueryHistory.js +20 -0
- package/dist/components/sql-editor/util/sqlQueryHistory.util.d.ts +12 -0
- package/dist/components/sql-editor/util/sqlQueryHistory.util.js +28 -0
- package/dist/components/sunburst-chart/SunburstChart.js +292 -0
- package/dist/components/sunburst-chart/SunburstChart.types.js +4 -0
- package/dist/components/tag-selection/TagSelection.js +102 -0
- package/dist/components/tag-selection/TagSelection.store.js +40 -0
- package/dist/components/tag-selection/TagSelection.types.d.ts +2 -0
- package/dist/components/tag-selection/TagSelection.types.js +18 -0
- package/dist/components/tag-selection/TagSelectionAutocomplete.js +382 -0
- package/dist/components/tag-selection/TagSelectionChip.js +30 -0
- package/dist/components/tag-selection/TagSelectionSelectedTags.js +73 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +23 -8035
- package/package.json +1 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { ToolbarButton as e } from "../shared/ToolbarButton.js";
|
|
2
|
+
import { SqlEditorHistoryMenu as t } from "./SqlEditorHistoryMenu.js";
|
|
3
|
+
import { useState as n } from "react";
|
|
4
|
+
import { Box as r, Divider as i } from "@mui/material";
|
|
5
|
+
import { redo as a, undo as o } from "@codemirror/commands";
|
|
6
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import u from "@mui/icons-material/ContentCopy";
|
|
8
|
+
import d from "@mui/icons-material/Check";
|
|
9
|
+
import f from "@mui/icons-material/Delete";
|
|
10
|
+
import p from "@mui/icons-material/Undo";
|
|
11
|
+
import m from "@mui/icons-material/Redo";
|
|
12
|
+
import h from "@mui/icons-material/AutoFixHigh";
|
|
13
|
+
import g from "@mui/icons-material/PlayArrow";
|
|
14
|
+
import { format as _ } from "sql-formatter";
|
|
15
|
+
//#region src/components/sql-editor/SqlEditorToolbar.tsx
|
|
16
|
+
var v = {
|
|
17
|
+
standard: "sql",
|
|
18
|
+
mysql: "mysql",
|
|
19
|
+
postgresql: "postgresql",
|
|
20
|
+
sqlite: "sqlite",
|
|
21
|
+
mssql: "tsql"
|
|
22
|
+
};
|
|
23
|
+
function y({ editorView: y, toolbarConfig: b, translation: x, dialect: S, disabled: C, onExecute: w, queryHistory: T = [], onSelectHistoryEntry: E, onClearHistory: D }) {
|
|
24
|
+
let [O, k] = n(!1), A = C || !y;
|
|
25
|
+
function j() {
|
|
26
|
+
let e = y?.state.doc.toString() ?? "";
|
|
27
|
+
navigator.clipboard.writeText(e).then(() => {
|
|
28
|
+
k(!0), setTimeout(() => k(!1), 2e3);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function M() {
|
|
32
|
+
let e = y;
|
|
33
|
+
e && (e.dispatch({ changes: {
|
|
34
|
+
from: 0,
|
|
35
|
+
to: e.state.doc.length,
|
|
36
|
+
insert: ""
|
|
37
|
+
} }), e.focus());
|
|
38
|
+
}
|
|
39
|
+
function N() {
|
|
40
|
+
let e = y;
|
|
41
|
+
e && (o(e), e.focus());
|
|
42
|
+
}
|
|
43
|
+
function P() {
|
|
44
|
+
let e = y;
|
|
45
|
+
e && (a(e), e.focus());
|
|
46
|
+
}
|
|
47
|
+
function F() {
|
|
48
|
+
let e = y;
|
|
49
|
+
if (!e) return;
|
|
50
|
+
let t = e.state.doc.toString();
|
|
51
|
+
try {
|
|
52
|
+
let n = _(t, { language: v[S] });
|
|
53
|
+
e.dispatch({ changes: {
|
|
54
|
+
from: 0,
|
|
55
|
+
to: e.state.doc.length,
|
|
56
|
+
insert: n
|
|
57
|
+
} });
|
|
58
|
+
} catch {}
|
|
59
|
+
e.focus();
|
|
60
|
+
}
|
|
61
|
+
function I() {
|
|
62
|
+
let e = y;
|
|
63
|
+
!e || !w || w(e.state.doc.toString());
|
|
64
|
+
}
|
|
65
|
+
let L = b.showFormat, R = b.showCopy || b.showClear, z = b.showUndoRedo, B = b.showExecute && !!w, V = b.showHistory && !!w && !!E && !!D;
|
|
66
|
+
return /* @__PURE__ */ l(r, {
|
|
67
|
+
sx: {
|
|
68
|
+
display: "flex",
|
|
69
|
+
flexWrap: "wrap",
|
|
70
|
+
alignItems: "center",
|
|
71
|
+
gap: .25,
|
|
72
|
+
px: 1,
|
|
73
|
+
py: .5
|
|
74
|
+
},
|
|
75
|
+
role: "toolbar",
|
|
76
|
+
"aria-label": "SQL editor actions",
|
|
77
|
+
children: [
|
|
78
|
+
L && /* @__PURE__ */ c(r, {
|
|
79
|
+
sx: {
|
|
80
|
+
display: "flex",
|
|
81
|
+
gap: .25
|
|
82
|
+
},
|
|
83
|
+
children: /* @__PURE__ */ c(e, {
|
|
84
|
+
label: x.format,
|
|
85
|
+
icon: /* @__PURE__ */ c(h, { fontSize: "small" }),
|
|
86
|
+
onClick: F,
|
|
87
|
+
disabled: A
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
L && (R || z) && /* @__PURE__ */ c(i, {
|
|
91
|
+
orientation: "vertical",
|
|
92
|
+
flexItem: !0,
|
|
93
|
+
sx: { mx: .5 }
|
|
94
|
+
}),
|
|
95
|
+
R && /* @__PURE__ */ l(r, {
|
|
96
|
+
sx: {
|
|
97
|
+
display: "flex",
|
|
98
|
+
gap: .25
|
|
99
|
+
},
|
|
100
|
+
children: [b.showCopy && /* @__PURE__ */ c(e, {
|
|
101
|
+
label: O ? x.copySuccess : x.copy,
|
|
102
|
+
icon: O ? /* @__PURE__ */ c(d, {
|
|
103
|
+
fontSize: "small",
|
|
104
|
+
color: "success"
|
|
105
|
+
}) : /* @__PURE__ */ c(u, { fontSize: "small" }),
|
|
106
|
+
onClick: j,
|
|
107
|
+
disabled: A
|
|
108
|
+
}), b.showClear && /* @__PURE__ */ c(e, {
|
|
109
|
+
label: x.clear,
|
|
110
|
+
icon: /* @__PURE__ */ c(f, { fontSize: "small" }),
|
|
111
|
+
onClick: M,
|
|
112
|
+
disabled: A
|
|
113
|
+
})]
|
|
114
|
+
}),
|
|
115
|
+
R && z && /* @__PURE__ */ c(i, {
|
|
116
|
+
orientation: "vertical",
|
|
117
|
+
flexItem: !0,
|
|
118
|
+
sx: { mx: .5 }
|
|
119
|
+
}),
|
|
120
|
+
z && /* @__PURE__ */ l(r, {
|
|
121
|
+
sx: {
|
|
122
|
+
display: "flex",
|
|
123
|
+
gap: .25
|
|
124
|
+
},
|
|
125
|
+
children: [/* @__PURE__ */ c(e, {
|
|
126
|
+
label: x.undo,
|
|
127
|
+
icon: /* @__PURE__ */ c(p, { fontSize: "small" }),
|
|
128
|
+
onClick: N,
|
|
129
|
+
disabled: A
|
|
130
|
+
}), /* @__PURE__ */ c(e, {
|
|
131
|
+
label: x.redo,
|
|
132
|
+
icon: /* @__PURE__ */ c(m, { fontSize: "small" }),
|
|
133
|
+
onClick: P,
|
|
134
|
+
disabled: A
|
|
135
|
+
})]
|
|
136
|
+
}),
|
|
137
|
+
V && /* @__PURE__ */ l(s, { children: [(R || z) && /* @__PURE__ */ c(i, {
|
|
138
|
+
orientation: "vertical",
|
|
139
|
+
flexItem: !0,
|
|
140
|
+
sx: { mx: .5 }
|
|
141
|
+
}), /* @__PURE__ */ c(t, {
|
|
142
|
+
history: T,
|
|
143
|
+
onSelect: E,
|
|
144
|
+
onClear: D,
|
|
145
|
+
translation: x,
|
|
146
|
+
disabled: C
|
|
147
|
+
})] }),
|
|
148
|
+
B && /* @__PURE__ */ l(s, { children: [(R || z || V) && /* @__PURE__ */ c(i, {
|
|
149
|
+
orientation: "vertical",
|
|
150
|
+
flexItem: !0,
|
|
151
|
+
sx: { mx: .5 }
|
|
152
|
+
}), /* @__PURE__ */ c(e, {
|
|
153
|
+
label: x.execute,
|
|
154
|
+
icon: /* @__PURE__ */ c(g, { fontSize: "small" }),
|
|
155
|
+
onClick: I,
|
|
156
|
+
disabled: A
|
|
157
|
+
})] }),
|
|
158
|
+
!L && !R && !z && !V && !B && /* @__PURE__ */ c(r, { sx: { height: 32 } })
|
|
159
|
+
]
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
export { y as SqlEditorToolbar };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { addQueryToHistory as e, loadQueryHistory as t, saveQueryHistory as n } from "./util/sqlQueryHistory.util.js";
|
|
2
|
+
import { useCallback as r, useState as i } from "react";
|
|
3
|
+
//#region src/components/sql-editor/useSqlQueryHistory.ts
|
|
4
|
+
function a(a, o) {
|
|
5
|
+
let [s, c] = i(() => t(a));
|
|
6
|
+
return {
|
|
7
|
+
history: s,
|
|
8
|
+
addEntry: r((t) => {
|
|
9
|
+
c((r) => {
|
|
10
|
+
let i = e(r, t, o);
|
|
11
|
+
return n(a, i), i;
|
|
12
|
+
});
|
|
13
|
+
}, [a, o]),
|
|
14
|
+
clearHistory: r(() => {
|
|
15
|
+
c([]), n(a, []);
|
|
16
|
+
}, [a])
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { a as useSqlQueryHistory };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type SqlQueryHistoryEntry = {
|
|
2
|
+
sql: string;
|
|
3
|
+
timestamp: number;
|
|
4
|
+
};
|
|
5
|
+
export declare function loadQueryHistory(storageKey: string): SqlQueryHistoryEntry[];
|
|
6
|
+
export declare function saveQueryHistory(storageKey: string, history: SqlQueryHistoryEntry[]): void;
|
|
7
|
+
/**
|
|
8
|
+
* Adds a new entry to the front of the history. An existing entry with the
|
|
9
|
+
* same SQL is moved to the front instead of duplicated. Result is capped at
|
|
10
|
+
* maxEntries.
|
|
11
|
+
*/
|
|
12
|
+
export declare function addQueryToHistory(history: SqlQueryHistoryEntry[], sql: string, maxEntries: number): SqlQueryHistoryEntry[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/components/sql-editor/util/sqlQueryHistory.util.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (typeof window > "u") return [];
|
|
4
|
+
try {
|
|
5
|
+
let t = window.localStorage.getItem(e);
|
|
6
|
+
if (!t) return [];
|
|
7
|
+
let n = JSON.parse(t);
|
|
8
|
+
return Array.isArray(n) ? n.filter((e) => typeof e?.sql == "string" && typeof e?.timestamp == "number") : [];
|
|
9
|
+
} catch {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function t(e, t) {
|
|
14
|
+
if (!(typeof window > "u")) try {
|
|
15
|
+
window.localStorage.setItem(e, JSON.stringify(t));
|
|
16
|
+
} catch {}
|
|
17
|
+
}
|
|
18
|
+
function n(e, t, n) {
|
|
19
|
+
let r = t.trim();
|
|
20
|
+
if (!r) return e;
|
|
21
|
+
let i = e.filter((e) => e.sql !== r);
|
|
22
|
+
return [{
|
|
23
|
+
sql: r,
|
|
24
|
+
timestamp: Date.now()
|
|
25
|
+
}, ...i].slice(0, Math.max(0, n));
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { n as addQueryToHistory, e as loadQueryHistory, t as saveQueryHistory };
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { useCallback as e, useLayoutEffect as t, useMemo as n, useRef as r, useState as i } from "react";
|
|
2
|
+
import { Box as a, Tooltip as o, Typography as s, useTheme as c } from "@mui/material";
|
|
3
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
4
|
+
import * as d from "d3";
|
|
5
|
+
//#region src/components/sunburst-chart/SunburstChart.tsx
|
|
6
|
+
var f = 2 * Math.PI, p = 11, m = p * .5, h = 5;
|
|
7
|
+
function g(e, t = 0, n = ".", r = ",") {
|
|
8
|
+
if (e == null || !isFinite(e)) return "0";
|
|
9
|
+
let [i, a] = e.toFixed(Math.max(0, t)).split("."), o = i.replace(/\B(?=(\d{3})+(?!\d))/g, r);
|
|
10
|
+
return a ? `${o}${n}${a}` : o;
|
|
11
|
+
}
|
|
12
|
+
function ee(e, t) {
|
|
13
|
+
let n = Math.floor(t / m);
|
|
14
|
+
return n <= 0 ? "" : e.length <= n ? e : n < h ? "" : e.slice(0, n - 1) + "…";
|
|
15
|
+
}
|
|
16
|
+
function te({ node: e, valueDecimalCount: t, valueDecimalSep: n, valueThousandsSep: r }) {
|
|
17
|
+
let i = (e.value ?? 0) > 0, o = e.ancestors().map((e) => e.data.name).reverse().join(" › ");
|
|
18
|
+
return /* @__PURE__ */ u(a, {
|
|
19
|
+
sx: { py: .25 },
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ l(s, {
|
|
22
|
+
variant: "caption",
|
|
23
|
+
sx: {
|
|
24
|
+
fontWeight: "bold",
|
|
25
|
+
display: "block"
|
|
26
|
+
},
|
|
27
|
+
children: e.data.name
|
|
28
|
+
}),
|
|
29
|
+
i && /* @__PURE__ */ l(s, {
|
|
30
|
+
variant: "caption",
|
|
31
|
+
sx: {
|
|
32
|
+
display: "block",
|
|
33
|
+
opacity: .85
|
|
34
|
+
},
|
|
35
|
+
children: g(e.value ?? 0, t, n, r)
|
|
36
|
+
}),
|
|
37
|
+
e.depth > 0 && /* @__PURE__ */ l(s, {
|
|
38
|
+
variant: "caption",
|
|
39
|
+
sx: {
|
|
40
|
+
display: "block",
|
|
41
|
+
opacity: .65,
|
|
42
|
+
mt: .25
|
|
43
|
+
},
|
|
44
|
+
children: o
|
|
45
|
+
})
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function _({ data: s, size: m = 500, showSegmentLabels: h = !0, innerRadius: g = 0, sortBy: _ = "value", chartColors: v, showRootLabel: y = !0, onSegmentClick: b, onZoomChange: x, valueDecimalCount: ne = 0, valueDecimalSeparator: re = ".", valueThousandsSeparator: S = ",", zoomable: C = !1, disabled: w = !1 }) {
|
|
50
|
+
let T = c(), E = r(null), [D, O] = i(`-${m / 2} -${m / 2} ${m} ${m}`), [k, A] = i(1), ie = n(() => {
|
|
51
|
+
if (k === 1) return D;
|
|
52
|
+
let [e, t, n, r] = D.split(" ").map(Number), i = n / k, a = r / k;
|
|
53
|
+
return `${e + (n - i) / 2} ${t + (r - a) / 2} ${i} ${a}`;
|
|
54
|
+
}, [D, k]), j = m / 2, M = Math.max(0, Math.min(g, Math.max(0, j - 1))), N = Math.max(1, j - M), ae = [
|
|
55
|
+
T.palette.primary.main,
|
|
56
|
+
T.palette.secondary.main,
|
|
57
|
+
T.palette.error.main,
|
|
58
|
+
T.palette.warning.main,
|
|
59
|
+
T.palette.success.main,
|
|
60
|
+
T.palette.info.main
|
|
61
|
+
], P = v && v.length > 0 ? v : ae, { root: F, ringThickness: I } = n(() => {
|
|
62
|
+
let e = d.hierarchy(s).sum((e) => e.value ?? 0);
|
|
63
|
+
_ === "value" ? e.sort((e, t) => (t.value ?? 0) - (e.value ?? 0)) : e.sort((e, t) => String(e.data.name).localeCompare(String(t.data.name), void 0, {
|
|
64
|
+
numeric: !0,
|
|
65
|
+
sensitivity: "base"
|
|
66
|
+
}));
|
|
67
|
+
let t = d.partition().size([f, N])(e), n = d.max(t.descendants(), (e) => e.depth) ?? 0, r = n > 0 ? N / n : N;
|
|
68
|
+
return n > 0 && t.descendants().forEach((e) => {
|
|
69
|
+
e.depth === 0 ? (e.y0 = 0, e.y1 = 0) : (e.y0 = (e.depth - 1) * r, e.y1 = e.depth * r);
|
|
70
|
+
}), {
|
|
71
|
+
root: t,
|
|
72
|
+
ringThickness: r
|
|
73
|
+
};
|
|
74
|
+
}, [
|
|
75
|
+
s,
|
|
76
|
+
N,
|
|
77
|
+
_
|
|
78
|
+
]), [L, R] = i(F), [z, oe] = i(F);
|
|
79
|
+
z !== F && (oe(F), R(F));
|
|
80
|
+
let B = n(() => F.children?.map((e) => e.data.name) ?? [F.data.name], [F]), se = n(() => d.scaleOrdinal().domain(B).range(P), [P, B]), V = (e) => {
|
|
81
|
+
if (e.data.colorConfig?.fill) return e.data.colorConfig.fill;
|
|
82
|
+
let t = e;
|
|
83
|
+
for (; t.depth > 1;) t = t.parent;
|
|
84
|
+
return se(t.data.name);
|
|
85
|
+
}, H = n(() => d.arc().startAngle((e) => e.x0).endAngle((e) => e.x1).padAngle((e) => Math.min((e.x1 - e.x0) / 2, .005)).padRadius(j / 2).innerRadius((e) => M + e.y0).outerRadius((e) => M + e.y1 - 1), [j, M]), U = e((e) => {
|
|
86
|
+
let t = f / (L.x1 - L.x0), n = Math.max(0, Math.min(f, (e.x0 - L.x0) * t)), r = Math.max(0, Math.min(f, (e.x1 - L.x0) * t)), i = L.depth === 0 ? 0 : (L.depth - 1) * I;
|
|
87
|
+
return {
|
|
88
|
+
x0: n,
|
|
89
|
+
x1: r,
|
|
90
|
+
y0: Math.max(0, e.y0 - i),
|
|
91
|
+
y1: Math.max(0, e.y1 - i)
|
|
92
|
+
};
|
|
93
|
+
}, [L, I]), W = (e) => e.x1 > e.x0 && e.y1 > e.y0, G = (e) => (M + (e.y0 + e.y1) / 2) * (e.x1 - e.x0) > 12, ce = (e) => {
|
|
94
|
+
let t = (e.x0 + e.x1) / 2 * 180 / Math.PI, n = M + (e.y0 + e.y1) / 2, r = t < 180 ? 0 : 180;
|
|
95
|
+
return `rotate(${t - 90}) translate(${n},0) rotate(${r})`;
|
|
96
|
+
}, le = e((e) => e.ancestors().includes(L), [L]), K = e((e) => {
|
|
97
|
+
let t = e.ancestors().reverse(), n = e.value ?? 0, r = F.value ?? 0;
|
|
98
|
+
return {
|
|
99
|
+
id: e.data.id,
|
|
100
|
+
name: e.data.name,
|
|
101
|
+
value: n || null,
|
|
102
|
+
percentage: r > 0 ? Math.round(n / r * 1e4) / 100 : 0,
|
|
103
|
+
depth: e.depth,
|
|
104
|
+
path: t.map((e) => e.data.name),
|
|
105
|
+
pathIds: t.map((e) => e.data.id),
|
|
106
|
+
childrenCount: e.children?.length ?? 0,
|
|
107
|
+
data: e.data
|
|
108
|
+
};
|
|
109
|
+
}, [F]), q = e((e) => {
|
|
110
|
+
R(e), x && x({
|
|
111
|
+
focusNode: K(e),
|
|
112
|
+
isRoot: e === F
|
|
113
|
+
});
|
|
114
|
+
}, [
|
|
115
|
+
F,
|
|
116
|
+
K,
|
|
117
|
+
x
|
|
118
|
+
]);
|
|
119
|
+
t(() => {
|
|
120
|
+
let e = E.current;
|
|
121
|
+
if (!e) return;
|
|
122
|
+
let t = requestAnimationFrame(() => {
|
|
123
|
+
try {
|
|
124
|
+
let t = e.getBBox();
|
|
125
|
+
O(`${t.x - 8} ${t.y - 8} ${t.width + 16} ${t.height + 16}`);
|
|
126
|
+
} catch {
|
|
127
|
+
O(`-${m / 2} -${m / 2} ${m} ${m}`);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return () => cancelAnimationFrame(t);
|
|
131
|
+
}, [
|
|
132
|
+
m,
|
|
133
|
+
F,
|
|
134
|
+
L,
|
|
135
|
+
M,
|
|
136
|
+
I,
|
|
137
|
+
y
|
|
138
|
+
]);
|
|
139
|
+
let J = r(null), ue = (e) => {
|
|
140
|
+
J.current &&= (clearTimeout(J.current), null), J.current = setTimeout(() => {
|
|
141
|
+
e(), J.current = null;
|
|
142
|
+
}, 250);
|
|
143
|
+
}, Y = () => {
|
|
144
|
+
J.current &&= (clearTimeout(J.current), null);
|
|
145
|
+
};
|
|
146
|
+
t(() => {
|
|
147
|
+
if (w) return;
|
|
148
|
+
let e = (e) => {
|
|
149
|
+
e.key === "Escape" && (Y(), q(F), A(1));
|
|
150
|
+
};
|
|
151
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
152
|
+
}, [
|
|
153
|
+
w,
|
|
154
|
+
F,
|
|
155
|
+
q
|
|
156
|
+
]);
|
|
157
|
+
let de = e((e) => {
|
|
158
|
+
if (!C || w || !e.ctrlKey) return;
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
let t = e.deltaY < 0 ? 1.15 : 1 / 1.15;
|
|
161
|
+
A((e) => Math.max(.25, Math.min(8, e * t)));
|
|
162
|
+
}, [C, w]), X = F.descendants().filter((e) => e.depth > 0), fe = (e) => {
|
|
163
|
+
if (w) return;
|
|
164
|
+
let t = X[Number(e.currentTarget.getAttribute("data-idx"))];
|
|
165
|
+
if (t) {
|
|
166
|
+
if (e.ctrlKey || e.metaKey) {
|
|
167
|
+
t.children && ue(() => q(t));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
b?.(K(t), e);
|
|
171
|
+
}
|
|
172
|
+
}, pe = (e) => {
|
|
173
|
+
w || (e.ctrlKey || e.metaKey) && (Y(), q(L.parent ?? F));
|
|
174
|
+
}, Z = (e) => {
|
|
175
|
+
if (!w) {
|
|
176
|
+
if (e.ctrlKey || e.metaKey) {
|
|
177
|
+
Y(), q(L.parent ?? F);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
b?.(K(L.parent ?? F), e);
|
|
181
|
+
}
|
|
182
|
+
}, Q = {
|
|
183
|
+
followCursor: !0,
|
|
184
|
+
enterDelay: 50,
|
|
185
|
+
enterNextDelay: 0,
|
|
186
|
+
disableHoverListener: w,
|
|
187
|
+
slotProps: { tooltip: { sx: { maxWidth: 260 } } }
|
|
188
|
+
}, $ = T.palette.text.primary, me = T.typography.fontFamily;
|
|
189
|
+
return /* @__PURE__ */ l(a, {
|
|
190
|
+
sx: {
|
|
191
|
+
display: "inline-flex",
|
|
192
|
+
opacity: w ? .5 : 1,
|
|
193
|
+
cursor: w ? "not-allowed" : "default",
|
|
194
|
+
userSelect: "none"
|
|
195
|
+
},
|
|
196
|
+
children: /* @__PURE__ */ l("svg", {
|
|
197
|
+
width: m,
|
|
198
|
+
height: m,
|
|
199
|
+
viewBox: ie,
|
|
200
|
+
onWheel: de,
|
|
201
|
+
style: {
|
|
202
|
+
fontFamily: me ?? "sans-serif",
|
|
203
|
+
overflow: C && k > 1 ? "hidden" : "visible"
|
|
204
|
+
},
|
|
205
|
+
role: "img",
|
|
206
|
+
"aria-label": s.name,
|
|
207
|
+
children: /* @__PURE__ */ u("g", {
|
|
208
|
+
ref: E,
|
|
209
|
+
children: [
|
|
210
|
+
M > 0 && /* @__PURE__ */ l(o, {
|
|
211
|
+
...Q,
|
|
212
|
+
title: L.data.name,
|
|
213
|
+
placement: "top",
|
|
214
|
+
children: /* @__PURE__ */ l("circle", {
|
|
215
|
+
cx: 0,
|
|
216
|
+
cy: 0,
|
|
217
|
+
r: M,
|
|
218
|
+
fill: "transparent",
|
|
219
|
+
pointerEvents: w ? "none" : "auto",
|
|
220
|
+
onClick: Z,
|
|
221
|
+
style: { cursor: w ? "not-allowed" : "pointer" }
|
|
222
|
+
})
|
|
223
|
+
}),
|
|
224
|
+
/* @__PURE__ */ l("g", { children: X.map((e, t) => {
|
|
225
|
+
let n = U(e), r = W(n), i = !!e.children;
|
|
226
|
+
return /* @__PURE__ */ l(o, {
|
|
227
|
+
...Q,
|
|
228
|
+
placement: "top",
|
|
229
|
+
title: r ? /* @__PURE__ */ l(te, {
|
|
230
|
+
node: e,
|
|
231
|
+
valueDecimalCount: ne,
|
|
232
|
+
valueDecimalSep: re,
|
|
233
|
+
valueThousandsSep: S
|
|
234
|
+
}) : "",
|
|
235
|
+
children: /* @__PURE__ */ l("path", {
|
|
236
|
+
"data-idx": t,
|
|
237
|
+
d: H(n) || "",
|
|
238
|
+
fill: V(e),
|
|
239
|
+
fillOpacity: r ? i ? .75 : .5 : 0,
|
|
240
|
+
style: {
|
|
241
|
+
pointerEvents: r && !w ? "auto" : "none",
|
|
242
|
+
cursor: i && !w ? "pointer" : "default",
|
|
243
|
+
transition: "fill-opacity 0.15s"
|
|
244
|
+
},
|
|
245
|
+
onClick: fe,
|
|
246
|
+
onDoubleClick: pe
|
|
247
|
+
})
|
|
248
|
+
}, `tt-${e.data.id}-${t}`);
|
|
249
|
+
}) }),
|
|
250
|
+
h && /* @__PURE__ */ l("g", {
|
|
251
|
+
pointerEvents: "none",
|
|
252
|
+
textAnchor: "middle",
|
|
253
|
+
fill: $,
|
|
254
|
+
children: X.map((e, t) => {
|
|
255
|
+
if (!le(e)) return null;
|
|
256
|
+
let n = U(e);
|
|
257
|
+
if (!G(n)) return null;
|
|
258
|
+
let r = (M + (n.y0 + n.y1) / 2) * (n.x1 - n.x0) * .88, i = ee(e.data.name, r);
|
|
259
|
+
return i ? /* @__PURE__ */ l("text", {
|
|
260
|
+
transform: ce(n),
|
|
261
|
+
dy: "0.35em",
|
|
262
|
+
fontSize: p,
|
|
263
|
+
children: i
|
|
264
|
+
}, `lbl-${e.data.id}-${t}`) : null;
|
|
265
|
+
})
|
|
266
|
+
}),
|
|
267
|
+
y && /* @__PURE__ */ l(o, {
|
|
268
|
+
...Q,
|
|
269
|
+
placement: "top",
|
|
270
|
+
title: "",
|
|
271
|
+
children: /* @__PURE__ */ l("g", {
|
|
272
|
+
textAnchor: "middle",
|
|
273
|
+
fill: $,
|
|
274
|
+
pointerEvents: w ? "none" : "auto",
|
|
275
|
+
onClick: Z,
|
|
276
|
+
style: { cursor: L !== F && !w ? "pointer" : "default" },
|
|
277
|
+
children: /* @__PURE__ */ l("text", {
|
|
278
|
+
fontSize: 13,
|
|
279
|
+
dy: "0.35em",
|
|
280
|
+
fontWeight: "bold",
|
|
281
|
+
children: L.data.name
|
|
282
|
+
})
|
|
283
|
+
})
|
|
284
|
+
})
|
|
285
|
+
]
|
|
286
|
+
})
|
|
287
|
+
})
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
_.displayName = "SunburstChart";
|
|
291
|
+
//#endregion
|
|
292
|
+
export { _ as SunburstChart };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { createTagSelectionStore as e } from "./TagSelection.store.js";
|
|
2
|
+
import { TagSelectionAutocomplete as t } from "./TagSelectionAutocomplete.js";
|
|
3
|
+
import { TagSelectionSelectedTags as n } from "./TagSelectionSelectedTags.js";
|
|
4
|
+
import { DEFAULT_TAG_SELECTION_TRANSLATION as r } from "./TagSelection.types.js";
|
|
5
|
+
import { createContext as i, useContext as a, useEffect as o, useMemo as s, useState as c } from "react";
|
|
6
|
+
import { Box as l, Stack as u } from "@mui/material";
|
|
7
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
|
+
import { useStore as p } from "zustand";
|
|
9
|
+
//#region src/components/tag-selection/TagSelection.tsx
|
|
10
|
+
var m = i(null);
|
|
11
|
+
function h(e) {
|
|
12
|
+
let t = a(m);
|
|
13
|
+
if (!t) throw Error("TagSelectionStoreContext is missing.");
|
|
14
|
+
return p(t, e);
|
|
15
|
+
}
|
|
16
|
+
function g({ tags: e, showSelectedTags: r = !0, showSelectedTagsLabel: i = !0, showAutoComplete: a = !0, inputSize: c = "medium", chipSize: p = "small", disabled: m = !1, loading: g = !1, maxTags: _, allowCreate: v = !1, maxVisibleChips: y, popoverPlacement: b = "bottom", listboxMaxHeight: x, translation: S, onTagSelect: C, onTagDelete: w, onTagsChange: T, onSearchChange: E, onTagCreate: D }) {
|
|
17
|
+
let O = h((e) => e.tags), k = h((e) => e.searchValue), A = h((e) => e.setTags), j = h((e) => e.setSearchValue), M = h((e) => e.selectTag), N = h((e) => e.deleteTag), P = h((e) => e.addTag);
|
|
18
|
+
o(() => {
|
|
19
|
+
A(e);
|
|
20
|
+
}, [e, A]);
|
|
21
|
+
let F = s(() => O.filter((e) => e.selected).sort((e, t) => e.label.localeCompare(t.label)), [O]), I = s(() => O.filter((e) => !e.selected && !e.disabled).sort((e, t) => e.label.localeCompare(t.label)), [O]), L = _ !== void 0 && F.length >= _, R = (e) => {
|
|
22
|
+
T && T(e.filter((e) => e.selected), e);
|
|
23
|
+
};
|
|
24
|
+
return /* @__PURE__ */ d(l, {
|
|
25
|
+
sx: { width: "100%" },
|
|
26
|
+
children: /* @__PURE__ */ f(u, { children: [r && /* @__PURE__ */ d(n, {
|
|
27
|
+
selectedTags: F,
|
|
28
|
+
translation: S,
|
|
29
|
+
onTagDelete: (e) => {
|
|
30
|
+
N(e.id);
|
|
31
|
+
let t = O.map((t) => t.id === e.id ? {
|
|
32
|
+
...t,
|
|
33
|
+
selected: !1
|
|
34
|
+
} : t), n = t.filter((e) => e.selected), r = t.find((t) => t.id === e.id);
|
|
35
|
+
r && w && w(r, n, t), R(t);
|
|
36
|
+
},
|
|
37
|
+
showSelectedTagsLabel: i,
|
|
38
|
+
chipSize: p,
|
|
39
|
+
disabled: m,
|
|
40
|
+
maxVisibleChips: y,
|
|
41
|
+
popoverPlacement: b
|
|
42
|
+
}), a && /* @__PURE__ */ d(t, {
|
|
43
|
+
availableTags: I,
|
|
44
|
+
searchValue: k,
|
|
45
|
+
translation: S,
|
|
46
|
+
onSearchChange: (e) => {
|
|
47
|
+
j(e), E && E(e);
|
|
48
|
+
},
|
|
49
|
+
onTagSelect: (e) => {
|
|
50
|
+
if (e.disabled || e.selected) return;
|
|
51
|
+
M(e.id);
|
|
52
|
+
let t = O.map((t) => t.id === e.id ? {
|
|
53
|
+
...t,
|
|
54
|
+
selected: !0
|
|
55
|
+
} : t), n = t.filter((e) => e.selected), r = t.find((t) => t.id === e.id);
|
|
56
|
+
r && C && C(r, n, t), R(t);
|
|
57
|
+
},
|
|
58
|
+
onTagCreate: (e) => {
|
|
59
|
+
P(e), R([...O, e]), D && D(e);
|
|
60
|
+
},
|
|
61
|
+
inputSize: c,
|
|
62
|
+
chipSize: p,
|
|
63
|
+
disabled: m,
|
|
64
|
+
loading: g,
|
|
65
|
+
isMaxReached: L,
|
|
66
|
+
allowCreate: v,
|
|
67
|
+
listboxMaxHeight: x
|
|
68
|
+
})] })
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function _({ tags: t, showSelectedTags: n = !0, showSelectedTagsLabel: i = !0, showAutoComplete: a = !0, translation: o, inputSize: s = "medium", chipSize: l = "small", disabled: u = !1, loading: f = !1, maxTags: p, allowCreate: h = !1, maxVisibleChips: _, popoverPlacement: v = "bottom", listboxMaxHeight: y, onTagSelect: b, onTagDelete: x, onTagsChange: S, onSearchChange: C, onTagCreate: w }) {
|
|
72
|
+
let T = {
|
|
73
|
+
...r,
|
|
74
|
+
...o
|
|
75
|
+
}, [E] = c(() => e(t));
|
|
76
|
+
return /* @__PURE__ */ d(m.Provider, {
|
|
77
|
+
value: E,
|
|
78
|
+
children: /* @__PURE__ */ d(g, {
|
|
79
|
+
tags: t,
|
|
80
|
+
showSelectedTags: n,
|
|
81
|
+
showSelectedTagsLabel: i,
|
|
82
|
+
showAutoComplete: a,
|
|
83
|
+
translation: T,
|
|
84
|
+
inputSize: s,
|
|
85
|
+
chipSize: l,
|
|
86
|
+
disabled: u,
|
|
87
|
+
loading: f,
|
|
88
|
+
maxTags: p,
|
|
89
|
+
allowCreate: h,
|
|
90
|
+
maxVisibleChips: _,
|
|
91
|
+
popoverPlacement: v,
|
|
92
|
+
listboxMaxHeight: y,
|
|
93
|
+
onTagSelect: b,
|
|
94
|
+
onTagDelete: x,
|
|
95
|
+
onTagsChange: S,
|
|
96
|
+
onSearchChange: C,
|
|
97
|
+
onTagCreate: w
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { _ as TagSelection };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createStore as e } from "zustand/vanilla";
|
|
2
|
+
//#region src/components/tag-selection/TagSelection.store.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
return e((e) => ({
|
|
5
|
+
tags: t,
|
|
6
|
+
searchValue: "",
|
|
7
|
+
setTags: (t) => {
|
|
8
|
+
e({ tags: t });
|
|
9
|
+
},
|
|
10
|
+
setSearchValue: (t) => {
|
|
11
|
+
e({ searchValue: t });
|
|
12
|
+
},
|
|
13
|
+
selectTag: (t) => {
|
|
14
|
+
e((e) => ({
|
|
15
|
+
tags: e.tags.map((e) => e.id === t && !e.disabled ? {
|
|
16
|
+
...e,
|
|
17
|
+
selected: !0
|
|
18
|
+
} : e),
|
|
19
|
+
searchValue: ""
|
|
20
|
+
}));
|
|
21
|
+
},
|
|
22
|
+
deleteTag: (t) => {
|
|
23
|
+
e((e) => ({ tags: e.tags.map((e) => e.id === t ? {
|
|
24
|
+
...e,
|
|
25
|
+
selected: !1
|
|
26
|
+
} : e) }));
|
|
27
|
+
},
|
|
28
|
+
addTag: (t) => {
|
|
29
|
+
e((e) => ({
|
|
30
|
+
tags: [...e.tags, {
|
|
31
|
+
...t,
|
|
32
|
+
selected: !0
|
|
33
|
+
}],
|
|
34
|
+
searchValue: ""
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { t as createTagSelectionStore };
|
|
@@ -20,6 +20,8 @@ export type TagSelectionTranslation = {
|
|
|
20
20
|
backgroundColorLabel: string;
|
|
21
21
|
textColorLabel: string;
|
|
22
22
|
autoTextColorLabel: string;
|
|
23
|
+
confirmCreateLabel: string;
|
|
24
|
+
cancelCreateLabel: string;
|
|
23
25
|
};
|
|
24
26
|
export declare const DEFAULT_TAG_SELECTION_TRANSLATION: TagSelectionTranslation;
|
|
25
27
|
export type TagSelectionProps = {
|