@fengwk/kchart 0.0.0-stage → 0.1.1
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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/NOTICE.md +11 -0
- package/README.md +68 -2
- package/README.zh-CN.md +69 -0
- package/dist/LICENSE +21 -0
- package/dist/NOTICE.md +11 -0
- package/dist/assets/ICONS-LICENSE.txt +53 -0
- package/dist/assets/maps/LICENSE.md +75 -0
- package/dist/assets/maps/METADATA.md +9 -0
- package/dist/assets/maps/REGIONS.md +28 -0
- package/dist/assets/maps/us-states.geojson +1 -0
- package/dist/assets/maps/world.geojson +1 -0
- package/dist/esm/_virtual/_kchart-families.js +48 -0
- package/dist/esm/_virtual/_rolldown/runtime.js +12 -0
- package/dist/esm/assets/icons.js +11 -0
- package/dist/esm/assets/maps/us-states.js +3 -0
- package/dist/esm/assets/maps/world.js +3 -0
- package/dist/esm/assets/themes/claude.js +69 -0
- package/dist/esm/assets/themes/cloudmusic.js +62 -0
- package/dist/esm/assets/themes/kanagawa.js +67 -0
- package/dist/esm/assets/themes/obsidian.js +67 -0
- package/dist/esm/assets/themes/paper.js +61 -0
- package/dist/esm/assets/themes/terminal.js +60 -0
- package/dist/esm/assets/themes/tokyo.js +62 -0
- package/dist/esm/chart/basic.js +1313 -0
- package/dist/esm/chart/catalog.js +476 -0
- package/dist/esm/chart/composition.js +844 -0
- package/dist/esm/chart/context.js +189 -0
- package/dist/esm/chart/distribution.js +442 -0
- package/dist/esm/chart/fields.js +67 -0
- package/dist/esm/chart/maps.js +563 -0
- package/dist/esm/chart/mindmap.js +629 -0
- package/dist/esm/chart/multivariate.js +1229 -0
- package/dist/esm/chart/registry.js +108 -0
- package/dist/esm/chart/relations.js +949 -0
- package/dist/esm/chart/spec.js +1415 -0
- package/dist/esm/chart/stat-compare.js +302 -0
- package/dist/esm/chart/stat-trend.js +181 -0
- package/dist/esm/chart/statistics.js +1007 -0
- package/dist/esm/chart/unit-variants.js +645 -0
- package/dist/esm/chart/variants.js +552 -0
- package/dist/esm/core/color.js +197 -0
- package/dist/esm/core/context.js +256 -0
- package/dist/esm/core/diagnostics.js +23 -0
- package/dist/esm/core/format.js +167 -0
- package/dist/esm/core/geometry.js +130 -0
- package/dist/esm/core/icon-data.js +5 -0
- package/dist/esm/core/icons.js +173 -0
- package/dist/esm/core/scale.js +112 -0
- package/dist/esm/core/scene.js +234 -0
- package/dist/esm/core/svg.js +89 -0
- package/dist/esm/core/text.js +184 -0
- package/dist/esm/core/theme.js +318 -0
- package/dist/esm/diagram/agentflow.js +596 -0
- package/dist/esm/diagram/architecture.js +729 -0
- package/dist/esm/diagram/block.js +988 -0
- package/dist/esm/diagram/blocks.js +687 -0
- package/dist/esm/diagram/c4.js +1002 -0
- package/dist/esm/diagram/class.js +1158 -0
- package/dist/esm/diagram/cynefin.js +749 -0
- package/dist/esm/diagram/emphasis.js +7 -0
- package/dist/esm/diagram/er.js +657 -0
- package/dist/esm/diagram/eventmodeling.js +948 -0
- package/dist/esm/diagram/gantt-date.js +323 -0
- package/dist/esm/diagram/gantt.js +661 -0
- package/dist/esm/diagram/gitgraph.js +472 -0
- package/dist/esm/diagram/graph-layout.js +4046 -0
- package/dist/esm/diagram/graph-parse.js +1366 -0
- package/dist/esm/diagram/graph-route.js +490 -0
- package/dist/esm/diagram/graph.js +553 -0
- package/dist/esm/diagram/ishikawa.js +496 -0
- package/dist/esm/diagram/journey.js +512 -0
- package/dist/esm/diagram/kanban.js +280 -0
- package/dist/esm/diagram/label.js +56 -0
- package/dist/esm/diagram/layers.js +385 -0
- package/dist/esm/diagram/map-label.js +44 -0
- package/dist/esm/diagram/mindmap.js +277 -0
- package/dist/esm/diagram/numeric-composition.js +78 -0
- package/dist/esm/diagram/numeric-model.js +86 -0
- package/dist/esm/diagram/numeric-parse.js +205 -0
- package/dist/esm/diagram/numeric-radar.js +355 -0
- package/dist/esm/diagram/numeric-sankey.js +201 -0
- package/dist/esm/diagram/numeric-xy.js +422 -0
- package/dist/esm/diagram/packet.js +175 -0
- package/dist/esm/diagram/presentation.js +252 -0
- package/dist/esm/diagram/quadrant.js +297 -0
- package/dist/esm/diagram/railroad-parse.js +465 -0
- package/dist/esm/diagram/railroad.js +294 -0
- package/dist/esm/diagram/registry.js +296 -0
- package/dist/esm/diagram/relations.js +966 -0
- package/dist/esm/diagram/requirement.js +341 -0
- package/dist/esm/diagram/sequence.js +1228 -0
- package/dist/esm/diagram/shapes.js +366 -0
- package/dist/esm/diagram/source.js +538 -0
- package/dist/esm/diagram/support.js +153 -0
- package/dist/esm/diagram/swimlane-mermaid.js +140 -0
- package/dist/esm/diagram/swimlane.js +1186 -0
- package/dist/esm/diagram/time.js +748 -0
- package/dist/esm/diagram/timeline.js +376 -0
- package/dist/esm/diagram/tree-family-icon.js +22 -0
- package/dist/esm/diagram/treeview.js +293 -0
- package/dist/esm/diagram/usecase.js +852 -0
- package/dist/esm/diagram/venn.js +1038 -0
- package/dist/esm/diagram/wardley.js +838 -0
- package/dist/esm/index.d.ts +133 -0
- package/dist/esm/index.js +92 -0
- package/dist/esm/interaction.js +561 -0
- package/dist/esm/mermaid.d.ts +28 -0
- package/dist/esm/mermaid.js +70 -0
- package/dist/esm/node.d.ts +68 -0
- package/dist/esm/node.js +373 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/page-api.js +65 -0
- package/dist/esm/runtime.js +352 -0
- package/dist/esm/src/families.js +209 -0
- package/dist/page-api.js +1 -0
- package/dist/units/chart/basic.js +1 -0
- package/dist/units/chart/catalog.js +1 -0
- package/dist/units/chart/composition.js +1 -0
- package/dist/units/chart/context.js +1 -0
- package/dist/units/chart/distribution.js +1 -0
- package/dist/units/chart/fields.js +1 -0
- package/dist/units/chart/maps.js +1 -0
- package/dist/units/chart/mindmap.js +1 -0
- package/dist/units/chart/multivariate.js +1 -0
- package/dist/units/chart/registry.js +1 -0
- package/dist/units/chart/relations.js +1 -0
- package/dist/units/chart/spec.js +3 -0
- package/dist/units/chart/stat-compare.js +1 -0
- package/dist/units/chart/stat-trend.js +1 -0
- package/dist/units/chart/statistics.js +1 -0
- package/dist/units/chart/unit-variants.js +1 -0
- package/dist/units/chart/variants.js +1 -0
- package/dist/units/core/color.js +1 -0
- package/dist/units/core/context.js +1 -0
- package/dist/units/core/diagnostics.js +1 -0
- package/dist/units/core/format.js +1 -0
- package/dist/units/core/geometry.js +1 -0
- package/dist/units/core/icon-data.js +1 -0
- package/dist/units/core/icons.js +1 -0
- package/dist/units/core/scale.js +1 -0
- package/dist/units/core/scene.js +1 -0
- package/dist/units/core/svg.js +1 -0
- package/dist/units/core/text.js +2 -0
- package/dist/units/core/theme.js +1 -0
- package/dist/units/diagram/agentflow.js +12 -0
- package/dist/units/diagram/architecture.js +4 -0
- package/dist/units/diagram/block.js +2 -0
- package/dist/units/diagram/blocks.js +2 -0
- package/dist/units/diagram/c4.js +6 -0
- package/dist/units/diagram/class.js +5 -0
- package/dist/units/diagram/cynefin.js +4 -0
- package/dist/units/diagram/emphasis.js +1 -0
- package/dist/units/diagram/er.js +9 -0
- package/dist/units/diagram/eventmodeling.js +5 -0
- package/dist/units/diagram/gantt-date.js +1 -0
- package/dist/units/diagram/gantt.js +3 -0
- package/dist/units/diagram/gitgraph.js +2 -0
- package/dist/units/diagram/graph-layout.js +4 -0
- package/dist/units/diagram/graph-parse.js +9 -0
- package/dist/units/diagram/graph-route.js +1 -0
- package/dist/units/diagram/graph.js +1 -0
- package/dist/units/diagram/ishikawa.js +2 -0
- package/dist/units/diagram/journey.js +5 -0
- package/dist/units/diagram/kanban.js +2 -0
- package/dist/units/diagram/label.js +4 -0
- package/dist/units/diagram/layers.js +1 -0
- package/dist/units/diagram/map-label.js +1 -0
- package/dist/units/diagram/mindmap.js +2 -0
- package/dist/units/diagram/numeric-composition.js +1 -0
- package/dist/units/diagram/numeric-model.js +1 -0
- package/dist/units/diagram/numeric-parse.js +2 -0
- package/dist/units/diagram/numeric-radar.js +3 -0
- package/dist/units/diagram/numeric-sankey.js +2 -0
- package/dist/units/diagram/numeric-xy.js +2 -0
- package/dist/units/diagram/packet.js +2 -0
- package/dist/units/diagram/presentation.js +2 -0
- package/dist/units/diagram/quadrant.js +2 -0
- package/dist/units/diagram/railroad-parse.js +4 -0
- package/dist/units/diagram/railroad.js +1 -0
- package/dist/units/diagram/registry.js +2 -0
- package/dist/units/diagram/relations.js +3 -0
- package/dist/units/diagram/requirement.js +3 -0
- package/dist/units/diagram/sequence.js +2 -0
- package/dist/units/diagram/shapes.js +60 -0
- package/dist/units/diagram/source.js +20 -0
- package/dist/units/diagram/support.js +3 -0
- package/dist/units/diagram/swimlane-mermaid.js +3 -0
- package/dist/units/diagram/swimlane.js +2 -0
- package/dist/units/diagram/time.js +3 -0
- package/dist/units/diagram/timeline.js +2 -0
- package/dist/units/diagram/tree-family-icon.js +1 -0
- package/dist/units/diagram/treeview.js +2 -0
- package/dist/units/diagram/usecase.js +3 -0
- package/dist/units/diagram/venn.js +2 -0
- package/dist/units/diagram/wardley.js +4 -0
- package/dist/units/interaction.js +1 -0
- package/dist/units/runtime.js +1 -0
- package/dist/units.json +712 -0
- package/package.json +30 -4
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { safeHref } from "../core/scene.js";
|
|
3
|
+
import { resolveIconRef } from "../core/icons.js";
|
|
4
|
+
import { normalizeLabel } from "./label.js";
|
|
5
|
+
import { presentation } from "./presentation.js";
|
|
6
|
+
import { FONT, appearance, error, warning } from "./support.js";
|
|
7
|
+
// src/diagram/kanban.js
|
|
8
|
+
var kanban_exports = /* @__PURE__ */ __exportAll({ implementations: () => implementations });
|
|
9
|
+
var priorities = /* @__PURE__ */ new Map([
|
|
10
|
+
["Very High", "danger"],
|
|
11
|
+
["High", "warn"],
|
|
12
|
+
["Medium", null],
|
|
13
|
+
["Low", "info"],
|
|
14
|
+
["Very Low", "info"]
|
|
15
|
+
]);
|
|
16
|
+
var shapes = [
|
|
17
|
+
["((", "))"],
|
|
18
|
+
["{{", "}}"],
|
|
19
|
+
["))", "(("],
|
|
20
|
+
["-)", "(-"],
|
|
21
|
+
["(-", "-)"],
|
|
22
|
+
["[", "]"],
|
|
23
|
+
["(", ")"],
|
|
24
|
+
[")", "("]
|
|
25
|
+
];
|
|
26
|
+
var honoredConfig = [
|
|
27
|
+
"kanban.sectionWidth",
|
|
28
|
+
"kanban.padding",
|
|
29
|
+
"kanban.ticketBaseUrl"
|
|
30
|
+
];
|
|
31
|
+
function metadata(source) {
|
|
32
|
+
const result = /* @__PURE__ */ new Map(), pair = /\s*([\w-]+)\s*:\s*("(?:\\.|[^"\\])*"|'(?:''|[^'])*'|[^,]+?)\s*(,|$)/y;
|
|
33
|
+
let at = 0;
|
|
34
|
+
while (at < source.length) {
|
|
35
|
+
pair.lastIndex = at;
|
|
36
|
+
const m = pair.exec(source);
|
|
37
|
+
if (!m) return null;
|
|
38
|
+
const raw = m[2].trim();
|
|
39
|
+
result.set(m[1], raw.startsWith("\"") ? raw.slice(1, -1).replace(/\\(.)/g, "$1") : raw.startsWith("'") ? raw.slice(1, -1).replace(/''/g, "'") : raw);
|
|
40
|
+
at = pair.lastIndex;
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
function parse(body, { lang, firstLine = 2, title = "", config, options = {} }) {
|
|
45
|
+
const columns = [], errors = [], unknownPriorities = /* @__PURE__ */ new Map(), assets = /* @__PURE__ */ new Set();
|
|
46
|
+
const look = presentation({ lang });
|
|
47
|
+
const report = (d) => {
|
|
48
|
+
if (!assets.has(d.message)) {
|
|
49
|
+
assets.add(d.message);
|
|
50
|
+
errors.push(d);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const clean = (raw, line) => {
|
|
54
|
+
const result = normalizeLabel(raw, {
|
|
55
|
+
lang,
|
|
56
|
+
line
|
|
57
|
+
});
|
|
58
|
+
result.diagnostics.forEach(report);
|
|
59
|
+
return result;
|
|
60
|
+
};
|
|
61
|
+
const fail = (line, zh, en) => errors.push(error(lang, line, zh, en, "修正列或卡片声明", "Fix the column or card declaration"));
|
|
62
|
+
if (Object.keys(options).length) fail(firstLine - 1, "kanban 不接受标题行选项", "Unexpected kanban header option");
|
|
63
|
+
let level, column, count = 0;
|
|
64
|
+
for (const [i, raw] of body.split("\n").entries()) {
|
|
65
|
+
const line = firstLine + i;
|
|
66
|
+
let s = raw.trim();
|
|
67
|
+
if (!s || s.startsWith("%%") || look.accept(s, line)) continue;
|
|
68
|
+
const suffix = /\s*(?:::icon\(([^()]+)\)|:::([\w-]+))$/;
|
|
69
|
+
let ending, iconRef;
|
|
70
|
+
const classes = [];
|
|
71
|
+
while (ending = suffix.exec(s)) {
|
|
72
|
+
if (ending[2]) classes.unshift(ending[2]);
|
|
73
|
+
else iconRef ??= ending[1].trim();
|
|
74
|
+
s = s.slice(0, ending.index).trimEnd();
|
|
75
|
+
}
|
|
76
|
+
if (!s && (classes.length || iconRef) && column) {
|
|
77
|
+
const item = column.cards.at(-1) || column;
|
|
78
|
+
look.addClasses(item.key, classes, line);
|
|
79
|
+
if (iconRef) item.icon = resolveIconRef(iconRef);
|
|
80
|
+
if (iconRef && !item.icon) report(warning("IGNORED_ASSET", lang, line, `未知图标 ${iconRef}`, `Unknown icon ${iconRef}`));
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const meta = /\s*@\{([\s\S]*)\}\s*$/.exec(s);
|
|
84
|
+
const data = meta ? metadata(meta[1].trim()) : /* @__PURE__ */ new Map();
|
|
85
|
+
if (meta) s = s.slice(0, meta.index).trimEnd();
|
|
86
|
+
const start = s.search(/[\[({)]|-\)/);
|
|
87
|
+
const shape = shapes.find(([open, close]) => start >= 0 && s.slice(start).startsWith(open) && s.endsWith(close));
|
|
88
|
+
if (!data || !shape && (start >= 0 || !/^\S+$/.test(s)) || /:::/.test(s.slice(0, start < 0 ? s.length : start))) {
|
|
89
|
+
fail(line, "无效的看板条目", "Invalid kanban item");
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const id = shape ? s.slice(0, start).trim() : s;
|
|
93
|
+
const caption = clean(data.get("label") ?? (shape ? s.slice(start + shape[0].length, -shape[1].length) : id), line);
|
|
94
|
+
iconRef ??= data.get("icon");
|
|
95
|
+
const icon = iconRef && resolveIconRef(iconRef) || caption.icon;
|
|
96
|
+
if (iconRef && !resolveIconRef(iconRef)) report(warning("IGNORED_ASSET", lang, line, `未知图标 ${iconRef}`, `Unknown icon ${iconRef}`));
|
|
97
|
+
const key = id || `kanban-item-${line}`;
|
|
98
|
+
if (classes.length) look.addClasses(key, classes, line);
|
|
99
|
+
const item = {
|
|
100
|
+
id,
|
|
101
|
+
key,
|
|
102
|
+
label: caption.text,
|
|
103
|
+
icon
|
|
104
|
+
};
|
|
105
|
+
const indent = raw.search(/\S/);
|
|
106
|
+
level ??= indent;
|
|
107
|
+
if (indent < level) {
|
|
108
|
+
fail(line, `缩进小于首列的 ${level} 个空格`, `Indentation is shallower than the first column (${level})`);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (++count > 2e3) {
|
|
112
|
+
fail(line, "看板超过 2000 个条目,请拆分图表", "Board exceeds 2000 items; split the diagram");
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
if (indent === level) {
|
|
116
|
+
columns.push(column = {
|
|
117
|
+
...item,
|
|
118
|
+
cards: [],
|
|
119
|
+
ids: /* @__PURE__ */ new Set()
|
|
120
|
+
});
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (id && column.ids.has(id)) {
|
|
124
|
+
fail(line, `本列的卡片 ID 重复:${id}`, `Duplicate card ID in this column: ${id}`);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (id) column.ids.add(id);
|
|
128
|
+
const priority = data.get("priority");
|
|
129
|
+
if (priority && !priorities.has(priority) && !unknownPriorities.has(priority)) unknownPriorities.set(priority, line);
|
|
130
|
+
column.cards.push({
|
|
131
|
+
...item,
|
|
132
|
+
line,
|
|
133
|
+
ticket: clean(data.get("ticket"), line).text,
|
|
134
|
+
assigned: clean(data.get("assigned"), line).text,
|
|
135
|
+
priority
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
for (const col of columns) for (const item of [col, ...col.cards]) {
|
|
139
|
+
item.status = look.statusOf(item.key);
|
|
140
|
+
item.link = look.linkOf(item.key);
|
|
141
|
+
}
|
|
142
|
+
errors.push(...look.diagnostics());
|
|
143
|
+
if (!columns.length) fail(firstLine, "缺少看板列", "Expected at least one column");
|
|
144
|
+
if (unknownPriorities.size) {
|
|
145
|
+
const names = [...unknownPriorities.keys()].join(", ");
|
|
146
|
+
errors.push(warning("DIAGRAM_HINT", lang, unknownPriorities.values().next().value, `未知优先级:${names}`, `Unknown priorities: ${names}`, "使用标准优先级", "Use a standard priority"));
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
model: {
|
|
150
|
+
type: "kanban",
|
|
151
|
+
columns,
|
|
152
|
+
title,
|
|
153
|
+
count,
|
|
154
|
+
config: config?.kanban || {}
|
|
155
|
+
},
|
|
156
|
+
errors
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function drawIcon(ctx, icon, x, y, ink) {
|
|
160
|
+
const [l, t, w, h] = icon.viewBox.split(/\s+/).map(Number), scale = 16 / Math.max(w, h);
|
|
161
|
+
const solid = icon.set === "simple";
|
|
162
|
+
return ctx.el("g", {
|
|
163
|
+
transform: `translate(${x - l * scale} ${y - t * scale}) scale(${scale})`,
|
|
164
|
+
fill: solid ? ink : "none",
|
|
165
|
+
stroke: solid ? "none" : ink,
|
|
166
|
+
"stroke-width": 1.6,
|
|
167
|
+
"stroke-linecap": "round",
|
|
168
|
+
"stroke-linejoin": "round"
|
|
169
|
+
}, icon.elements.map(({ tag, attrs }) => ctx.shape(tag, attrs)));
|
|
170
|
+
}
|
|
171
|
+
function layout(model, { width, ctx, renderOptions }, info = {}) {
|
|
172
|
+
const { columns, config, title, count } = model, t = appearance(ctx), gap = 14, pad = 18;
|
|
173
|
+
const colWidth = Math.max(180, Math.min(560, Number(config.sectionWidth) || 220));
|
|
174
|
+
const inset = Math.max(8, Math.min(28, Number(config.padding) || 10));
|
|
175
|
+
const colsWidth = columns.length * (colWidth + gap) - gap;
|
|
176
|
+
const w = Math.max(width, colsWidth + 36), left = (w - colsWidth) / 2;
|
|
177
|
+
const titleInline = title && !renderOptions?.frame, top = titleInline ? 52 : pad;
|
|
178
|
+
const cardWidth = colWidth - 2 * inset, cardPad = 12, inner = cardWidth - 24;
|
|
179
|
+
const headers = columns.map((c) => ctx.wrap(c.label, cardWidth - (c.icon ? 22 : 0), FONT.title.size, FONT.title.weight));
|
|
180
|
+
const headerHeight = Math.max(...headers.map((lines) => lines.length)) * 18 + 22;
|
|
181
|
+
const children = [], errors = [];
|
|
182
|
+
if (titleInline) children.push(ctx.text(left, 32, title, {
|
|
183
|
+
...FONT.title,
|
|
184
|
+
fill: t.fg1
|
|
185
|
+
}));
|
|
186
|
+
const frames = columns.map((column, i) => {
|
|
187
|
+
const x = left + i * (colWidth + gap), cardX = x + inset;
|
|
188
|
+
let y = top + headerHeight;
|
|
189
|
+
const header = [...ctx.textLines(cardX + (column.icon ? 22 : 0), top + 24, headers[i], {
|
|
190
|
+
...FONT.title,
|
|
191
|
+
leading: 18,
|
|
192
|
+
fill: t.fg1
|
|
193
|
+
}).children ?? []];
|
|
194
|
+
if (column.icon) header.push(drawIcon(ctx, column.icon, cardX, top + 11, t[column.status] || t.fg1));
|
|
195
|
+
children.push(...column.link ? [ctx.link(column.link.href, header, column.link)] : header);
|
|
196
|
+
column.cards.forEach((card, j) => {
|
|
197
|
+
const first = children.length, iconGap = card.icon ? 22 : 0;
|
|
198
|
+
const lines = ctx.wrap(card.label, inner - iconGap, FONT.body.size);
|
|
199
|
+
const sizes = [card.ticket, card.assigned].map((text) => ctx.measure(text, FONT.label.size));
|
|
200
|
+
const shared = sizes[0] + sizes[1] + 12 <= inner;
|
|
201
|
+
const ticket = card.ticket ? ctx.wrap(card.ticket, inner, FONT.label.size) : [];
|
|
202
|
+
const assigned = card.assigned ? ctx.wrap(card.assigned, inner, FONT.label.size) : [];
|
|
203
|
+
const rows = shared ? Math.max(ticket.length, assigned.length) : ticket.length + assigned.length;
|
|
204
|
+
const h = 22 + lines.length * 17 + (rows ? 5 + rows * 16 : 0);
|
|
205
|
+
const metaY = y + 17 + lines.length * 17 + 5;
|
|
206
|
+
children.push(ctx.rect(cardX, y, cardWidth, h, {
|
|
207
|
+
rx: t.smallRadius,
|
|
208
|
+
fill: card.status ? ctx.tint(t.surface, t[card.status], .1) : t.surface,
|
|
209
|
+
stroke: t[card.status] || t.line,
|
|
210
|
+
meta: {
|
|
211
|
+
kind: "node",
|
|
212
|
+
id: `${i}:${j}`
|
|
213
|
+
}
|
|
214
|
+
}));
|
|
215
|
+
const status = priorities.get(card.priority);
|
|
216
|
+
if (status) children.push(ctx.rect(cardX + 1, y + 7, 4, h - 14, {
|
|
217
|
+
rx: 2,
|
|
218
|
+
fill: t[status],
|
|
219
|
+
opacity: card.priority === "Very Low" ? .4 : 1
|
|
220
|
+
}));
|
|
221
|
+
if (card.icon) children.push(drawIcon(ctx, card.icon, cardX + cardPad, y + 6, t[card.status] || t.fg1));
|
|
222
|
+
children.push(...ctx.textLines(cardX + cardPad + iconGap, y + 17, lines, {
|
|
223
|
+
...FONT.body,
|
|
224
|
+
leading: 17,
|
|
225
|
+
fill: t.fg1
|
|
226
|
+
}).children ?? []);
|
|
227
|
+
if (ticket.length) {
|
|
228
|
+
const text = ctx.textLines(cardX + cardPad, metaY, ticket, FONT.label);
|
|
229
|
+
const href = typeof config.ticketBaseUrl === "string" && config.ticketBaseUrl.replaceAll("#TICKET#", () => encodeURIComponent(card.ticket));
|
|
230
|
+
const safe = href && /^https?:\/\//i.test(href) && safeHref(href);
|
|
231
|
+
if (safe && !card.link) children.push(ctx.link(safe, [text]));
|
|
232
|
+
else {
|
|
233
|
+
children.push(text);
|
|
234
|
+
if (href && !safe && !errors.some((d) => d.code === "IGNORED_INTERACTION")) errors.push(warning("IGNORED_INTERACTION", ctx.lang, card.line, "工单链接未启用", "Ticket links are unavailable", "使用安全的 HTTP(S) 工单地址", "Use a safe HTTP(S) ticket URL"));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
children.push(...ctx.textLines(cardX + cardWidth - cardPad, metaY + (shared ? 0 : ticket.length * 16), assigned, {
|
|
238
|
+
...FONT.label,
|
|
239
|
+
anchor: "end"
|
|
240
|
+
}).children ?? []);
|
|
241
|
+
if (card.link) children.push(ctx.link(card.link.href, children.splice(first), card.link));
|
|
242
|
+
y += h + 8;
|
|
243
|
+
});
|
|
244
|
+
return {
|
|
245
|
+
x,
|
|
246
|
+
h: y - top + inset - (column.cards.length ? 8 : 0)
|
|
247
|
+
};
|
|
248
|
+
});
|
|
249
|
+
const h = Math.max(...frames.map((f) => f.h));
|
|
250
|
+
children.unshift(...frames.map(({ x }, i) => ctx.rect(x, top, colWidth, h, {
|
|
251
|
+
rx: 6,
|
|
252
|
+
stroke: ctx.frameTone(t[columns[i].status] || t.line),
|
|
253
|
+
fill: "transparent",
|
|
254
|
+
meta: {
|
|
255
|
+
kind: "frame",
|
|
256
|
+
id: `column:${i}`
|
|
257
|
+
}
|
|
258
|
+
})));
|
|
259
|
+
const height = top + h + pad;
|
|
260
|
+
if (w > width * 2 || count > 60) errors.push(warning("LARGE_DIAGRAM", ctx.lang, info.headerLine || 1, "看板较大", "Large kanban board", "考虑拆分图表", "Consider splitting the diagram"));
|
|
261
|
+
return {
|
|
262
|
+
width: w,
|
|
263
|
+
height,
|
|
264
|
+
scene: {
|
|
265
|
+
width: w,
|
|
266
|
+
height,
|
|
267
|
+
children,
|
|
268
|
+
title,
|
|
269
|
+
heading: title
|
|
270
|
+
},
|
|
271
|
+
errors
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
var implementations = { kanban: {
|
|
275
|
+
parse,
|
|
276
|
+
layout,
|
|
277
|
+
honoredConfig,
|
|
278
|
+
acceptsPresentation: true
|
|
279
|
+
} };
|
|
280
|
+
export { implementations, kanban_exports };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { resolveIconRef } from "../core/icons.js";
|
|
3
|
+
import { warning } from "./support.js";
|
|
4
|
+
import { stripEmphasis } from "./emphasis.js";
|
|
5
|
+
// src/diagram/label.js
|
|
6
|
+
var label_exports = /* @__PURE__ */ __exportAll({ normalizeLabel: () => normalizeLabel });
|
|
7
|
+
var entities = new Map(`AElig:c6 Aacute:c1 Acirc:c2 Agrave:c0 Alpha:391 Aring:c5 Atilde:c3 Auml:c4 Beta:392 Ccedil:c7 Chi:3a7 Dagger:2021 Delta:394 ETH:d0 Eacute:c9 Ecirc:ca Egrave:c8 Epsilon:395 Eta:397 Euml:cb Gamma:393 Iacute:cd Icirc:ce Igrave:cc Iota:399 Iuml:cf Kappa:39a Lambda:39b Mu:39c Ntilde:d1 Nu:39d OElig:152 Oacute:d3 Ocirc:d4 Ograve:d2 Omega:3a9 Omicron:39f Oslash:d8 Otilde:d5 Ouml:d6 Phi:3a6 Pi:3a0 Prime:2033 Psi:3a8 Rho:3a1 Scaron:160 Sigma:3a3 THORN:de Tau:3a4 Theta:398 Uacute:da Ucirc:db Ugrave:d9 Upsilon:3a5 Uuml:dc Xi:39e Yacute:dd Yuml:178 Zeta:396
|
|
8
|
+
aacute:e1 acirc:e2 acute:b4 aelig:e6 agrave:e0 alefsym:2135 alpha:3b1 amp:26 and:2227 ang:2220 apos:27 aring:e5 asymp:2248 atilde:e3 auml:e4 bdquo:201e beta:3b2 brvbar:a6 bull:2022 cap:2229 ccedil:e7 cedil:b8 cent:a2 chi:3c7 circ:2c6 clubs:2663 cong:2245 copy:a9 crarr:21b5 cup:222a curren:a4 dArr:21d3 dagger:2020 darr:2193 deg:b0 delta:3b4 diams:2666 divide:f7 eacute:e9 ecirc:ea egrave:e8 empty:2205 emsp:2003 ensp:2002 epsilon:3b5 equiv:2261 eta:3b7 eth:f0 euml:eb euro:20ac exist:2203 fnof:192 forall:2200 frac12:bd frac14:bc frac34:be frasl:2044 gamma:3b3 ge:2265 gt:3e hArr:21d4 harr:2194 hearts:2665 hellip:2026 iacute:ed icirc:ee iexcl:a1 igrave:ec image:2111 infin:221e int:222b iota:3b9 iquest:bf isin:2208 iuml:ef kappa:3ba lArr:21d0 lambda:3bb lang:27e8 laquo:ab larr:2190 lceil:2308 ldquo:201c le:2264 lfloor:230a lowast:2217 loz:25ca lrm:200e lsaquo:2039 lsquo:2018 lt:3c macr:af mdash:2014 micro:b5 middot:b7 minus:2212 mu:3bc nabla:2207 nbsp:a0 ndash:2013 ne:2260 ni:220b not:ac notin:2209 nsub:2284 ntilde:f1 nu:3bd oacute:f3 ocirc:f4 oelig:153 ograve:f2 oline:203e omega:3c9 omicron:3bf oplus:2295 or:2228 ordf:aa ordm:ba oslash:f8 otilde:f5 otimes:2297 ouml:f6 para:b6 part:2202 permil:2030 perp:22a5 phi:3c6 pi:3c0 piv:3d6 plusmn:b1 pound:a3 prime:2032 prod:220f prop:221d psi:3c8 quot:22 rArr:21d2 radic:221a rang:27e9 raquo:bb rarr:2192 rceil:2309 rdquo:201d real:211c reg:ae rfloor:230b rho:3c1 rlm:200f rsaquo:203a rsquo:2019 sbquo:201a scaron:161 sdot:22c5 sect:a7 shy:ad sigma:3c3 sigmaf:3c2 sim:223c spades:2660 sub:2282 sube:2286 sum:2211 sup:2283 sup1:b9 sup2:b2 sup3:b3 supe:2287 szlig:df tau:3c4 there4:2234 theta:3b8 thetasym:3d1 thinsp:2009 thorn:fe tilde:2dc times:d7 trade:2122 uArr:21d1 uacute:fa uarr:2191 ucirc:fb ugrave:f9 uml:a8 upsih:3d2 upsilon:3c5 uuml:fc weierp:2118 xi:3be yacute:fd yen:a5 yuml:ff zeta:3b6 zwj:200d zwnj:200c
|
|
9
|
+
AMP:26 LT:3c GT:3e QUOT:22 COPY:a9 REG:ae NewLine:a Tab:9 num:23 colon:3a semi:3b sol:2f bsol:5c dollar:24 check:2713 checkmark:2713 cross:2717 star:2606 starf:2605 RightArrow:2192 LeftArrow:2190`.split(/\s+/).map((entry) => {
|
|
10
|
+
const [name, hex] = entry.split(":");
|
|
11
|
+
return [name, Number.parseInt(hex, 16)];
|
|
12
|
+
}));
|
|
13
|
+
var decode = (value) => value.replace(/(?:&#([0-9]+|[xX][\da-fA-F]+)|#([0-9]+)|[&#]([a-zA-Z][a-zA-Z\d]*));/g, (raw, html, mermaid, name) => {
|
|
14
|
+
const number = html ?? mermaid;
|
|
15
|
+
const cp = name ? entities.get(name) : /^[xX]/.test(number) ? Number.parseInt(number.slice(1), 16) : Number(number);
|
|
16
|
+
if (cp === void 0) return raw;
|
|
17
|
+
return !cp || cp > 1114111 || cp >= 55296 && cp <= 57343 ? "�" : String.fromCodePoint(cp);
|
|
18
|
+
});
|
|
19
|
+
var html = /<\/?(br|img|b|i|u|em|strong|small|sup|sub|span|code|mark|font|s|del|ins|kbd|a)(?=[\s/>])(?:"[^"]*"|'[^']*'|[^<>"'])*>/gi;
|
|
20
|
+
var iconToken = /(?<![\w:-])fa[bsrlk]?:fa-[a-z\d]+(?:-[a-z\d]+)*/gi;
|
|
21
|
+
function normalizeLabel(raw, { lang, line = 1 } = {}) {
|
|
22
|
+
const diagnostics = [], subjects = /* @__PURE__ */ new Set();
|
|
23
|
+
let icon = null, sawIcon = false;
|
|
24
|
+
const warn = (subject, zh, en) => {
|
|
25
|
+
if (subjects.has(subject)) return;
|
|
26
|
+
subjects.add(subject);
|
|
27
|
+
diagnostics.push(warning("IGNORED_ASSET", lang, line, zh, en, "改用纯文本或内置图标", "Use plain text or a supported icon"));
|
|
28
|
+
};
|
|
29
|
+
let source = String(raw ?? "");
|
|
30
|
+
const markdown = /^(?:"`([\s\S]*)`"|`([\s\S]*)`)$/.exec(source);
|
|
31
|
+
if (markdown) source = stripEmphasis(markdown[1] ?? markdown[2]);
|
|
32
|
+
return {
|
|
33
|
+
text: source.split(/(\$\$[\s\S]*?\$\$)/).map((part, index) => {
|
|
34
|
+
if (index % 2) {
|
|
35
|
+
warn("math", "数学公式保留为 TeX 文本", "Math shown as TeX source");
|
|
36
|
+
return part.slice(2, -2);
|
|
37
|
+
}
|
|
38
|
+
return decode(part.replace(html, (_, tag) => {
|
|
39
|
+
tag = tag.toLowerCase();
|
|
40
|
+
if (tag === "img") warn("image", "已移除标签中的图片", "Removed an image from the label");
|
|
41
|
+
return tag === "br" ? "\n" : "";
|
|
42
|
+
})).replace(iconToken, (ref) => {
|
|
43
|
+
const resolved = resolveIconRef(ref);
|
|
44
|
+
if (!sawIcon) {
|
|
45
|
+
icon = resolved;
|
|
46
|
+
sawIcon = true;
|
|
47
|
+
}
|
|
48
|
+
if (!resolved) warn(ref.toLowerCase(), `未知图标 ${ref}`, `Unknown icon ${ref}`);
|
|
49
|
+
return "";
|
|
50
|
+
});
|
|
51
|
+
}).join("").replace(/^[ \t]+|[ \t]+$/g, ""),
|
|
52
|
+
icon,
|
|
53
|
+
diagnostics
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export { label_exports, normalizeLabel };
|