@ac-design/design-system 2.6.1 → 2.7.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 (50) hide show
  1. package/dist/lib/charts/ChartFrame.vue_vue_type_script_setup_true_lang.js +2 -2
  2. package/dist/lib/charts/graph.d.ts +9 -15
  3. package/dist/lib/charts/graph.js +79 -75
  4. package/dist/lib/charts/index.d.ts +4 -2
  5. package/dist/lib/charts/index.js +2 -1
  6. package/dist/lib/charts/nodeSymbol.d.ts +15 -0
  7. package/dist/lib/charts/nodeSymbol.js +27 -0
  8. package/dist/lib/charts/tree.d.ts +15 -0
  9. package/dist/lib/charts/tree.js +89 -0
  10. package/dist/lib/compat.css +113 -0
  11. package/dist/lib/components/AcAccordionItem.vue.d.ts +3 -1
  12. package/dist/lib/components/AcAccordionItem.vue_vue_type_script_setup_true_lang.js +35 -26
  13. package/dist/lib/components/AcAlert.vue.d.ts +1 -1
  14. package/dist/lib/components/AcBadge.vue.d.ts +1 -1
  15. package/dist/lib/components/AcBanner.vue.d.ts +1 -1
  16. package/dist/lib/components/AcCard.vue.d.ts +1 -1
  17. package/dist/lib/components/AcCellValue.vue.d.ts +1 -1
  18. package/dist/lib/components/AcCheckList.vue.d.ts +1 -1
  19. package/dist/lib/components/AcConfirmModal.vue.d.ts +1 -1
  20. package/dist/lib/components/AcDropdownItem.vue.d.ts +1 -1
  21. package/dist/lib/components/AcFeatureCard.vue.d.ts +1 -1
  22. package/dist/lib/components/AcGraphChart.vue.d.ts +53 -3
  23. package/dist/lib/components/AcGraphChart.vue_vue_type_script_setup_true_lang.js +401 -233
  24. package/dist/lib/components/AcList.js +5 -0
  25. package/dist/lib/components/AcList.vue.d.ts +56 -0
  26. package/dist/lib/components/AcList.vue_vue_type_script_setup_true_lang.js +74 -0
  27. package/dist/lib/components/AcListItem.js +5 -0
  28. package/dist/lib/components/AcListItem.vue.d.ts +53 -0
  29. package/dist/lib/components/AcListItem.vue_vue_type_script_setup_true_lang.js +105 -0
  30. package/dist/lib/components/AcMapChart.vue.d.ts +66 -3
  31. package/dist/lib/components/AcMapChart.vue_vue_type_script_setup_true_lang.js +403 -201
  32. package/dist/lib/components/AcMonthPicker.js +5 -0
  33. package/dist/lib/components/AcMonthPicker.vue.d.ts +102 -0
  34. package/dist/lib/components/AcMonthPicker.vue_vue_type_script_setup_true_lang.js +595 -0
  35. package/dist/lib/components/AcNavbarItem.vue.d.ts +1 -1
  36. package/dist/lib/components/AcResourceCard.vue.d.ts +1 -1
  37. package/dist/lib/components/AcSideTabs.vue.d.ts +3 -1
  38. package/dist/lib/components/AcSideTabs.vue_vue_type_script_setup_true_lang.js +53 -33
  39. package/dist/lib/components/AcSidebarItem.vue.d.ts +1 -1
  40. package/dist/lib/components/AcStatCard.vue.d.ts +1 -1
  41. package/dist/lib/components/AcTreeChart.js +5 -0
  42. package/dist/lib/components/AcTreeChart.vue.d.ts +135 -0
  43. package/dist/lib/components/AcTreeChart.vue_vue_type_script_setup_true_lang.js +809 -0
  44. package/dist/lib/components/AcUsageCard.vue.d.ts +1 -1
  45. package/dist/lib/components/index.d.ts +5 -2
  46. package/dist/lib/composables/copyText.d.ts +5 -1
  47. package/dist/lib/composables/copyText.js +15 -3
  48. package/dist/lib/index.d.ts +3 -0
  49. package/dist/lib/index.js +85 -81
  50. package/package.json +1 -1
@@ -131,7 +131,7 @@ var C = ["data-testid"], w = ["aria-pressed", "onClick"], T = { class: "truncate
131
131
  "aria-label": u.summary
132
132
  }, [y(e.$slots, "default")], 8, O)) : y(e.$slots, "default", {}, void 0, void 0, 1), y(e.$slots, "controls")], 14, D)),
133
133
  u.title || u.description ? (g(), s("figcaption", k, b([u.title, u.description].filter(Boolean).join(". ")), 1)) : o("", !0),
134
- !u.loading && !u.empty ? (g(), s("table", A, [
134
+ !u.loading && !u.empty ? (g(), s("div", A, [c("table", null, [
135
135
  c("caption", null, b(u.title ? `${u.title}: data` : "Chart data"), 1),
136
136
  c("thead", null, [c("tr", null, [(g(!0), s(r, null, v(u.table.columns, (e, t) => (g(), s("th", {
137
137
  key: t,
@@ -139,7 +139,7 @@ var C = ["data-testid"], w = ["aria-pressed", "onClick"], T = { class: "truncate
139
139
  class: "text-left"
140
140
  }, b(e), 1))), 128))])]),
141
141
  c("tbody", null, [(g(!0), s(r, null, v(u.table.rows, (e, t) => (g(), s("tr", { key: t }, [c("th", j, b(e[0]), 1), (g(!0), s(r, null, v(e.slice(1), (e, t) => (g(), s("td", { key: t }, b(e), 1))), 128))]))), 128))])
142
- ])) : o("", !0),
142
+ ])])) : o("", !0),
143
143
  (g(), a(i, { to: "body" }, [u.tooltip && u.tip && !u.loading && !u.empty ? (g(), s("div", {
144
144
  key: 0,
145
145
  class: "pointer-events-none fixed z-[100] w-max max-w-[280px] min-w-[160px] rounded-10 border border-border bg-surface px-3 py-2.5 text-xs text-body shadow-lg",
@@ -1,4 +1,4 @@
1
- import type { Component } from "vue";
1
+ export { nodeImage } from "./nodeSymbol";
2
2
  /** Node diameter in px at 100% zoom. */
3
3
  export declare const NODE_SIZE = 40;
4
4
  /** Gap between a node and its label. */
@@ -11,6 +11,7 @@ export declare const GROUP_TITLE = 20;
11
11
  export interface LayoutNode {
12
12
  id: string;
13
13
  label: string;
14
+ /** The second line under the name: the kind, or the node's `sublabel`. */
14
15
  kind: string;
15
16
  group?: string;
16
17
  badge: boolean;
@@ -22,6 +23,8 @@ export interface LayoutLink {
22
23
  }
23
24
  export interface GroupBox {
24
25
  name: string;
26
+ /** How many groups it sits inside: 0 for a top-level box. Inner boxes draw over outer ones. */
27
+ depth: number;
25
28
  /** Top-left corner and size, in layout px. */
26
29
  x: number;
27
30
  y: number;
@@ -51,8 +54,11 @@ export declare function labelDetail(scale: number): LabelDetail;
51
54
  export declare function truncate(text: string, max: number): string;
52
55
  export declare function nodeName(label: string): string;
53
56
  export declare function nodeKind(kind: string): string;
54
- /** Layered layout: ranks follow the links, and nodes of a group are kept together as a dagre cluster. */
55
- export declare function layoutGraph(nodes: LayoutNode[], links: LayoutLink[], direction: "LR" | "TB"): GraphLayout;
57
+ /**
58
+ * Layered layout: ranks follow the links, and nodes of a group are kept together as a dagre cluster.
59
+ * `parents` maps a group to the group it sits inside, so boxes can nest (a subnet inside its VPC).
60
+ */
61
+ export declare function layoutGraph(nodes: LayoutNode[], links: LayoutLink[], direction: "LR" | "TB", parents?: Map<string, string>): GraphLayout;
56
62
  /**
57
63
  * How far the drawing reaches past the node centres' box, in screen px at `scale`.
58
64
  * Nodes and group boxes scale; labels don't, so the answer isn't linear in `scale`.
@@ -63,15 +69,3 @@ export declare function overhang(layout: GraphLayout, scale: number, detail: Lab
63
69
  right: number;
64
70
  bottom: number;
65
71
  };
66
- export interface NodeImageOptions {
67
- icon: Component | string;
68
- /** Resolved colours (ECharts and SVG images can't read CSS variables). */
69
- iconColor: string;
70
- fill: string;
71
- ring: string;
72
- ringWidth: number;
73
- shape: "circle" | "square";
74
- font: string;
75
- }
76
- /** One node as an `image://` symbol: fill, ring and icon in a 40×40 view box, rasterised large enough to stay sharp at 150% on a 2× screen. */
77
- export declare function nodeImage(o: NodeImageOptions): string;
@@ -1,41 +1,57 @@
1
- import { h as e, render as t } from "vue";
2
- import n from "@dagrejs/dagre";
3
- var r = 20, i = 22, a = 24, o = 18, s = "\0group:", c = [
1
+ import { nodeImage as e } from "./nodeSymbol.js";
2
+ import t from "@dagrejs/dagre";
3
+ var n = 22, r = 24, i = 18, a = "\0group:", o = [
4
4
  "full",
5
5
  "name",
6
6
  "badge"
7
7
  ];
8
- function l(e) {
8
+ function s(e) {
9
9
  return e >= .6 ? "full" : e >= .4 ? "name" : "badge";
10
10
  }
11
- var u = {
11
+ var c = {
12
12
  full: 36,
13
13
  name: 22,
14
14
  badge: 22
15
15
  };
16
- function d(e, t) {
16
+ function l(e, t) {
17
17
  return e.length > t ? `${e.slice(0, t - 1)}…` : e;
18
18
  }
19
- function f(e) {
20
- return d(e, i);
19
+ function u(e) {
20
+ return l(e, n);
21
21
  }
22
- function p(e) {
23
- return d(e, a);
22
+ function d(e) {
23
+ return l(e, r);
24
24
  }
25
- function m(e) {
26
- let t = e.badge ? o : 0, n = f(e.label).length * 6.8 + t, r = p(e.kind).length * 6.2;
25
+ function f(e) {
26
+ let t = e.badge ? i : 0, n = u(e.label).length * 6.8 + t, r = d(e.kind).length * 6.2;
27
27
  return {
28
28
  full: Math.max(n, r) + 8,
29
29
  name: n + 8,
30
30
  badge: t
31
31
  };
32
32
  }
33
- function h(e, t, r) {
34
- let i = new n.graphlib.Graph({
33
+ function p(e, t, n) {
34
+ let r = a + t;
35
+ if (e.hasNode(r)) return r;
36
+ e.setNode(r, {
37
+ width: 0,
38
+ height: 0
39
+ });
40
+ let i = n.get(t);
41
+ if (i === void 0 || i === t) return r;
42
+ let o = p(e, i, n);
43
+ return m(e, r, o) || e.setParent(r, o), r;
44
+ }
45
+ function m(e, t, n) {
46
+ for (let r = n; r !== void 0; r = e.parent(r) || void 0) if (r === t) return !0;
47
+ return !1;
48
+ }
49
+ function h(e, n, r, i = /* @__PURE__ */ new Map()) {
50
+ let a = new t.graphlib.Graph({
35
51
  compound: !0,
36
52
  multigraph: !0
37
53
  });
38
- i.setGraph(r === "TB" ? {
54
+ a.setGraph(r === "TB" ? {
39
55
  rankdir: "TB",
40
56
  nodesep: 28,
41
57
  ranksep: 44,
@@ -45,76 +61,88 @@ function h(e, t, r) {
45
61
  nodesep: 20,
46
62
  ranksep: 72,
47
63
  edgesep: 52
48
- }), i.setDefaultEdgeLabel(() => ({}));
49
- let a = /* @__PURE__ */ new Map();
64
+ }), a.setDefaultEdgeLabel(() => ({}));
65
+ let o = /* @__PURE__ */ new Map();
50
66
  for (let t of e) {
51
- let e = m(t);
52
- a.set(t.id, {
67
+ let e = f(t);
68
+ o.set(t.id, {
53
69
  full: e.full / 2,
54
70
  name: e.name / 2,
55
71
  badge: e.badge / 2
56
72
  });
57
73
  let n = Math.max(40, e.full);
58
- if (i.setNode(t.id, {
74
+ a.setNode(t.id, {
59
75
  width: n,
60
76
  height: 76
61
- }), t.group) {
62
- let e = s + t.group;
63
- i.hasNode(e) || i.setNode(e, {
64
- width: 0,
65
- height: 0
66
- }), i.setParent(t.id, e);
67
- }
77
+ }), t.group && a.setParent(t.id, p(a, t.group, i));
68
78
  }
69
- t.forEach((e, t) => {
79
+ n.forEach((e, t) => {
70
80
  let n = e.label ? {
71
81
  width: e.label.length * 6.4 + 16,
72
82
  height: 18,
73
83
  labelpos: "c"
74
84
  } : {};
75
- i.setEdge(e.source, e.target, n, String(t));
76
- }), n.layout(i);
77
- let o = /* @__PURE__ */ new Map(), c = {
85
+ a.setEdge(e.source, e.target, n, String(t));
86
+ }), t.layout(a);
87
+ let s = /* @__PURE__ */ new Map(), c = {
78
88
  minX: Infinity,
79
89
  minY: Infinity,
80
90
  maxX: -Infinity,
81
91
  maxY: -Infinity
82
92
  };
83
93
  for (let t of e) {
84
- let e = i.node(t.id), n = e.x ?? 0, r = (e.y ?? 0) - 38 + 20;
85
- o.set(t.id, [n, r]), _(c, n, r, n, r);
86
- }
87
- let l = [];
88
- for (let e of i.nodes()) {
89
- if (!e.startsWith(s)) continue;
90
- let t = i.node(e), n = (t.x ?? 0) - t.width / 2 - 10, r = (t.y ?? 0) - t.height / 2 - 10 - 20, a = {
91
- name: e.slice(7),
92
- x: n,
93
- y: r,
94
- width: t.width + 20,
95
- height: t.height + 20 + 20
96
- };
97
- l.push(a);
94
+ let e = a.node(t.id), n = e.x ?? 0, r = (e.y ?? 0) - 38 + 20;
95
+ s.set(t.id, [n, r]), v(c, n, r, n, r);
98
96
  }
97
+ let l = g(a);
99
98
  return e.length || Object.assign(c, {
100
99
  minX: 0,
101
100
  minY: 0,
102
101
  maxX: 0,
103
102
  maxY: 0
104
103
  }), {
105
- positions: o,
104
+ positions: s,
106
105
  groups: l,
107
106
  centers: c,
108
- labelHalf: a
107
+ labelHalf: o
109
108
  };
110
109
  }
111
- function g(e, t, n) {
110
+ function g(e) {
111
+ let t = (t) => {
112
+ let n = 0;
113
+ for (let r = e.parent(t); r; r = e.parent(r)) n++;
114
+ return n;
115
+ }, n = e.nodes().filter((e) => e.startsWith(a)), r = /* @__PURE__ */ new Map();
116
+ for (let i of n.sort((e, n) => t(n) - t(e))) {
117
+ let n = e.node(i), a = {
118
+ minX: (n.x ?? 0) - n.width / 2,
119
+ minY: (n.y ?? 0) - n.height / 2,
120
+ maxX: (n.x ?? 0) + n.width / 2,
121
+ maxY: (n.y ?? 0) + n.height / 2
122
+ };
123
+ for (let t of e.children(i) ?? []) {
124
+ let e = r.get(t);
125
+ e && v(a, e.x, e.y, e.x + e.width, e.y + e.height);
126
+ }
127
+ let o = a.minX - 10, s = a.minY - 10 - 20;
128
+ r.set(i, {
129
+ name: i.slice(7),
130
+ depth: t(i),
131
+ x: o,
132
+ y: s,
133
+ width: a.maxX - a.minX + 20,
134
+ height: a.maxY - a.minY + 20 + 20
135
+ });
136
+ }
137
+ return [...r.values()].sort((e, t) => e.depth - t.depth);
138
+ }
139
+ function _(e, t, n) {
112
140
  let { centers: r } = e, i = {
113
141
  left: 0,
114
142
  top: 0,
115
143
  right: 0,
116
144
  bottom: 0
117
- }, a = u[n];
145
+ }, a = c[n];
118
146
  for (let [o, [s, c]] of e.positions) {
119
147
  let l = e.labelHalf.get(o)?.[n] ?? 0, u = Math.max(20 * t, l);
120
148
  i.left = Math.max(i.left, u - (s - r.minX) * t), i.right = Math.max(i.right, u - (r.maxX - s) * t), i.top = Math.max(i.top, 20 * t - (c - r.minY) * t);
@@ -124,32 +152,8 @@ function g(e, t, n) {
124
152
  for (let n of e.groups) i.left = Math.max(i.left, (r.minX - n.x) * t), i.right = Math.max(i.right, (n.x + n.width - r.maxX) * t), i.top = Math.max(i.top, (r.minY - n.y) * t), i.bottom = Math.max(i.bottom, (n.y + n.height - r.maxY) * t);
125
153
  return i;
126
154
  }
127
- function _(e, t, n, r, i) {
155
+ function v(e, t, n, r, i) {
128
156
  e.minX = Math.min(e.minX, t), e.minY = Math.min(e.minY, n), e.maxX = Math.max(e.maxX, r), e.maxY = Math.max(e.maxY, i);
129
157
  }
130
- var v = /* @__PURE__ */ new WeakMap();
131
- function y(n) {
132
- let i = v.get(n);
133
- if (i !== void 0) return i;
134
- if (i = "", typeof document < "u") {
135
- let a = document.createElement("div");
136
- t(e(n, {
137
- size: r,
138
- width: r,
139
- height: r
140
- }), a);
141
- let o = a.querySelector("svg");
142
- o && (o.removeAttribute("class"), o.setAttribute("x", "10"), o.setAttribute("y", "10"), o.setAttribute("width", String(r)), o.setAttribute("height", String(r)), i = new XMLSerializer().serializeToString(o)), t(null, a);
143
- }
144
- return v.set(n, i), i;
145
- }
146
- function b(e) {
147
- return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
148
- }
149
- var x = 160;
150
- function S(e) {
151
- let t = e.ringWidth / 2, n = 40 - e.ringWidth, r = `<svg xmlns="http://www.w3.org/2000/svg" width="${x}" height="${x}" viewBox="0 0 40 40">${e.shape === "square" ? `<rect x="${t}" y="${t}" width="${n}" height="${n}" rx="10" fill="${e.fill}" stroke="${e.ring}" stroke-width="${e.ringWidth}"/>` : `<circle cx="20" cy="20" r="${n / 2}" fill="${e.fill}" stroke="${e.ring}" stroke-width="${e.ringWidth}"/>`}${typeof e.icon == "string" ? `<text x="20" y="20" text-anchor="middle" dominant-baseline="central" font-size="11" font-weight="600" font-family="${b(e.font)}" fill="${e.iconColor}">${b(e.icon.slice(0, 3))}</text>` : `<g color="${e.iconColor}">${y(e.icon)}</g>`}</svg>`;
152
- return `image://data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`;
153
- }
154
158
  //#endregion
155
- export { c as LABEL_DETAILS, l as labelDetail, h as layoutGraph, S as nodeImage, p as nodeKind, f as nodeName, g as overhang, d as truncate };
159
+ export { o as LABEL_DETAILS, s as labelDetail, h as layoutGraph, e as nodeImage, d as nodeKind, u as nodeName, _ as overhang, l as truncate };
@@ -4,8 +4,10 @@ export { default as AcBarChart } from "../components/AcBarChart.vue";
4
4
  export { default as AcDonutChart } from "../components/AcDonutChart.vue";
5
5
  export { default as AcGraphChart } from "../components/AcGraphChart.vue";
6
6
  export { default as AcMapChart } from "../components/AcMapChart.vue";
7
+ export { default as AcTreeChart } from "../components/AcTreeChart.vue";
7
8
  export type { ChartAccessor, ChartCategory, ChartColor, ChartCurve, ChartDatum, ChartLegendPosition, ChartTooltipItem, } from "./shared";
8
9
  export type { ChartTooltipSlotProps } from "./ChartFrame.vue";
9
10
  export type { XYChartProps } from "./xy";
10
- export type { MapChartTooltipSlotProps, MapGeoJson, MapPoint, MapPointStatus } from "../components/AcMapChart.vue";
11
- export type { GraphLink, GraphNode, GraphStatus, GraphTooltipSlotProps } from "../components/AcGraphChart.vue";
11
+ export type { MapArea, MapChartAreaTooltipSlotProps, MapChartTooltipSlotProps, MapFocusTarget, MapGeoJson, MapPoint, MapPointStatus, } from "../components/AcMapChart.vue";
12
+ export type { GraphGroup, GraphHighlight, GraphLink, GraphLinkStyle, GraphNode, GraphStatus, GraphTooltipSlotProps } from "../components/AcGraphChart.vue";
13
+ export type { TreeChartNode, TreeChartStatus, TreeChartTooltipSlotProps } from "../components/AcTreeChart.vue";
@@ -4,4 +4,5 @@ import n from "../components/AcBarChart.js";
4
4
  import r from "../components/AcDonutChart.js";
5
5
  import i from "../components/AcGraphChart.js";
6
6
  import a from "../components/AcMapChart.js";
7
- export { t as AcAreaChart, n as AcBarChart, r as AcDonutChart, i as AcGraphChart, e as AcLineChart, a as AcMapChart };
7
+ import o from "../components/AcTreeChart.js";
8
+ export { t as AcAreaChart, n as AcBarChart, r as AcDonutChart, i as AcGraphChart, e as AcLineChart, a as AcMapChart, o as AcTreeChart };
@@ -0,0 +1,15 @@
1
+ import type { Component } from "vue";
2
+ export interface NodeImageOptions {
3
+ icon: Component | string;
4
+ /** Resolved colours (ECharts and SVG images can't read CSS variables). */
5
+ iconColor: string;
6
+ fill: string;
7
+ ring: string;
8
+ ringWidth: number;
9
+ shape: "circle" | "square";
10
+ font: string;
11
+ /** Size of a text icon in view-box units. */
12
+ fontSize?: number;
13
+ }
14
+ /** One node as an `image://` symbol: fill, ring and icon in a 40×40 view box. */
15
+ export declare function nodeImage(o: NodeImageOptions): string;
@@ -0,0 +1,27 @@
1
+ import { h as e, render as t } from "vue";
2
+ //#region src/lib/charts/nodeSymbol.ts
3
+ var n = 40, r = 20, i = 160, a = /* @__PURE__ */ new WeakMap();
4
+ function o(n) {
5
+ let i = a.get(n);
6
+ if (i !== void 0) return i;
7
+ if (i = "", typeof document < "u") {
8
+ let a = document.createElement("div");
9
+ t(e(n, {
10
+ size: r,
11
+ width: r,
12
+ height: r
13
+ }), a);
14
+ let o = a.querySelector("svg");
15
+ o && (o.removeAttribute("class"), o.setAttribute("x", "10"), o.setAttribute("y", "10"), o.setAttribute("width", String(r)), o.setAttribute("height", String(r)), i = new XMLSerializer().serializeToString(o)), t(null, a);
16
+ }
17
+ return a.set(n, i), i;
18
+ }
19
+ function s(e) {
20
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
21
+ }
22
+ function c(e) {
23
+ let t = e.ringWidth / 2, r = n - e.ringWidth, a = `<svg xmlns="http://www.w3.org/2000/svg" width="${i}" height="${i}" viewBox="0 0 ${n} ${n}">${e.shape === "square" ? `<rect x="${t}" y="${t}" width="${r}" height="${r}" rx="10" fill="${e.fill}" stroke="${e.ring}" stroke-width="${e.ringWidth}"/>` : `<circle cx="${n / 2}" cy="${n / 2}" r="${r / 2}" fill="${e.fill}" stroke="${e.ring}" stroke-width="${e.ringWidth}"/>`}${typeof e.icon == "string" ? `<text x="${n / 2}" y="${n / 2}" text-anchor="middle" dominant-baseline="central" font-size="${e.fontSize ?? 11}" font-weight="600" font-family="${s(e.font)}" fill="${e.iconColor}">${s(e.icon.slice(0, 3))}</text>` : `<g color="${e.iconColor}">${o(e.icon)}</g>`}</svg>`;
24
+ return `image://data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`;
25
+ }
26
+ //#endregion
27
+ export { c as nodeImage };
@@ -0,0 +1,15 @@
1
+ /** A node of the tree as the layout sees it: only its open children. */
2
+ export interface BreadthNode {
3
+ children: BreadthNode[];
4
+ }
5
+ /**
6
+ * How many rows (LR) or columns (TB) ECharts' tree layout spreads the open nodes over: siblings sit one unit apart,
7
+ * cousins two. Mirrors ECharts' own Reingold–Tilford pass, so a box this many units tall gives every row the same pitch.
8
+ */
9
+ export declare function treeBreadth(root: BreadthNode): number;
10
+ /** Width of `text` in px, set in a CSS font such as `500 12px Roboto`. */
11
+ export declare function textWidth(text: string, font: string): number;
12
+ /** `text` cut with an ellipsis to fit `max` px; at least `minChars` characters stay. */
13
+ export declare function fitText(text: string, max: number, font: string, minChars?: number): string;
14
+ /** Symbol diameter of a node with an icon, in px. */
15
+ export declare const ICON_NODE = 28;
@@ -0,0 +1,89 @@
1
+ //#region src/lib/charts/tree.ts
2
+ function e(e, t) {
3
+ return e.parent === t.parent ? 1 : 2;
4
+ }
5
+ function t(e) {
6
+ return e.children.length ? e.children[e.children.length - 1] : e.thread;
7
+ }
8
+ function n(e) {
9
+ return e.children.length ? e.children[0] : e.thread;
10
+ }
11
+ function r(e, t, n) {
12
+ let r = n / (t.i - e.i);
13
+ t.change -= r, t.shift += n, t.modifier += n, t.prelim += n, e.change += r;
14
+ }
15
+ function i(e) {
16
+ let t = 0, n = 0;
17
+ for (let r = e.children.length - 1; r >= 0; r--) {
18
+ let i = e.children[r];
19
+ i.prelim += t, i.modifier += t, n += i.change, t += i.shift + n;
20
+ }
21
+ }
22
+ function a(i, a, o) {
23
+ if (!a) return o;
24
+ let s = i, c = i, l = a, u = i.parent.children[0], d = s.modifier, f = c.modifier, p = l.modifier, m = u.modifier;
25
+ for (;;) {
26
+ let a = t(l), h = n(s);
27
+ if (l = a, s = h, !a || !h) break;
28
+ c = t(c), u = n(u), c.ancestor = i;
29
+ let g = a.prelim + p - h.prelim - d + e(a, h);
30
+ g > 0 && (r(a.ancestor.parent === i.parent ? a.ancestor : o, i, g), d += g, f += g), p += a.modifier, d += h.modifier, f += c.modifier, m += u.modifier;
31
+ }
32
+ return l && !t(c) && (c.thread = l, c.modifier += p - f), s && !n(u) && (u.thread = s, u.modifier += d - m, o = i), o;
33
+ }
34
+ function o(t) {
35
+ let n = (e, t, r) => {
36
+ let i = {
37
+ node: e,
38
+ parent: t,
39
+ children: [],
40
+ i: r,
41
+ prelim: 0,
42
+ modifier: 0,
43
+ change: 0,
44
+ shift: 0,
45
+ thread: null,
46
+ defaultAncestor: null,
47
+ x: 0
48
+ };
49
+ return i.ancestor = i, i.children = e.children.map((e, t) => n(e, i, t)), i;
50
+ }, r = n({ children: [t] }, null, 0), o = r.children[0], s = [], c = [o];
51
+ for (; c.length;) {
52
+ let e = c.pop();
53
+ s.push(e), c.push(...e.children);
54
+ }
55
+ for (let t = s.length - 1; t >= 0; t--) {
56
+ let n = s[t], r = n.parent.children, o = n.i ? r[n.i - 1] : null;
57
+ if (n.children.length) {
58
+ i(n);
59
+ let t = (n.children[0].prelim + n.children[n.children.length - 1].prelim) / 2;
60
+ o ? (n.prelim = o.prelim + e(n, o), n.modifier = n.prelim - t) : n.prelim = t;
61
+ } else o && (n.prelim = o.prelim + e(n, o));
62
+ n.parent.defaultAncestor = a(n, o, n.parent.defaultAncestor ?? r[0]);
63
+ }
64
+ r.modifier = -o.prelim;
65
+ let l = o, u = o, d = [o];
66
+ for (; d.length;) {
67
+ let e = d.pop();
68
+ e.x = e.prelim + e.parent.modifier, e.modifier += e.parent.modifier, e.x < l.x && (l = e), e.x > u.x && (u = e);
69
+ for (let t = e.children.length - 1; t >= 0; t--) d.push(e.children[t]);
70
+ }
71
+ let f = l === u ? 1 : e(l, u) / 2;
72
+ return u.x - l.x + 2 * f;
73
+ }
74
+ var s, c = /* @__PURE__ */ new Map();
75
+ function l(e, t) {
76
+ let n = `${t}\u0000${e}`, r = c.get(n);
77
+ return r === void 0 ? (s === void 0 && (s = typeof document > "u" ? null : document.createElement("canvas").getContext("2d")), s ? (s.font = t, r = s.measureText(e).width) : r = e.length * 6.6, c.size > 5e3 && c.clear(), c.set(n, r), r) : r;
78
+ }
79
+ function u(e, t, n, r = 4) {
80
+ if (l(e, n) <= t) return e;
81
+ let i = Math.min(r, e.length), a = e.length;
82
+ for (; i < a;) {
83
+ let r = i + a + 1 >> 1;
84
+ l(`${e.slice(0, r)}…`, n) <= t ? i = r : a = r - 1;
85
+ }
86
+ return `${e.slice(0, i).trimEnd()}…`;
87
+ }
88
+ //#endregion
89
+ export { u as fitText, l as textWidth, o as treeBreadth };