@draftably/editor 0.0.0-stage → 0.1.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.md +26 -2
- package/dist/LICENSE +21 -0
- package/dist/assets/engine.worker-DmHew5f6.js +6813 -0
- package/dist/assets/import-d2.worker-CnXfFXoa.js +5395 -0
- package/dist/chunks/abnfDiagram-WEYOIA3C-llcpthp5.js +87 -0
- package/dist/chunks/arc-rJj0TtXf.js +83 -0
- package/dist/chunks/architectureDiagram-ZHVYKT53-CfiXg0Lk.js +4781 -0
- package/dist/chunks/blockDiagram-RJAE7QA3-CO-14jWz.js +1440 -0
- package/dist/chunks/browser-iNhbPsGc.js +40 -0
- package/dist/chunks/c4Diagram-XDPPPE54-DYKuxA4n.js +1524 -0
- package/dist/chunks/channel-qMvPU6eH.js +5 -0
- package/dist/chunks/chunk-2E7WHVMD-BEZwsFS3.js +670 -0
- package/dist/chunks/chunk-2Q5K7J3B-gqtzQ8ux.js +18 -0
- package/dist/chunks/chunk-4EMNKR2T-MC54CXVe.js +262 -0
- package/dist/chunks/chunk-55XCU76K-DkZUAaqC.js +68 -0
- package/dist/chunks/chunk-5VM5RSS4-CaKe4sjM.js +19 -0
- package/dist/chunks/chunk-JWPE2WC7-CnAFS2xF.js +8 -0
- package/dist/chunks/chunk-VQ5W62QI-CXRv7FiX.js +19 -0
- package/dist/chunks/chunk-XXDRQBXY-B-AMQgD2.js +8 -0
- package/dist/chunks/chunk-ZCHMQSOR-BALpdc3g.js +451 -0
- package/dist/chunks/classDiagram-v2-4MYWR3UA-wPjgJTg4.js +1570 -0
- package/dist/chunks/cose-bilkent-JH36ORCC-Bbh5ggBc.js +2608 -0
- package/dist/chunks/cynefin-EF2NZ3EQ-Bt6b88hY.js +22361 -0
- package/dist/chunks/cynefinDiagram-WF24UDRP-BHWZvxoF.js +299 -0
- package/dist/chunks/cytoscape.esm-CRsF_JA3.js +18791 -0
- package/dist/chunks/dagre-NK4GIZVX-Cz37yPrT.js +2157 -0
- package/dist/chunks/defaultLocale-BgPVtth8.js +171 -0
- package/dist/chunks/diagram-CBK3MWTC-Q2R6FJ0B.js +531 -0
- package/dist/chunks/diagram-I5XIIV2D-a2Kdu_wA.js +153 -0
- package/dist/chunks/diagram-ODIL2UCW-DTWXxcOn.js +346 -0
- package/dist/chunks/diagram-PFBEJUXE-DIAQQ5KX.js +480 -0
- package/dist/chunks/diagram-RJA3I4VV-BPD0GghS.js +219 -0
- package/dist/chunks/diagram-TYUNFSNR-BmdkONfG.js +2586 -0
- package/dist/chunks/dot-importer-B23jwEkx.js +1547 -0
- package/dist/chunks/ebnfDiagram-V4P3TTPT-C5IKvYlb.js +109 -0
- package/dist/chunks/elk-QONTBCTQ-CtdQFvh2.js +49229 -0
- package/dist/chunks/erDiagram-KYQIGQAA-5wguK9Dx.js +1064 -0
- package/dist/chunks/flowDiagram-IUGLLWBU-BijvFPku.js +1771 -0
- package/dist/chunks/ganttDiagram-R7GPNTJY-BaqGPz-O.js +2729 -0
- package/dist/chunks/gitGraphDiagram-PDYL7XHY-DZfMGyHE.js +815 -0
- package/dist/chunks/graph-CKJmgLki.js +1541 -0
- package/dist/chunks/import-core-C-I1wGfw.js +145 -0
- package/dist/chunks/infoDiagram-MVDRKAX5-C2vH_59e.js +24 -0
- package/dist/chunks/init-DjUOC4st.js +16 -0
- package/dist/chunks/ishikawaDiagram-HPEHV2GE-q149MFlV.js +624 -0
- package/dist/chunks/journeyDiagram-BOSHW7O7-D-2Z3VtR.js +834 -0
- package/dist/chunks/kanban-definition-FNSA4HC5-wvAjV5ub.js +724 -0
- package/dist/chunks/katex-BsrBVQKd.js +11314 -0
- package/dist/chunks/linear-4t7D_ros.js +259 -0
- package/dist/chunks/mermaid-facade-BoLWBerE.js +289 -0
- package/dist/chunks/mermaid-importer-Cgx1IhmR.js +478 -0
- package/dist/chunks/mermaid.core-DXv6D2Sm.js +19244 -0
- package/dist/chunks/mindmap-definition-6OY57UG3-r9wTKul_.js +837 -0
- package/dist/chunks/mount-C1Xk_GQz.js +22131 -0
- package/dist/chunks/ordinal-DfAQgscy.js +61 -0
- package/dist/chunks/pegDiagram-ECIUJNBX-CmKlFWiP.js +95 -0
- package/dist/chunks/pieDiagram-GNMPY74T-DNTw_qan.js +208 -0
- package/dist/chunks/quadrantDiagram-D57K4MC3-CT_tvVub.js +1029 -0
- package/dist/chunks/railroadDiagram-Y72NRBL7-C5TUvZBe.js +77 -0
- package/dist/chunks/requirementDiagram-EQYSW5RA-C_c65aCa.js +889 -0
- package/dist/chunks/sankeyDiagram-SY24JHO5-CKcbizM1.js +859 -0
- package/dist/chunks/sequenceDiagram-BLEHNHQU-GpVnHOjf.js +2972 -0
- package/dist/chunks/sizeCapture-INFHLROL-CToN3JSu.js +46 -0
- package/dist/chunks/stateDiagram-v2-A6IESKWZ-rJYd2FfM.js +1520 -0
- package/dist/chunks/swimlanes-B3ENRKFQ-C7w5pfxG.js +4991 -0
- package/dist/chunks/swimlanesDiagram-AYQRV4AK-BpGY_bvE.js +13 -0
- package/dist/chunks/timeline-definition-JXYKGLGB-ChKFPBKc.js +1058 -0
- package/dist/chunks/usecaseDiagram-WPOLBNNX-skXH8Dcu.js +7945 -0
- package/dist/chunks/vennDiagram-Q3Y3IDCW-C5KknmJf.js +1578 -0
- package/dist/chunks/wardleyDiagram-IVAIDKWA-DY4Lkfpu.js +678 -0
- package/dist/chunks/xychartDiagram-4URNHDU4-BHScsL7h.js +1536 -0
- package/dist/element.js +36 -0
- package/dist/index.js +4 -0
- package/dist/types/src/cli/links.d.ts +4 -0
- package/dist/types/src/cli/pdf.d.ts +29 -0
- package/dist/types/src/cli/png.d.ts +23 -0
- package/dist/types/src/cli/svg.d.ts +4 -0
- package/dist/types/src/components/Icon.d.ts +14 -0
- package/dist/types/src/components/LayoutPreviewBar.d.ts +2 -0
- package/dist/types/src/components/canvas/Canvas.d.ts +15 -0
- package/dist/types/src/components/canvas/Frame.d.ts +22 -0
- package/dist/types/src/components/canvas/InlineEditor.d.ts +2 -0
- package/dist/types/src/components/canvas/Notes.d.ts +5 -0
- package/dist/types/src/components/canvas/Overlay.d.ts +2 -0
- package/dist/types/src/components/canvas/StateBar.d.ts +5 -0
- package/dist/types/src/components/canvas/TextHits.d.ts +6 -0
- package/dist/types/src/components/canvas/ZoomControls.d.ts +1 -0
- package/dist/types/src/components/canvas/text-boxes.d.ts +24 -0
- package/dist/types/src/components/controls.d.ts +88 -0
- package/dist/types/src/components/scene/EdgeView.d.ts +22 -0
- package/dist/types/src/components/scene/GroupView.d.ts +22 -0
- package/dist/types/src/components/scene/Lifelines.d.ts +15 -0
- package/dist/types/src/components/scene/LinkMark.d.ts +11 -0
- package/dist/types/src/components/scene/NodeView.d.ts +18 -0
- package/dist/types/src/components/scene/parts.d.ts +50 -0
- package/dist/types/src/components/sculpt/BrushDock.d.ts +2 -0
- package/dist/types/src/components/sculpt/TimelineDeck.d.ts +2 -0
- package/dist/types/src/components/session-context.d.ts +486 -0
- package/dist/types/src/dsl/cells.d.ts +91 -0
- package/dist/types/src/dsl/channels.d.ts +53 -0
- package/dist/types/src/dsl/compile.d.ts +162 -0
- package/dist/types/src/dsl/frame.d.ts +38 -0
- package/dist/types/src/dsl/lanes.d.ts +23 -0
- package/dist/types/src/dsl/layout-edits.d.ts +58 -0
- package/dist/types/src/dsl/legend-notes.d.ts +3 -0
- package/dist/types/src/dsl/project.d.ts +39 -0
- package/dist/types/src/dsl/source-edits.d.ts +37 -0
- package/dist/types/src/dsl/syntax.d.ts +317 -0
- package/dist/types/src/dsl/translate.d.ts +69 -0
- package/dist/types/src/editor/Editor.d.ts +6 -0
- package/dist/types/src/editor/element.d.ts +15 -0
- package/dist/types/src/editor/mount.d.ts +23 -0
- package/dist/types/src/import/browser.d.ts +3 -0
- package/dist/types/src/import/detect.d.ts +31 -0
- package/dist/types/src/import/dot-importer.d.ts +3 -0
- package/dist/types/src/import/import-core.d.ts +105 -0
- package/dist/types/src/import/mermaid-facade.d.ts +120 -0
- package/dist/types/src/import/mermaid-importer.d.ts +4 -0
- package/dist/types/src/import/mermaid-sequence.d.ts +8 -0
- package/dist/types/src/import/scratch.d.ts +3 -0
- package/dist/types/src/lib/engine-tasks.d.ts +88 -0
- package/dist/types/src/lib/font-data.d.ts +9 -0
- package/dist/types/src/lib/saved-diagram.d.ts +4 -0
- package/dist/types/src/lib/scene-cache.d.ts +4 -0
- package/dist/types/src/lib/source-hash.d.ts +7 -0
- package/dist/types/src/lib/svg-export.d.ts +15 -0
- package/dist/types/src/model/appearance.d.ts +209 -0
- package/dist/types/src/model/bounds.d.ts +19 -0
- package/dist/types/src/model/camera.d.ts +21 -0
- package/dist/types/src/model/candidates.d.ts +53 -0
- package/dist/types/src/model/colors.d.ts +22 -0
- package/dist/types/src/model/document.d.ts +24 -0
- package/dist/types/src/model/edits.d.ts +133 -0
- package/dist/types/src/model/embed.d.ts +17 -0
- package/dist/types/src/model/examples.d.ts +15 -0
- package/dist/types/src/model/font-faces.d.ts +24 -0
- package/dist/types/src/model/fonts.d.ts +47 -0
- package/dist/types/src/model/footnote.d.ts +34 -0
- package/dist/types/src/model/frame.d.ts +71 -0
- package/dist/types/src/model/geometry.d.ts +29 -0
- package/dist/types/src/model/graph.d.ts +53 -0
- package/dist/types/src/model/heading.d.ts +38 -0
- package/dist/types/src/model/icons.d.ts +2 -0
- package/dist/types/src/model/label-hits.d.ts +27 -0
- package/dist/types/src/model/labels.d.ts +88 -0
- package/dist/types/src/model/legend.d.ts +25 -0
- package/dist/types/src/model/link.d.ts +63 -0
- package/dist/types/src/model/markers.d.ts +47 -0
- package/dist/types/src/model/note.d.ts +75 -0
- package/dist/types/src/model/panels.d.ts +11 -0
- package/dist/types/src/model/rich-text.d.ts +24 -0
- package/dist/types/src/model/routes.d.ts +170 -0
- package/dist/types/src/model/samples.d.ts +11 -0
- package/dist/types/src/model/stack.d.ts +8 -0
- package/dist/types/src/model/static-scene.d.ts +15 -0
- package/dist/types/src/model/status.d.ts +84 -0
- package/dist/types/src/model/styles.d.ts +13 -0
- package/dist/types/src/model/surface.d.ts +31 -0
- package/dist/types/src/model/types.d.ts +277 -0
- package/dist/types/src/runtime/svg-renderer.d.ts +38 -0
- package/dist/types/src/server/file-session.d.ts +19 -0
- package/dist/types/src/server/workspace.d.ts +21 -0
- package/dist/types/src/state/active-session.d.ts +479 -0
- package/dist/types/src/state/commands.d.ts +529 -0
- package/dist/types/src/state/comparison.d.ts +151 -0
- package/dist/types/src/state/files.d.ts +61 -0
- package/dist/types/src/state/keyboard.d.ts +6 -0
- package/dist/types/src/state/keys.d.ts +5 -0
- package/dist/types/src/state/launch.d.ts +61 -0
- package/dist/types/src/state/links.d.ts +11 -0
- package/dist/types/src/state/session/actions.d.ts +77 -0
- package/dist/types/src/state/session/canvas-text.d.ts +24 -0
- package/dist/types/src/state/session/document.d.ts +84 -0
- package/dist/types/src/state/session/editor.d.ts +81 -0
- package/dist/types/src/state/session/emphasis.d.ts +11 -0
- package/dist/types/src/state/session/file-session.d.ts +98 -0
- package/dist/types/src/state/session/index.d.ts +496 -0
- package/dist/types/src/state/session/layout.d.ts +79 -0
- package/dist/types/src/state/session/pointer.d.ts +19 -0
- package/dist/types/src/state/session/routing.d.ts +20 -0
- package/dist/types/src/state/session/scene.d.ts +144 -0
- package/dist/types/src/state/session/sculpt.d.ts +70 -0
- package/dist/types/src/state/toast.d.ts +14 -0
- package/dist/types/src/state/ui.d.ts +39 -0
- package/package.json +41 -3
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { i as a } from "./init-DjUOC4st.js";
|
|
2
|
+
class o extends Map {
|
|
3
|
+
constructor(n, t = g) {
|
|
4
|
+
if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: t } }), n != null) for (const [r, s] of n) this.set(r, s);
|
|
5
|
+
}
|
|
6
|
+
get(n) {
|
|
7
|
+
return super.get(c(this, n));
|
|
8
|
+
}
|
|
9
|
+
has(n) {
|
|
10
|
+
return super.has(c(this, n));
|
|
11
|
+
}
|
|
12
|
+
set(n, t) {
|
|
13
|
+
return super.set(l(this, n), t);
|
|
14
|
+
}
|
|
15
|
+
delete(n) {
|
|
16
|
+
return super.delete(p(this, n));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function c({ _intern: e, _key: n }, t) {
|
|
20
|
+
const r = n(t);
|
|
21
|
+
return e.has(r) ? e.get(r) : t;
|
|
22
|
+
}
|
|
23
|
+
function l({ _intern: e, _key: n }, t) {
|
|
24
|
+
const r = n(t);
|
|
25
|
+
return e.has(r) ? e.get(r) : (e.set(r, t), t);
|
|
26
|
+
}
|
|
27
|
+
function p({ _intern: e, _key: n }, t) {
|
|
28
|
+
const r = n(t);
|
|
29
|
+
return e.has(r) && (t = e.get(r), e.delete(r)), t;
|
|
30
|
+
}
|
|
31
|
+
function g(e) {
|
|
32
|
+
return e !== null && typeof e == "object" ? e.valueOf() : e;
|
|
33
|
+
}
|
|
34
|
+
const f = Symbol("implicit");
|
|
35
|
+
function h() {
|
|
36
|
+
var e = new o(), n = [], t = [], r = f;
|
|
37
|
+
function s(u) {
|
|
38
|
+
let i = e.get(u);
|
|
39
|
+
if (i === void 0) {
|
|
40
|
+
if (r !== f) return r;
|
|
41
|
+
e.set(u, i = n.push(u) - 1);
|
|
42
|
+
}
|
|
43
|
+
return t[i % t.length];
|
|
44
|
+
}
|
|
45
|
+
return s.domain = function(u) {
|
|
46
|
+
if (!arguments.length) return n.slice();
|
|
47
|
+
n = [], e = new o();
|
|
48
|
+
for (const i of u)
|
|
49
|
+
e.has(i) || e.set(i, n.push(i) - 1);
|
|
50
|
+
return s;
|
|
51
|
+
}, s.range = function(u) {
|
|
52
|
+
return arguments.length ? (t = Array.from(u), s) : t.slice();
|
|
53
|
+
}, s.unknown = function(u) {
|
|
54
|
+
return arguments.length ? (r = u, s) : r;
|
|
55
|
+
}, s.copy = function() {
|
|
56
|
+
return h(n, t).unknown(r);
|
|
57
|
+
}, a.apply(s, arguments), s;
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
h as o
|
|
61
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { g as l, r as m, d as a } from "./chunk-2E7WHVMD-BEZwsFS3.js";
|
|
2
|
+
import { p } from "./chunk-JWPE2WC7-CnAFS2xF.js";
|
|
3
|
+
import { _ as t, l as o } from "./mermaid.core-DXv6D2Sm.js";
|
|
4
|
+
import { M as u, d as c } from "./cynefin-EF2NZ3EQ-Bt6b88hY.js";
|
|
5
|
+
var f = c().RailroadPeg.parser.LangiumParser, i = /* @__PURE__ */ t((e) => {
|
|
6
|
+
const r = e.alternatives.map(d);
|
|
7
|
+
return r.length === 1 ? r[0] : {
|
|
8
|
+
type: "choice",
|
|
9
|
+
alternatives: r
|
|
10
|
+
};
|
|
11
|
+
}, "transformOrderedChoice"), d = /* @__PURE__ */ t((e) => {
|
|
12
|
+
const r = e.elements.map(P);
|
|
13
|
+
return r.length === 1 ? r[0] : {
|
|
14
|
+
type: "sequence",
|
|
15
|
+
elements: r
|
|
16
|
+
};
|
|
17
|
+
}, "transformSequence"), P = /* @__PURE__ */ t((e) => {
|
|
18
|
+
const r = g(e.suffix);
|
|
19
|
+
return e.operator ? {
|
|
20
|
+
type: "special",
|
|
21
|
+
text: e.operator === "&" ? `&${s(r)}` : `!${s(r)}`
|
|
22
|
+
} : r;
|
|
23
|
+
}, "transformPrefix"), s = /* @__PURE__ */ t((e) => {
|
|
24
|
+
switch (e.type) {
|
|
25
|
+
case "terminal":
|
|
26
|
+
return `"${e.value}"`;
|
|
27
|
+
case "nonterminal":
|
|
28
|
+
return e.name;
|
|
29
|
+
case "special":
|
|
30
|
+
return e.text;
|
|
31
|
+
default:
|
|
32
|
+
return "(...)";
|
|
33
|
+
}
|
|
34
|
+
}, "nodeToLabel"), g = /* @__PURE__ */ t((e) => {
|
|
35
|
+
const r = v(e.primary);
|
|
36
|
+
if (!e.operator)
|
|
37
|
+
return r;
|
|
38
|
+
switch (e.operator) {
|
|
39
|
+
case "?":
|
|
40
|
+
return { type: "optional", element: r };
|
|
41
|
+
case "*":
|
|
42
|
+
return { type: "repetition", element: r, min: 0, max: 1 / 0 };
|
|
43
|
+
case "+":
|
|
44
|
+
return { type: "repetition", element: r, min: 1, max: 1 / 0 };
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(`Unsupported PEG suffix operator: ${e.operator}`);
|
|
47
|
+
}
|
|
48
|
+
}, "transformSuffix"), v = /* @__PURE__ */ t((e) => {
|
|
49
|
+
switch (e.$type) {
|
|
50
|
+
case "PegLiteral":
|
|
51
|
+
return {
|
|
52
|
+
type: "terminal",
|
|
53
|
+
value: e.value
|
|
54
|
+
};
|
|
55
|
+
case "PegIdentifier":
|
|
56
|
+
return {
|
|
57
|
+
type: "nonterminal",
|
|
58
|
+
name: e.name
|
|
59
|
+
};
|
|
60
|
+
case "PegGroup":
|
|
61
|
+
return i(e.element);
|
|
62
|
+
case "PegAny":
|
|
63
|
+
return {
|
|
64
|
+
type: "special",
|
|
65
|
+
text: e.dot
|
|
66
|
+
};
|
|
67
|
+
default:
|
|
68
|
+
throw new Error(`Unsupported PEG primary node: ${e.$type}`);
|
|
69
|
+
}
|
|
70
|
+
}, "transformPrimary"), y = /* @__PURE__ */ t((e) => ({
|
|
71
|
+
name: e.name,
|
|
72
|
+
definition: i(e.definition)
|
|
73
|
+
}), "transformRule"), h = /* @__PURE__ */ t((e) => {
|
|
74
|
+
p(e, a), e.title && a.setTitle(e.title), e.rules.map((r) => a.addRule(y(r)));
|
|
75
|
+
}, "populateDb"), b = {
|
|
76
|
+
parse: /* @__PURE__ */ t((e) => {
|
|
77
|
+
a.clear(), o.debug("[PEG Parser] Starting Langium parse");
|
|
78
|
+
const r = f.parse(e);
|
|
79
|
+
if (r.lexerErrors.length > 0 || r.parserErrors.length > 0)
|
|
80
|
+
throw new u(r);
|
|
81
|
+
const n = r.value;
|
|
82
|
+
o.debug("[PEG Parser] Parsed rules:", n.rules.length), h(n), o.debug("[PEG Parser] Parse complete");
|
|
83
|
+
}, "parse"),
|
|
84
|
+
parser: {
|
|
85
|
+
yy: a
|
|
86
|
+
}
|
|
87
|
+
}, $ = {
|
|
88
|
+
parser: b,
|
|
89
|
+
db: a,
|
|
90
|
+
renderer: m,
|
|
91
|
+
styles: l
|
|
92
|
+
};
|
|
93
|
+
export {
|
|
94
|
+
$ as diagram
|
|
95
|
+
};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { p as at } from "./chunk-JWPE2WC7-CnAFS2xF.js";
|
|
2
|
+
import { aa as T, ad as G, bc as rt, g as nt, s as it, a as ot, b as st, t as lt, q as ct, _ as g, l as B, c as dt, N as ut, Q as gt, V as pt, d as ht, A as ft, O as mt } from "./mermaid.core-DXv6D2Sm.js";
|
|
3
|
+
import { p as vt } from "./cynefin-EF2NZ3EQ-Bt6b88hY.js";
|
|
4
|
+
import { d as X } from "./arc-rJj0TtXf.js";
|
|
5
|
+
import { o as xt } from "./ordinal-DfAQgscy.js";
|
|
6
|
+
function St(t, n) {
|
|
7
|
+
return n < t ? -1 : n > t ? 1 : n >= t ? 0 : NaN;
|
|
8
|
+
}
|
|
9
|
+
function yt(t) {
|
|
10
|
+
return t;
|
|
11
|
+
}
|
|
12
|
+
function wt() {
|
|
13
|
+
var t = yt, n = St, y = null, b = T(0), l = T(G), p = T(0);
|
|
14
|
+
function i(e) {
|
|
15
|
+
var r, s = (e = rt(e)).length, h, w, $ = 0, f = new Array(s), o = new Array(s), D = +b.apply(this, arguments), E = Math.min(G, Math.max(-G, l.apply(this, arguments) - D)), k, L = Math.min(Math.abs(E) / s, p.apply(this, arguments)), d = L * (E < 0 ? -1 : 1), A;
|
|
16
|
+
for (r = 0; r < s; ++r)
|
|
17
|
+
(A = o[f[r] = r] = +t(e[r], r, e)) > 0 && ($ += A);
|
|
18
|
+
for (n != null ? f.sort(function(M, m) {
|
|
19
|
+
return n(o[M], o[m]);
|
|
20
|
+
}) : y != null && f.sort(function(M, m) {
|
|
21
|
+
return y(e[M], e[m]);
|
|
22
|
+
}), r = 0, w = $ ? (E - s * d) / $ : 0; r < s; ++r, D = k)
|
|
23
|
+
h = f[r], A = o[h], k = D + (A > 0 ? A * w : 0) + d, o[h] = {
|
|
24
|
+
data: e[h],
|
|
25
|
+
index: r,
|
|
26
|
+
value: A,
|
|
27
|
+
startAngle: D,
|
|
28
|
+
endAngle: k,
|
|
29
|
+
padAngle: L
|
|
30
|
+
};
|
|
31
|
+
return o;
|
|
32
|
+
}
|
|
33
|
+
return i.value = function(e) {
|
|
34
|
+
return arguments.length ? (t = typeof e == "function" ? e : T(+e), i) : t;
|
|
35
|
+
}, i.sortValues = function(e) {
|
|
36
|
+
return arguments.length ? (n = e, y = null, i) : n;
|
|
37
|
+
}, i.sort = function(e) {
|
|
38
|
+
return arguments.length ? (y = e, n = null, i) : y;
|
|
39
|
+
}, i.startAngle = function(e) {
|
|
40
|
+
return arguments.length ? (b = typeof e == "function" ? e : T(+e), i) : b;
|
|
41
|
+
}, i.endAngle = function(e) {
|
|
42
|
+
return arguments.length ? (l = typeof e == "function" ? e : T(+e), i) : l;
|
|
43
|
+
}, i.padAngle = function(e) {
|
|
44
|
+
return arguments.length ? (p = typeof e == "function" ? e : T(+e), i) : p;
|
|
45
|
+
}, i;
|
|
46
|
+
}
|
|
47
|
+
var At = mt.pie, I = {
|
|
48
|
+
sections: /* @__PURE__ */ new Map(),
|
|
49
|
+
showData: !1
|
|
50
|
+
}, W = I.sections, V = I.showData, Ct = structuredClone(At), $t = /* @__PURE__ */ g(() => structuredClone(Ct), "getConfig"), Dt = /* @__PURE__ */ g(() => {
|
|
51
|
+
W = /* @__PURE__ */ new Map(), V = I.showData, ft();
|
|
52
|
+
}, "clear"), Tt = /* @__PURE__ */ g(({ label: t, value: n }) => {
|
|
53
|
+
if (n < 0)
|
|
54
|
+
throw new Error(
|
|
55
|
+
`"${t}" has invalid value: ${n}. Negative values are not allowed in pie charts. All slice values must be >= 0.`
|
|
56
|
+
);
|
|
57
|
+
W.has(t) || (W.set(t, n), B.debug(`added new section: ${t}, with value: ${n}`));
|
|
58
|
+
}, "addSection"), bt = /* @__PURE__ */ g(() => W, "getSections"), kt = /* @__PURE__ */ g((t) => {
|
|
59
|
+
V = t;
|
|
60
|
+
}, "setShowData"), zt = /* @__PURE__ */ g(() => V, "getShowData"), Z = {
|
|
61
|
+
getConfig: $t,
|
|
62
|
+
clear: Dt,
|
|
63
|
+
setDiagramTitle: ct,
|
|
64
|
+
getDiagramTitle: lt,
|
|
65
|
+
setAccTitle: st,
|
|
66
|
+
getAccTitle: ot,
|
|
67
|
+
setAccDescription: it,
|
|
68
|
+
getAccDescription: nt,
|
|
69
|
+
addSection: Tt,
|
|
70
|
+
getSections: bt,
|
|
71
|
+
setShowData: kt,
|
|
72
|
+
getShowData: zt
|
|
73
|
+
}, Et = /* @__PURE__ */ g((t, n) => {
|
|
74
|
+
at(t, n), n.setShowData(t.showData), t.sections.map(n.addSection);
|
|
75
|
+
}, "populateDb"), Mt = {
|
|
76
|
+
parse: /* @__PURE__ */ g(async (t) => {
|
|
77
|
+
const n = await vt("pie", t);
|
|
78
|
+
B.debug(n), Et(n, Z);
|
|
79
|
+
}, "parse")
|
|
80
|
+
}, Rt = /* @__PURE__ */ g((t) => `
|
|
81
|
+
.pieCircle{
|
|
82
|
+
stroke: ${t.pieStrokeColor};
|
|
83
|
+
stroke-width : ${t.pieStrokeWidth};
|
|
84
|
+
opacity : ${t.pieOpacity};
|
|
85
|
+
}
|
|
86
|
+
.pieCircle.highlighted{
|
|
87
|
+
scale: 1.05;
|
|
88
|
+
opacity: 1;
|
|
89
|
+
}
|
|
90
|
+
.pieCircle.highlightedOnHover:hover{
|
|
91
|
+
transition-duration: 250ms;
|
|
92
|
+
scale: 1.05;
|
|
93
|
+
opacity: 1;
|
|
94
|
+
}
|
|
95
|
+
.pieOuterCircle{
|
|
96
|
+
stroke: ${t.pieOuterStrokeColor};
|
|
97
|
+
stroke-width: ${t.pieOuterStrokeWidth};
|
|
98
|
+
fill: none;
|
|
99
|
+
}
|
|
100
|
+
.pieTitleText {
|
|
101
|
+
text-anchor: middle;
|
|
102
|
+
font-size: ${t.pieTitleTextSize};
|
|
103
|
+
fill: ${t.pieTitleTextColor};
|
|
104
|
+
font-family: ${t.fontFamily};
|
|
105
|
+
}
|
|
106
|
+
.slice {
|
|
107
|
+
font-family: ${t.fontFamily};
|
|
108
|
+
fill: ${t.pieSectionTextColor};
|
|
109
|
+
font-size:${t.pieSectionTextSize};
|
|
110
|
+
// fill: white;
|
|
111
|
+
}
|
|
112
|
+
.legend text {
|
|
113
|
+
fill: ${t.pieLegendTextColor};
|
|
114
|
+
font-family: ${t.fontFamily};
|
|
115
|
+
font-size: ${t.pieLegendTextSize};
|
|
116
|
+
}
|
|
117
|
+
`, "getStyles"), Lt = Rt, Nt = /* @__PURE__ */ g((t) => {
|
|
118
|
+
const n = [...t.values()].reduce((l, p) => l + p, 0), y = [...t.entries()].map(([l, p]) => ({ label: l, value: p })).filter((l) => l.value / n * 100 >= 1);
|
|
119
|
+
return wt().value((l) => l.value).sort(null)(y);
|
|
120
|
+
}, "createPieArcs"), Ot = /* @__PURE__ */ g((t, n, y, b) => {
|
|
121
|
+
B.debug(`rendering pie chart
|
|
122
|
+
` + t);
|
|
123
|
+
const l = b.db, p = dt(), i = ut(l.getConfig(), p.pie), e = 40, r = 18, s = 4, h = 450, w = h, $ = gt(n), f = $.append("g");
|
|
124
|
+
f.attr("transform", "translate(" + w / 2 + "," + h / 2 + ")");
|
|
125
|
+
const { themeVariables: o } = p;
|
|
126
|
+
let [D] = pt(o.pieOuterStrokeWidth);
|
|
127
|
+
D ??= 2;
|
|
128
|
+
const E = i.legendPosition, k = i.textPosition, L = i.donutHole > 0 && i.donutHole <= 0.9 ? i.donutHole : 0, d = Math.min(w, h) / 2 - e, A = X().innerRadius(L * d).outerRadius(d), M = X().innerRadius(d * k).outerRadius(d * k), m = f.append("g");
|
|
129
|
+
m.append("circle").attr("cx", 0).attr("cy", 0).attr("r", d + D / 2).attr("class", "pieOuterCircle");
|
|
130
|
+
const N = l.getSections(), J = Nt(N), K = [
|
|
131
|
+
o.pie1,
|
|
132
|
+
o.pie2,
|
|
133
|
+
o.pie3,
|
|
134
|
+
o.pie4,
|
|
135
|
+
o.pie5,
|
|
136
|
+
o.pie6,
|
|
137
|
+
o.pie7,
|
|
138
|
+
o.pie8,
|
|
139
|
+
o.pie9,
|
|
140
|
+
o.pie10,
|
|
141
|
+
o.pie11,
|
|
142
|
+
o.pie12
|
|
143
|
+
];
|
|
144
|
+
let _ = 0;
|
|
145
|
+
N.forEach((a) => {
|
|
146
|
+
_ += a;
|
|
147
|
+
});
|
|
148
|
+
const U = J.filter((a) => (a.data.value / _ * 100).toFixed(0) !== "0"), F = xt(K).domain([
|
|
149
|
+
...N.keys()
|
|
150
|
+
]);
|
|
151
|
+
m.selectAll("mySlices").data(U).enter().append("path").attr("d", A).attr("fill", (a) => F(a.data.label)).attr("class", (a) => {
|
|
152
|
+
let c = "pieCircle";
|
|
153
|
+
return i.highlightSlice === "hover" ? c += " highlightedOnHover" : i.highlightSlice === a.data.label && (c += " highlighted"), c;
|
|
154
|
+
}), m.selectAll("mySlices").data(U).enter().append("text").text((a) => (a.data.value / _ * 100).toFixed(0) + "%").attr("transform", (a) => "translate(" + M.centroid(a) + ")").style("text-anchor", "middle").attr("class", "slice");
|
|
155
|
+
const Y = f.append("text").text(l.getDiagramTitle()).attr("x", 0).attr("y", -400 / 2).attr("class", "pieTitleText"), R = [...N.entries()].map(([a, c]) => ({
|
|
156
|
+
label: a,
|
|
157
|
+
value: c
|
|
158
|
+
})), C = f.selectAll(".legend").data(R).enter().append("g").attr("class", "legend");
|
|
159
|
+
C.append("rect").attr("width", r).attr("height", r).style("fill", (a) => F(a.label)).style("stroke", (a) => F(a.label)), C.append("text").attr("x", r + s).attr("y", r - s).text((a) => l.getShowData() ? `${a.label} [${a.value}]` : a.label);
|
|
160
|
+
const z = Math.max(
|
|
161
|
+
...C.selectAll("text").nodes().map((a) => a?.getBoundingClientRect().width ?? 0)
|
|
162
|
+
);
|
|
163
|
+
let O = h, H = w + e;
|
|
164
|
+
const u = r + s, P = R.length * u;
|
|
165
|
+
switch (E) {
|
|
166
|
+
case "center":
|
|
167
|
+
C.attr("transform", (a, c) => {
|
|
168
|
+
const v = u * R.length / 2, x = -z / 2 - (r + s), S = c * u - v;
|
|
169
|
+
return "translate(" + x + "," + S + ")";
|
|
170
|
+
});
|
|
171
|
+
break;
|
|
172
|
+
case "top":
|
|
173
|
+
O += P, C.attr("transform", (a, c) => {
|
|
174
|
+
const v = d, x = -z / 2 - (r + s), S = c * u - v;
|
|
175
|
+
return `translate(${x}, ${S})`;
|
|
176
|
+
}), m.attr("transform", () => `translate(0, ${P + u})`);
|
|
177
|
+
break;
|
|
178
|
+
case "bottom":
|
|
179
|
+
O += P, C.attr("transform", (a, c) => {
|
|
180
|
+
const v = -d - u, x = -z / 2 - (r + s), S = c * u - v;
|
|
181
|
+
return "translate(" + x + "," + S + ")";
|
|
182
|
+
});
|
|
183
|
+
break;
|
|
184
|
+
case "left":
|
|
185
|
+
H += r + s + z, C.attr("transform", (a, c) => {
|
|
186
|
+
const v = u * R.length / 2, x = -d - (r + s), S = c * u - v;
|
|
187
|
+
return "translate(" + x + "," + S + ")";
|
|
188
|
+
}), m.attr("transform", () => `translate(${z + r + s}, 0)`);
|
|
189
|
+
break;
|
|
190
|
+
case "right":
|
|
191
|
+
default:
|
|
192
|
+
H += r + s + z, C.attr("transform", (a, c) => {
|
|
193
|
+
const v = u * R.length / 2, x = 12 * r, S = c * u - v;
|
|
194
|
+
return "translate(" + x + "," + S + ")";
|
|
195
|
+
});
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
const j = Y.node()?.getBoundingClientRect().width ?? 0, tt = w / 2 - j / 2, et = w / 2 + j / 2, q = Math.min(0, tt), Q = Math.max(H, et) - q;
|
|
199
|
+
$.attr("viewBox", `${q} 0 ${Q} ${O}`), ht($, O, Q, i.useMaxWidth);
|
|
200
|
+
}, "draw"), Wt = { draw: Ot }, It = {
|
|
201
|
+
parser: Mt,
|
|
202
|
+
db: Z,
|
|
203
|
+
renderer: Wt,
|
|
204
|
+
styles: Lt
|
|
205
|
+
};
|
|
206
|
+
export {
|
|
207
|
+
It as diagram
|
|
208
|
+
};
|