@openbkn/workshop 0.2.2-rc.5 → 0.2.2-rc.6
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 +79 -8
- package/component.d.ts +10 -0
- package/dist/ActionConfirm-DJ91X3ml.js +236 -0
- package/dist/ActionFailure-ZgPt_3B-.js +37 -0
- package/dist/AgentChat-CRYai8ge.js +1062 -0
- package/dist/AppFormModal-D73ucaHK.js +4282 -0
- package/dist/AppListPage-D87piiOw.js +1364 -0
- package/dist/AskDrawer-BUMYsRnt.js +38 -0
- package/dist/ComputedView-CgYrDbx1.js +3221 -0
- package/dist/ConclusionApply-sjGfoEBY.js +153 -0
- package/dist/CypherEditor-lus6FA5L.js +485 -0
- package/dist/LandingList-6JI6864C.js +230 -0
- package/dist/MenuUnfoldOutlined-Cdg24l2h.js +27 -0
- package/dist/ModelTrial-ClHFGTpQ.js +359 -0
- package/dist/PageRenderer-DBd_g6mN.js +85480 -0
- package/dist/README-DjRyTQSR.js +76 -0
- package/dist/ScenarioApply-DtW_hh47.js +590 -0
- package/dist/SimulateForm-C-i08Jjd.js +153 -0
- package/dist/Subgraph-CnrkH9AN.js +32586 -0
- package/dist/WorkshopLabPage-DiVXQL9e.js +11364 -0
- package/dist/WorkshopRunPage-6hjRUf64.js +253 -0
- package/dist/abnfDiagram-WEYOIA3C-beRNhN3c.js +87 -0
- package/dist/action-type-tool.service-B2B74fKC.js +1060 -0
- package/dist/actionButton-DA5CNEzx.js +94 -0
- package/dist/actionButton.en-US-qjeqA7hs.js +94 -0
- package/dist/agentChat-EoDznd58.js +116 -0
- package/dist/agentChat.en-US-B6-pFd9Y.js +116 -0
- package/dist/alertList-DqditwM8.js +84 -0
- package/dist/alertList.en-US-BAXAgltP.js +84 -0
- package/dist/architectureDiagram-ZHVYKT53-DY2l1qxx.js +4779 -0
- package/dist/asOfSlider-QPvHWUMV.js +83 -0
- package/dist/asOfSlider.en-US-BI4jVfSn.js +83 -0
- package/dist/bkn-agent-execution.service-DVh-SHyl.js +205 -0
- package/dist/blockDiagram-RJAE7QA3-DR0mjN2h.js +1435 -0
- package/dist/c4Diagram-XDPPPE54-DH5zsGug.js +1518 -0
- package/dist/channel-B034hcOF.js +5 -0
- package/dist/china-C6m7zXIv.js +9 -0
- package/dist/chunk-2E7WHVMD-Ba3svxgx.js +664 -0
- package/dist/chunk-2Q5K7J3B-rT4eU6_y.js +15 -0
- package/dist/chunk-4EMNKR2T-C1kQZYHK.js +262 -0
- package/dist/chunk-55XCU76K-dcpLOktb.js +68 -0
- package/dist/chunk-5VM5RSS4-BdpQuzmO.js +19 -0
- package/dist/chunk-JWPE2WC7-CDBrSjU7.js +8 -0
- package/dist/chunk-VQ5W62QI-BiVKc40w.js +19 -0
- package/dist/chunk-XXDRQBXY-CPYrcdVW.js +8 -0
- package/dist/chunk-ZCHMQSOR-BG8OLpvb.js +451 -0
- package/dist/classDiagram-v2-4MYWR3UA-DqbpQpwI.js +1564 -0
- package/dist/component.d-DFoMKuUv.js +179 -0
- package/dist/cose-bilkent-JH36ORCC-CdXk4sPf.js +2609 -0
- package/dist/customComponents-DasaZ6pq.js +4 -0
- package/dist/customComponents.en-US-CkabuCXg.js +79 -0
- package/dist/customParseFormat-C0uLEpdq.js +182 -0
- package/dist/cynefin-EF2NZ3EQ-D7MVnMHu.js +21746 -0
- package/dist/cynefinDiagram-WF24UDRP-BYT_KpDL.js +299 -0
- package/dist/cytoscape.esm-BCV9V6aO.js +18760 -0
- package/dist/d3-scale-DA8IHmf0.js +1841 -0
- package/dist/dagre-NK4GIZVX-l-ghPdM8.js +2154 -0
- package/dist/dateRange-BbkLMg8L.js +79 -0
- package/dist/dateRange.en-US-CV12Q02G.js +79 -0
- package/dist/dayjs.min-DZ-YV8Mv.js +284 -0
- package/dist/diagram-CBK3MWTC-Bt3HiwvA.js +542 -0
- package/dist/diagram-I5XIIV2D-DcbqfBjx.js +150 -0
- package/dist/diagram-ODIL2UCW-9PC1n3n5.js +346 -0
- package/dist/diagram-PFBEJUXE-DGhr2kc7.js +478 -0
- package/dist/diagram-RJA3I4VV-DwzpOjZ_.js +219 -0
- package/dist/diagram-TYUNFSNR-B3Bd3TDU.js +2583 -0
- package/dist/dropdownFilter-DOi_8-ZT.js +76 -0
- package/dist/dropdownFilter.en-US-BiXpvXtF.js +76 -0
- package/dist/ebnfDiagram-V4P3TTPT-E5NN2oKc.js +109 -0
- package/dist/elk-QONTBCTQ-dFjcujl_.js +49170 -0
- package/dist/erDiagram-KYQIGQAA-BMrasBzB.js +1061 -0
- package/dist/eventList-CnsAwfDS.js +115 -0
- package/dist/eventList.en-US-Cof3rCLq.js +115 -0
- package/dist/eventReport-XS-HegnH.js +76 -0
- package/dist/eventReport.en-US-DTx4vzWT.js +76 -0
- package/dist/flowDiagram-IUGLLWBU-BGIBH0q0.js +1769 -0
- package/dist/ganttChart-DEeSvTJA.js +77 -0
- package/dist/ganttChart.en-US-SwRKrnoD.js +77 -0
- package/dist/ganttDiagram-R7GPNTJY-C0tb1Lpp.js +1741 -0
- package/dist/generateCypher-Ch9_lQa6.js +399 -0
- package/dist/gitGraphDiagram-PDYL7XHY-DBqcOa-c.js +815 -0
- package/dist/graph-CKJmgLki.js +1541 -0
- package/dist/index-BA-GzCXt.js +441 -0
- package/dist/infoDiagram-MVDRKAX5-Bwuki4JA.js +24 -0
- package/dist/ishikawaDiagram-HPEHV2GE-Dz4d6ygx.js +622 -0
- package/dist/journeyDiagram-BOSHW7O7-C99m34Bb.js +834 -0
- package/dist/kanban-definition-FNSA4HC5-mdqjODsT.js +724 -0
- package/dist/katex-BsrBVQKd.js +11314 -0
- package/dist/manifest-BjV1PJ6u.js +41 -0
- package/dist/mermaid.core-yQghUlIz.js +17642 -0
- package/dist/metricCards-CSb-_cT2.js +104 -0
- package/dist/metricCards.en-US-BLLhRsQU.js +104 -0
- package/dist/mindmap-definition-6OY57UG3-BZhO2wX4.js +834 -0
- package/dist/modelTrial-Bvb-RhGt.js +137 -0
- package/dist/modelTrial.en-US-DYcuor-G.js +137 -0
- package/dist/models-DekiCOuZ.js +6 -0
- package/dist/object-metric-numeric-vs3BeDkH.js +42 -0
- package/dist/object-metric.service-flZgBMRX.js +233 -0
- package/dist/objectDetail-SQUbp4Py.js +117 -0
- package/dist/objectDetail.en-US-DW3mlONM.js +117 -0
- package/dist/objectList-D99wPtJH.js +97 -0
- package/dist/objectList.en-US-PBBNyVLW.js +97 -0
- package/dist/objectTable-0jsFFMN3.js +127 -0
- package/dist/objectTable.en-US-yWEs8qc_.js +127 -0
- package/dist/pegDiagram-ECIUJNBX-BDa5RfZt.js +95 -0
- package/dist/pieDiagram-GNMPY74T-DNVtzXPv.js +165 -0
- package/dist/pivotTable-CHmQw18-.js +102 -0
- package/dist/pivotTable.en-US-B4uv4P08.js +102 -0
- package/dist/prompt-DYrjlEFr.js +373 -0
- package/dist/quadrantDiagram-D57K4MC3-vK0f2OvQ.js +1023 -0
- package/dist/railroadDiagram-Y72NRBL7-j6ZrTmRp.js +77 -0
- package/dist/regionMap-Cme-JyV_.js +128 -0
- package/dist/regionMap.en-US-Bwr2_p32.js +128 -0
- package/dist/requirementDiagram-EQYSW5RA-DgfEyljA.js +886 -0
- package/dist/sankeyDiagram-SY24JHO5-CImx-IX0.js +1160 -0
- package/dist/scenarioBar-BV43p7n-.js +122 -0
- package/dist/scenarioBar.en-US-5KqMQ2Bg.js +122 -0
- package/dist/scheduleGantt-CTYO-zYP.js +180 -0
- package/dist/scheduleGantt.en-US-hE7mvVUW.js +180 -0
- package/dist/searchBox-Ca7w0f_6.js +67 -0
- package/dist/searchBox.en-US-ArS_XBvB.js +67 -0
- package/dist/segmentedFilter-MhjVcWo0.js +80 -0
- package/dist/segmentedFilter.en-US-BxNrQO5T.js +80 -0
- package/dist/sequenceDiagram-BLEHNHQU-nWmjd1ci.js +2969 -0
- package/dist/sizeCapture-INFHLROL-D3jlbt7h.js +46 -0
- package/dist/stageChain-BxBafwjD.js +74 -0
- package/dist/stageChain.en-US-CP0G27n8.js +74 -0
- package/dist/stateDiagram-v2-A6IESKWZ-DG1ZetEu.js +1514 -0
- package/dist/subgraph-7n4SwliR.js +71 -0
- package/dist/subgraph.en-US-BNvY18IW.js +71 -0
- package/dist/swimlanes-B3ENRKFQ-cCmJE8AU.js +4991 -0
- package/dist/swimlanesDiagram-AYQRV4AK-CtuhyguU.js +14 -0
- package/dist/taskInbox-DGWYeI2b.js +118 -0
- package/dist/taskInbox.en-US-B-OzDmVl.js +118 -0
- package/dist/text-BqSVQKS6.js +78 -0
- package/dist/text.en-US-BhAxy_LE.js +78 -0
- package/dist/timeline-definition-JXYKGLGB-Cc-INsOv.js +1057 -0
- package/dist/trendChart-BjEeRS5_.js +135 -0
- package/dist/trendChart.en-US-BBGqWUKM.js +135 -0
- package/dist/useLabData-Df-jEHKs.js +20470 -0
- package/dist/usecaseDiagram-WPOLBNNX-r8wVjopm.js +7920 -0
- package/dist/vennDiagram-Q3Y3IDCW-BZiOcgrj.js +1579 -0
- package/dist/wardleyDiagram-IVAIDKWA-16jd07C_.js +675 -0
- package/dist/workshop-app-DnHNjBqy.js +86038 -0
- package/dist/workshop-app.css +1 -0
- package/dist/workshop-app.js +4 -0
- package/dist/world-Djau1JyJ.js +9 -0
- package/dist/xychartDiagram-4URNHDU4-C8DwWQNh.js +1460 -0
- package/dist-cli/workshop.js +340 -217
- package/example/host.js +109 -0
- package/example/index.html +93 -0
- package/example/server.mjs +237 -0
- package/index.d.ts +48 -0
- package/lib/validate.js +47 -1
- package/package.json +17 -5
- package/runtime/frame-runtime.js +13 -1
- package/workshop-component.js +32 -12
- package/workshop.js +2 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
const e = `// Copyright openbkn.ai. All rights reserved.
|
|
2
|
+
// Proprietary — OpenBKN Enterprise Edition. See LICENSE in the repository root.
|
|
3
|
+
|
|
4
|
+
// 供应商风险矩阵:Workshop 自定义组件示例(契约见 design/custom-components.md)。
|
|
5
|
+
// 不依赖任何库:自定义元素 + Shadow DOM + SVG。
|
|
6
|
+
|
|
7
|
+
const TEXT = {
|
|
8
|
+
"zh-CN": {
|
|
9
|
+
x: "延期概率",
|
|
10
|
+
y: "影响金额(万元)",
|
|
11
|
+
hh: "重点关注",
|
|
12
|
+
hl: "常见延期",
|
|
13
|
+
lh: "潜在风险",
|
|
14
|
+
ll: "稳定",
|
|
15
|
+
empty: "没有数据",
|
|
16
|
+
missing: "数据源缺少字段:",
|
|
17
|
+
truncated: (n) => \`只显示前 \${n} 条\`,
|
|
18
|
+
pick: "点一个气泡,查看该供应商的超期订单",
|
|
19
|
+
pickOff: "构建与预览中点击不联动;切到运行模式(run)再试",
|
|
20
|
+
loading: "正在查询超期订单…",
|
|
21
|
+
noOrders: "没有超期订单",
|
|
22
|
+
orders: (name, n) => \`\${name} 的超期订单(\${n})\`,
|
|
23
|
+
urgent: "加急",
|
|
24
|
+
urgentDone: "已受理",
|
|
25
|
+
urgentPending: "待审批",
|
|
26
|
+
urgentOff: "构建中不可执行",
|
|
27
|
+
denied: "没有权限查询订单",
|
|
28
|
+
failed: "查询失败",
|
|
29
|
+
due: "交期",
|
|
30
|
+
summary: (q, sel) =>
|
|
31
|
+
\`风险矩阵:重点关注 \${q.hh.length} 家(\${q.hh.join("、") || "无"}),常见延期 \${q.hl.length} 家,潜在风险 \${q.lh.length} 家,稳定 \${q.ll.length} 家。\` +
|
|
32
|
+
(sel ? \`已选中 \${sel.name},列出 \${sel.count} 张超期订单。\` : "未选中供应商。"),
|
|
33
|
+
},
|
|
34
|
+
"en-US": {
|
|
35
|
+
x: "Delay probability",
|
|
36
|
+
y: "Impact (10k CNY)",
|
|
37
|
+
hh: "Watch closely",
|
|
38
|
+
hl: "Frequent delays",
|
|
39
|
+
lh: "Latent risk",
|
|
40
|
+
ll: "Stable",
|
|
41
|
+
empty: "No data",
|
|
42
|
+
missing: "The source is missing fields: ",
|
|
43
|
+
truncated: (n) => \`Showing the first \${n}\`,
|
|
44
|
+
pick: "Click a bubble to list the supplier's overdue orders",
|
|
45
|
+
pickOff: "Clicks do nothing while building or previewing; switch to run mode",
|
|
46
|
+
loading: "Loading overdue orders…",
|
|
47
|
+
noOrders: "No overdue orders",
|
|
48
|
+
orders: (name, n) => \`Overdue orders of \${name} (\${n})\`,
|
|
49
|
+
urgent: "Expedite",
|
|
50
|
+
urgentDone: "Submitted",
|
|
51
|
+
urgentPending: "Awaiting approval",
|
|
52
|
+
urgentOff: "Not available while building",
|
|
53
|
+
denied: "No permission to read orders",
|
|
54
|
+
failed: "Query failed",
|
|
55
|
+
due: "Due",
|
|
56
|
+
summary: (q, sel) =>
|
|
57
|
+
\`Risk matrix: \${q.hh.length} to watch closely (\${q.hh.join(", ") || "none"}), \${q.hl.length} with frequent delays, \${q.lh.length} latent, \${q.ll.length} stable. \` +
|
|
58
|
+
(sel ? \`\${sel.name} is selected with \${sel.count} overdue orders.\` : "No supplier selected."),
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const STYLE = \`
|
|
63
|
+
:host { display: block; height: 100%; color: var(--workshop-color-text, #1f2329);
|
|
64
|
+
font-family: var(--workshop-font-family, system-ui, sans-serif); font-size: var(--workshop-font-size, 14px); }
|
|
65
|
+
.root { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; height: 100%; box-sizing: border-box; padding: 8px; }
|
|
66
|
+
.root.narrow { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(260px, 1fr) auto; }
|
|
67
|
+
.chart { position: relative; min-height: 0; }
|
|
68
|
+
svg { width: 100%; height: 100%; display: block; overflow: visible; }
|
|
69
|
+
.axis { stroke: var(--workshop-color-border, #dee0e3); }
|
|
70
|
+
.axis-label, .tick { fill: var(--workshop-color-text-muted, #646a73); font-size: 12px; }
|
|
71
|
+
.quad-label { fill: var(--workshop-color-text-muted, #646a73); font-size: 12px; font-weight: 600; }
|
|
72
|
+
.quad { fill: var(--workshop-color-surface-alt, #f5f6f7); }
|
|
73
|
+
.bubble { cursor: pointer; fill-opacity: .55; stroke-width: 1.5; outline: none; transition: fill-opacity .15s; }
|
|
74
|
+
.bubble:hover, .bubble:focus-visible { fill-opacity: .8; }
|
|
75
|
+
.bubble.selected { fill-opacity: .9; stroke: var(--workshop-color-text, #1f2329); stroke-width: 2.5; }
|
|
76
|
+
.bubble.dim { fill-opacity: .2; }
|
|
77
|
+
.root.inert .bubble { cursor: default; }
|
|
78
|
+
.name { fill: var(--workshop-color-text, #1f2329); font-size: 12px; pointer-events: none; }
|
|
79
|
+
.side { border-left: 1px solid var(--workshop-color-border, #dee0e3); padding-left: 12px; overflow: auto; min-height: 0; }
|
|
80
|
+
.root.narrow .side { border-left: 0; border-top: 1px solid var(--workshop-color-border, #dee0e3); padding: 12px 0 0; }
|
|
81
|
+
.hint { color: var(--workshop-color-text-muted, #646a73); }
|
|
82
|
+
h3 { margin: 0 0 8px; font-size: 14px; }
|
|
83
|
+
ul { list-style: none; margin: 0; padding: 0; }
|
|
84
|
+
li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0;
|
|
85
|
+
border-bottom: 1px solid var(--workshop-color-border, #dee0e3); }
|
|
86
|
+
.order-id { font-weight: 600; }
|
|
87
|
+
.order-meta { color: var(--workshop-color-text-muted, #646a73); font-size: 12px; }
|
|
88
|
+
button { min-height: 32px; padding: 0 12px; border-radius: var(--workshop-radius, 6px); cursor: pointer;
|
|
89
|
+
border: 1px solid var(--workshop-color-primary, #1f6feb); background: transparent; color: var(--workshop-color-primary, #1f6feb); font: inherit; }
|
|
90
|
+
button:disabled { cursor: not-allowed; opacity: .5; }
|
|
91
|
+
.status { font-size: 12px; color: var(--workshop-color-success, #2ea121); white-space: nowrap; }
|
|
92
|
+
.note { position: absolute; left: 8px; bottom: 0; font-size: 12px; color: var(--workshop-color-text-muted, #646a73); }
|
|
93
|
+
.empty { display: grid; place-items: center; height: 100%; color: var(--workshop-color-text-muted, #646a73); }
|
|
94
|
+
@media (max-width: 600px) { li { min-height: 44px; } button { min-height: 44px; } }
|
|
95
|
+
\`;
|
|
96
|
+
|
|
97
|
+
const SVG = "http://www.w3.org/2000/svg";
|
|
98
|
+
|
|
99
|
+
class RiskMatrix extends HTMLElement {
|
|
100
|
+
#config = {};
|
|
101
|
+
#data = null;
|
|
102
|
+
#variables = {};
|
|
103
|
+
#theme = {};
|
|
104
|
+
#locale = "zh-CN";
|
|
105
|
+
#mode = "run";
|
|
106
|
+
#orders = { supplierId: null, state: "idle", rows: [], error: "" };
|
|
107
|
+
#acted = new Map(); // 订单编号 -> 状态(文案键)
|
|
108
|
+
#queued = false;
|
|
109
|
+
#observer;
|
|
110
|
+
#size = { w: 0, h: 0 };
|
|
111
|
+
#lastDescribed = "";
|
|
112
|
+
|
|
113
|
+
constructor() {
|
|
114
|
+
super();
|
|
115
|
+
const root = this.attachShadow({ mode: "open" });
|
|
116
|
+
const style = document.createElement("style");
|
|
117
|
+
style.textContent = STYLE;
|
|
118
|
+
this.box = document.createElement("div");
|
|
119
|
+
this.box.className = "root";
|
|
120
|
+
root.append(style, this.box);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// 输入属性:设置时只记下并排一次渲染,不重建组件。
|
|
124
|
+
set config(v) { this.#config = v ?? {}; this.#schedule(); }
|
|
125
|
+
set data(v) {
|
|
126
|
+
this.#data = v;
|
|
127
|
+
// 数据先于或晚于选中到达都要能下钻。
|
|
128
|
+
const id = this.#selectedId();
|
|
129
|
+
if (id !== this.#orders.supplierId) this.#loadOrders(id, this.#variables.selection?.objectType);
|
|
130
|
+
this.#schedule();
|
|
131
|
+
}
|
|
132
|
+
set theme(v) { this.#theme = v ?? {}; this.#schedule(); }
|
|
133
|
+
set locale(v) { this.#locale = TEXT[v] ? v : "zh-CN"; this.#schedule(); }
|
|
134
|
+
set mode(v) { this.#mode = v ?? "run"; this.#schedule(); }
|
|
135
|
+
set variables(v) {
|
|
136
|
+
this.#variables = v ?? {};
|
|
137
|
+
// 选中状态由页面持有:页面的选中对象筛选变了,就跟着查订单。
|
|
138
|
+
const id = this.#selectedId();
|
|
139
|
+
if (id !== this.#orders.supplierId) this.#loadOrders(id, this.#variables.selection?.objectType);
|
|
140
|
+
this.#schedule();
|
|
141
|
+
}
|
|
142
|
+
get config() { return this.#config; }
|
|
143
|
+
get data() { return this.#data; }
|
|
144
|
+
|
|
145
|
+
connectedCallback() {
|
|
146
|
+
this.#observer = new ResizeObserver(([entry]) => {
|
|
147
|
+
const { width, height } = entry.contentRect;
|
|
148
|
+
this.#size = { w: width, h: height };
|
|
149
|
+
this.#schedule();
|
|
150
|
+
});
|
|
151
|
+
this.#observer.observe(this);
|
|
152
|
+
this.#schedule();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
disconnectedCallback() {
|
|
156
|
+
this.#observer?.disconnect();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
#t() { return TEXT[this.#locale]; }
|
|
160
|
+
|
|
161
|
+
#schedule() {
|
|
162
|
+
if (this.#queued) return;
|
|
163
|
+
this.#queued = true;
|
|
164
|
+
queueMicrotask(() => { this.#queued = false; this.#render(); });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
#selectedId() {
|
|
168
|
+
const sel = this.#variables.selection;
|
|
169
|
+
// 只认数据源那个对象类的选中;对象类取自数据行,不写死。
|
|
170
|
+
const type = this.#data?.rows?.find((row) => row._object)?._object.type;
|
|
171
|
+
return sel && sel.objectType === type && sel.ids?.length ? sel.ids[0] : null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
#roles() {
|
|
175
|
+
const r = this.#config.fieldRoles ?? {};
|
|
176
|
+
return { label: r.label ?? "name", x: r.x ?? "x", y: r.y ?? "y", size: r.size ?? "size" };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
#points() {
|
|
180
|
+
const rows = this.#data?.rows ?? [];
|
|
181
|
+
const r = this.#roles();
|
|
182
|
+
return rows
|
|
183
|
+
.filter((row) => typeof row[r.x] === "number" && typeof row[r.y] === "number")
|
|
184
|
+
.map((row) => ({
|
|
185
|
+
id: row._object?.id ?? row[r.label],
|
|
186
|
+
objectType: row._object?.type,
|
|
187
|
+
name: String(row[r.label] ?? row._object?.id ?? ""),
|
|
188
|
+
x: row[r.x],
|
|
189
|
+
y: row[r.y],
|
|
190
|
+
size: typeof row[r.size] === "number" ? row[r.size] : 1,
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
#quadrant(p) {
|
|
195
|
+
const xt = this.#config.xThreshold ?? 0.5;
|
|
196
|
+
const yt = this.#config.yThreshold ?? 100;
|
|
197
|
+
return (p.x >= xt ? "h" : "l") + (p.y >= yt ? "h" : "l");
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
#color(q) {
|
|
201
|
+
const t = this.#theme;
|
|
202
|
+
return { hh: t.colorDanger ?? "#d83931", hl: t.colorWarning ?? "#de7802", lh: t.colorInfo ?? t.colorPrimary ?? "#1f6feb", ll: t.colorSuccess ?? "#2ea121" }[q];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// 用 workshop.query 自己再查一次:选中供应商的超期订单。对象类与关系来自配置,不写死。
|
|
206
|
+
async #loadOrders(supplierId, supplierType) {
|
|
207
|
+
this.#orders = { supplierId, state: supplierId ? "loading" : "idle", rows: [], error: "" };
|
|
208
|
+
this.#schedule();
|
|
209
|
+
if (!supplierId || !this.workshop) return;
|
|
210
|
+
const order = this.#config.orderObjectType ?? "purchase_order";
|
|
211
|
+
const rel = this.#config.supplierRelation ?? "supplied_by";
|
|
212
|
+
try {
|
|
213
|
+
const result = await this.workshop.query({
|
|
214
|
+
kind: "cypher",
|
|
215
|
+
// 是否超期由知识网络上订单的逻辑属性 overdue 判断,组件不自己比日期。
|
|
216
|
+
statement: \`MATCH (o:\\\`\${order}\\\`)-[:\\\`\${rel}\\\`]->(s:\\\`\${supplierType}\\\` {id: $id}) WHERE o.overdue = true RETURN o.id AS id, o.due_date AS due_date, o.amount AS amount ORDER BY o.due_date\`,
|
|
217
|
+
params: { id: supplierId },
|
|
218
|
+
});
|
|
219
|
+
if (this.#orders.supplierId !== supplierId) return; // 期间又换了选中
|
|
220
|
+
this.#orders = { supplierId, state: "done", rows: result.rows, error: "" };
|
|
221
|
+
} catch (err) {
|
|
222
|
+
if (this.#orders.supplierId !== supplierId) return;
|
|
223
|
+
const t = this.#t();
|
|
224
|
+
this.#orders = { supplierId, state: "error", rows: [], error: err.code === "forbidden" ? t.denied : t.failed };
|
|
225
|
+
}
|
|
226
|
+
this.#schedule();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
#select(p) {
|
|
230
|
+
if (this.#mode !== "run" || !p.objectType) return;
|
|
231
|
+
const same = this.#selectedId() === p.id;
|
|
232
|
+
// 再点同一个取消选中,与标准组件习惯一致。
|
|
233
|
+
this.dispatchEvent(new CustomEvent("workshop:select", {
|
|
234
|
+
bubbles: true, composed: true,
|
|
235
|
+
detail: { objectType: p.objectType, ids: same ? [] : [p.id] },
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async #expedite(orderId, button) {
|
|
240
|
+
button.disabled = true;
|
|
241
|
+
try {
|
|
242
|
+
const result = await this.workshop.act({
|
|
243
|
+
actionType: this.#config.urgentAction,
|
|
244
|
+
objects: [{ type: this.#config.orderObjectType ?? "purchase_order", id: orderId }],
|
|
245
|
+
params: { reason: this.#locale === "zh-CN" ? "供应商风险矩阵:重点关注" : "Supplier risk matrix: watch closely" },
|
|
246
|
+
});
|
|
247
|
+
this.#acted.set(orderId, result.status === "pending_approval" ? "urgentPending" : "urgentDone");
|
|
248
|
+
} catch (err) {
|
|
249
|
+
if (err.code !== "cancelled") this.#acted.set(orderId, "failed");
|
|
250
|
+
}
|
|
251
|
+
this.#schedule();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
#render() {
|
|
255
|
+
if (!this.isConnected) return;
|
|
256
|
+
const t = this.#t();
|
|
257
|
+
const points = this.#points();
|
|
258
|
+
// 整块重画,但保留键盘焦点与列表的滚动位置。
|
|
259
|
+
const focused = this.shadowRoot.activeElement?.dataset?.id;
|
|
260
|
+
const scroll = this.box.querySelector(".side")?.scrollTop ?? 0;
|
|
261
|
+
this.box.classList.toggle("narrow", this.#size.w > 0 && this.#size.w < 600);
|
|
262
|
+
this.box.classList.toggle("inert", this.#mode !== "run");
|
|
263
|
+
this.box.replaceChildren();
|
|
264
|
+
|
|
265
|
+
const r = this.#roles();
|
|
266
|
+
const keys = new Set((this.#data?.fields ?? []).map((f) => f.key));
|
|
267
|
+
const missing = this.#data ? [r.x, r.y].filter((k) => !keys.has(k)) : [];
|
|
268
|
+
if (!this.#data || !points.length) {
|
|
269
|
+
const empty = document.createElement("div");
|
|
270
|
+
empty.className = "empty";
|
|
271
|
+
empty.textContent = missing.length ? t.missing + missing.join(", ") : t.empty;
|
|
272
|
+
this.box.append(empty);
|
|
273
|
+
this.box.style.gridTemplateColumns = "1fr";
|
|
274
|
+
this.workshop?.describe({ summary: empty.textContent });
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
this.box.style.gridTemplateColumns = "";
|
|
278
|
+
|
|
279
|
+
const chart = document.createElement("div");
|
|
280
|
+
chart.className = "chart";
|
|
281
|
+
chart.append(this.#svg(points));
|
|
282
|
+
if (this.#data.truncated) {
|
|
283
|
+
const note = document.createElement("div");
|
|
284
|
+
note.className = "note";
|
|
285
|
+
note.textContent = t.truncated(this.#data.rows.length);
|
|
286
|
+
chart.append(note);
|
|
287
|
+
}
|
|
288
|
+
const side = this.#side(points);
|
|
289
|
+
this.box.append(chart, side);
|
|
290
|
+
side.scrollTop = scroll;
|
|
291
|
+
if (focused) this.box.querySelector(\`[data-id="\${CSS.escape(focused)}"]\`)?.focus();
|
|
292
|
+
this.#describe(points);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
#svg(points) {
|
|
296
|
+
const t = this.#t();
|
|
297
|
+
const narrow = this.#size.w > 0 && this.#size.w < 600;
|
|
298
|
+
const W = Math.max(280, narrow ? this.#size.w - 16 : this.#size.w - 290);
|
|
299
|
+
const H = Math.max(240, narrow ? Math.min(360, this.#size.h * 0.6) : this.#size.h - 16);
|
|
300
|
+
const pad = { l: 48, r: 12, t: 12, b: 36 };
|
|
301
|
+
const maxY = Math.max(this.#config.yThreshold ?? 100, ...points.map((p) => p.y)) * 1.1;
|
|
302
|
+
const maxS = Math.max(...points.map((p) => p.size), 1);
|
|
303
|
+
const sx = (v) => pad.l + v * (W - pad.l - pad.r);
|
|
304
|
+
const sy = (v) => H - pad.b - (v / maxY) * (H - pad.t - pad.b);
|
|
305
|
+
const xt = this.#config.xThreshold ?? 0.5;
|
|
306
|
+
const yt = this.#config.yThreshold ?? 100;
|
|
307
|
+
const selected = this.#selectedId();
|
|
308
|
+
|
|
309
|
+
const svg = el("svg", { viewBox: \`0 0 \${W} \${H}\`, role: "img", "aria-label": \`\${t.x} × \${t.y}\` });
|
|
310
|
+
// 四个象限:高概率高影响在右上。
|
|
311
|
+
const quads = [
|
|
312
|
+
["lh", sx(0), sy(maxY), sx(xt) - sx(0), sy(yt) - sy(maxY)],
|
|
313
|
+
["hh", sx(xt), sy(maxY), sx(1) - sx(xt), sy(yt) - sy(maxY)],
|
|
314
|
+
["ll", sx(0), sy(yt), sx(xt) - sx(0), sy(0) - sy(yt)],
|
|
315
|
+
["hl", sx(xt), sy(yt), sx(1) - sx(xt), sy(0) - sy(yt)],
|
|
316
|
+
];
|
|
317
|
+
for (const [q, x, y, w, h] of quads) {
|
|
318
|
+
svg.append(el("rect", { class: "quad", x, y, width: w, height: h, "fill-opacity": q === "hh" ? 1 : 0.5 }));
|
|
319
|
+
// 标签放在远离中心的外角,少与气泡重叠。
|
|
320
|
+
const right = q[0] === "h";
|
|
321
|
+
const top = q[1] === "h";
|
|
322
|
+
svg.append(el("text", {
|
|
323
|
+
class: "quad-label", x: right ? x + w - 8 : x + 8, y: top ? y + 18 : y + h - 8,
|
|
324
|
+
"text-anchor": right ? "end" : "start",
|
|
325
|
+
}, t[q]));
|
|
326
|
+
}
|
|
327
|
+
svg.append(el("line", { class: "axis", x1: sx(0), y1: sy(0), x2: sx(1), y2: sy(0) }));
|
|
328
|
+
svg.append(el("line", { class: "axis", x1: sx(0), y1: sy(0), x2: sx(0), y2: sy(maxY) }));
|
|
329
|
+
for (const v of [0, 0.25, 0.5, 0.75, 1]) {
|
|
330
|
+
svg.append(el("text", { class: "tick", x: sx(v), y: sy(0) + 16, "text-anchor": "middle" }, \`\${Math.round(v * 100)}%\`));
|
|
331
|
+
}
|
|
332
|
+
for (const v of [0, Math.round(maxY / 2), Math.round(maxY)]) {
|
|
333
|
+
svg.append(el("text", { class: "tick", x: pad.l - 6, y: sy(v) + 4, "text-anchor": "end" }, String(v)));
|
|
334
|
+
}
|
|
335
|
+
svg.append(el("text", { class: "axis-label", x: (sx(0) + sx(1)) / 2, y: H - 4, "text-anchor": "middle" }, t.x));
|
|
336
|
+
svg.append(el("text", { class: "axis-label", x: 12, y: (sy(0) + sy(maxY)) / 2, transform: \`rotate(-90 12 \${(sy(0) + sy(maxY)) / 2})\`, "text-anchor": "middle" }, t.y));
|
|
337
|
+
|
|
338
|
+
for (const p of [...points].sort((a, b) => b.size - a.size)) {
|
|
339
|
+
const q = this.#quadrant(p);
|
|
340
|
+
const radius = 6 + Math.sqrt(p.size / maxS) * 18;
|
|
341
|
+
const cls = ["bubble", selected === p.id ? "selected" : selected ? "dim" : ""].join(" ");
|
|
342
|
+
const c = el("circle", {
|
|
343
|
+
class: cls, cx: sx(p.x), cy: sy(p.y), r: radius, "data-id": p.id,
|
|
344
|
+
fill: this.#color(q), stroke: this.#color(q), tabindex: 0, role: "button",
|
|
345
|
+
"aria-label": \`\${p.name} \${Math.round(p.x * 100)}% \${p.y}\`,
|
|
346
|
+
});
|
|
347
|
+
c.append(el("title", {}, \`\${p.name}\\n\${t.x} \${Math.round(p.x * 100)}%\\n\${t.y} \${p.y}\`));
|
|
348
|
+
c.addEventListener("click", () => this.#select(p));
|
|
349
|
+
c.addEventListener("keydown", (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); this.#select(p); } });
|
|
350
|
+
svg.append(c);
|
|
351
|
+
svg.append(el("text", { class: "name", x: sx(p.x), y: sy(p.y) - radius - 4, "text-anchor": "middle" }, p.name));
|
|
352
|
+
}
|
|
353
|
+
return svg;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
#side(points) {
|
|
357
|
+
const t = this.#t();
|
|
358
|
+
const side = document.createElement("div");
|
|
359
|
+
side.className = "side";
|
|
360
|
+
const sel = points.find((p) => p.id === this.#selectedId());
|
|
361
|
+
const o = this.#orders;
|
|
362
|
+
if (!sel) {
|
|
363
|
+
side.append(text("div", this.#mode === "run" ? t.pick : t.pickOff, "hint"));
|
|
364
|
+
return side;
|
|
365
|
+
}
|
|
366
|
+
if (o.state === "loading") { side.append(text("div", t.loading, "hint")); return side; }
|
|
367
|
+
if (o.state === "error") { side.append(text("div", o.error, "hint")); return side; }
|
|
368
|
+
side.append(text("h3", t.orders(sel.name, o.rows.length)));
|
|
369
|
+
if (!o.rows.length) { side.append(text("div", t.noOrders, "hint")); return side; }
|
|
370
|
+
const list = document.createElement("ul");
|
|
371
|
+
const canAct = this.#mode === "run" && !!this.#config.urgentAction;
|
|
372
|
+
for (const row of o.rows) {
|
|
373
|
+
const li = document.createElement("li");
|
|
374
|
+
const info = document.createElement("div");
|
|
375
|
+
info.append(text("div", row.id, "order-id"), text("div", \`\${t.due} \${formatDate(row.due_date, this.#locale)} · \${formatNumber(row.amount, this.#locale)}\`, "order-meta"));
|
|
376
|
+
li.append(info);
|
|
377
|
+
if (this.#acted.has(row.id)) {
|
|
378
|
+
li.append(text("span", t[this.#acted.get(row.id)], "status"));
|
|
379
|
+
} else if (this.#config.urgentAction) {
|
|
380
|
+
const b = document.createElement("button");
|
|
381
|
+
b.textContent = t.urgent;
|
|
382
|
+
b.disabled = !canAct;
|
|
383
|
+
if (!canAct) b.title = t.urgentOff;
|
|
384
|
+
b.addEventListener("click", () => this.#expedite(row.id, b));
|
|
385
|
+
li.append(b);
|
|
386
|
+
}
|
|
387
|
+
list.append(li);
|
|
388
|
+
}
|
|
389
|
+
side.append(list);
|
|
390
|
+
return side;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// 让页面 Agent 看懂这张图:每次渲染后报告一次(内容没变就不重复报)。
|
|
394
|
+
#describe(points) {
|
|
395
|
+
const q = { hh: [], hl: [], lh: [], ll: [] };
|
|
396
|
+
for (const p of points) q[this.#quadrant(p)].push(p.name);
|
|
397
|
+
const sel = points.find((p) => p.id === this.#selectedId());
|
|
398
|
+
const state = {
|
|
399
|
+
summary: this.#t().summary(q, sel && this.#orders.state === "done" ? { name: sel.name, count: this.#orders.rows.length } : null),
|
|
400
|
+
details: {
|
|
401
|
+
quadrants: Object.fromEntries(Object.entries(q).map(([k, v]) => [k, v.length])),
|
|
402
|
+
watchClosely: q.hh,
|
|
403
|
+
selected: sel?.id ?? null,
|
|
404
|
+
overdueOrders: sel ? this.#orders.rows.map((r) => r.id) : [],
|
|
405
|
+
},
|
|
406
|
+
};
|
|
407
|
+
const key = JSON.stringify(state);
|
|
408
|
+
if (key === this.#lastDescribed) return;
|
|
409
|
+
this.#lastDescribed = key;
|
|
410
|
+
this.workshop?.describe(state);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function el(tag, attrs, content) {
|
|
415
|
+
const node = document.createElementNS(SVG, tag);
|
|
416
|
+
for (const [k, v] of Object.entries(attrs)) node.setAttribute(k, String(v));
|
|
417
|
+
if (content != null) node.textContent = content;
|
|
418
|
+
return node;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function text(tag, content, cls) {
|
|
422
|
+
const node = document.createElement(tag);
|
|
423
|
+
if (cls) node.className = cls;
|
|
424
|
+
node.textContent = content;
|
|
425
|
+
return node;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function formatDate(v, locale) {
|
|
429
|
+
const d = new Date(v);
|
|
430
|
+
return Number.isNaN(d.getTime()) ? String(v ?? "") : d.toLocaleDateString(locale);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function formatNumber(v, locale) {
|
|
434
|
+
return typeof v === "number" ? v.toLocaleString(locale) : "";
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
customElements.define("acme-risk-matrix", RiskMatrix);
|
|
438
|
+
`;
|
|
439
|
+
export {
|
|
440
|
+
e as default
|
|
441
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { _ as e, l as s, T as o, d as i } from "./mermaid.core-yQghUlIz.js";
|
|
2
|
+
import { p as g } from "./cynefin-EF2NZ3EQ-D7MVnMHu.js";
|
|
3
|
+
var d = {
|
|
4
|
+
parse: /* @__PURE__ */ e(async (r) => {
|
|
5
|
+
const a = await g("info", r);
|
|
6
|
+
s.debug(a);
|
|
7
|
+
}, "parse")
|
|
8
|
+
}, p = {
|
|
9
|
+
version: "12.2.0"
|
|
10
|
+
}, v = /* @__PURE__ */ e(() => p.version, "getVersion"), m = {
|
|
11
|
+
getVersion: v
|
|
12
|
+
}, c = /* @__PURE__ */ e((r, a, n) => {
|
|
13
|
+
s.debug(`rendering info diagram
|
|
14
|
+
` + r);
|
|
15
|
+
const t = o(a);
|
|
16
|
+
i(t, 100, 400, !0), t.append("g").append("text").attr("x", 100).attr("y", 40).attr("class", "version").attr("font-size", 32).style("text-anchor", "middle").text(`v${n}`);
|
|
17
|
+
}, "draw"), l = { draw: c }, _ = {
|
|
18
|
+
parser: d,
|
|
19
|
+
db: m,
|
|
20
|
+
renderer: l
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
_ as diagram
|
|
24
|
+
};
|