@beehexa/design-rules 2611.8.1 → 2611.9.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/dist/catalog.json +10 -10
- package/dist/docs/src/components/NativeFlowDemo.astro +26 -8
- package/dist/docs/src/content/tools/ant-design-vue-theme.mdx +3 -0
- package/dist/docs/src/content/tools/mermaid.mdx +5 -2
- package/dist/docs/src/content/tools/vueflow.mdx +27 -0
- package/dist/docs/src/content-vi/tools/ant-design-vue-theme.mdx +4 -1
- package/dist/docs/src/content-vi/tools/vueflow.mdx +24 -0
- package/dist/index.js +10 -10
- package/package.json +1 -1
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
<script>
|
|
4
4
|
import { computed, createApp, defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, useId, watch } from 'vue';
|
|
5
|
-
import { Alert, Button, ConfigProvider, Flex, Select, Space
|
|
5
|
+
import { Alert, Button, ConfigProvider, Flex, Select, Space } from 'ant-design-vue';
|
|
6
6
|
import mermaid from 'mermaid';
|
|
7
7
|
import { compactFlowGraph, compactFlowMermaid, flowStylesheet, type RenderGroup, type RenderOverlay } from '@beehexa/hexasync-template-model';
|
|
8
8
|
import { tokenPixels } from '@beehexa/design-tokens';
|
|
9
9
|
import { createAntDesignVueTheme, useAntDesignVueRootFontSize } from '@beehexa/ant-design-vue-tokens';
|
|
10
|
-
import { createCanvasTheme, createMermaidConfig, preserveMermaidDefinitionPaint, workerFlowSvgStyle } from '@beehexa/mermaid-tokens';
|
|
10
|
+
import { createCanvasTheme, createMermaidConfig, mermaidEvidenceStyles, preserveMermaidDefinitionPaint, workerFlowSvgStyle, type MermaidEdgeReading, type MermaidLogReading } from '@beehexa/mermaid-tokens';
|
|
11
11
|
import '@beehexa/ant-design-vue-tokens/css';
|
|
12
12
|
|
|
13
13
|
// One genuine native renderer and public model: no copied cards, paths or icon masks.
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
const rootFontSize = useAntDesignVueRootFontSize();
|
|
18
18
|
const dark = ref(document.documentElement.dataset.theme === 'dark');
|
|
19
19
|
const locale = ref<'en' | 'vi'>(document.documentElement.lang.startsWith('vi') ? 'vi' : 'en');
|
|
20
|
-
const execution = ref(
|
|
20
|
+
const execution = ref<'none' | 'typed' | 'log'>('none');
|
|
21
21
|
const direction = ref<'LR' | 'TD'>('TD');
|
|
22
22
|
const zoom = ref(100);
|
|
23
23
|
const selected = ref<string | null>(null);
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
sheet.textContent = flowStylesheet();
|
|
34
34
|
document.head.append(sheet);
|
|
35
35
|
const words = computed(() => locale.value === 'vi' ? {
|
|
36
|
-
title: 'Đồng bộ đơn hàng', run: '
|
|
36
|
+
title: 'Đồng bộ đơn hàng', run: 'Bằng chứng thực thi mẫu', none: 'Không có (định nghĩa)', typed: 'Kết quả có kiểu', log: 'Suy ra từ log', direction: 'Hướng luồng',
|
|
37
37
|
vertical: 'Dọc', horizontal: 'Ngang', reset: 'Đặt lại thu phóng', export: 'Xuất SVG gốc',
|
|
38
38
|
start: 'Bắt đầu', fetch: 'Đọc toàn bộ đơn hàng từ dịch vụ bên ngoài và giữ nguyên tiêu đề dài',
|
|
39
39
|
transform: 'Chuẩn hóa các trường đơn hàng', condition: 'Đơn hàng đã hợp lệ chưa?',
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
choose: 'Chọn một bước bằng chuột hoặc Enter/Space; dùng Tab để thấy vòng lấy nét độc lập.',
|
|
42
42
|
selected: 'Bước đã chọn', zoomIn: 'Phóng to', zoomOut: 'Thu nhỏ'
|
|
43
43
|
} : {
|
|
44
|
-
title: 'Order synchronization', run: '
|
|
44
|
+
title: 'Order synchronization', run: 'Sample execution evidence', none: 'None (definition)', typed: 'Typed outcomes', log: 'Log-derived readings', direction: 'Flow direction',
|
|
45
45
|
vertical: 'Vertical', horizontal: 'Horizontal', reset: 'Reset zoom', export: 'Export native SVG',
|
|
46
46
|
start: 'Start', fetch: 'Read all orders from the external service while retaining this complete wrapped title',
|
|
47
47
|
transform: 'Normalize order fields', condition: 'Is this order valid?',
|
|
@@ -75,6 +75,23 @@
|
|
|
75
75
|
condition: { state: 'ranOk' }, delay: { state: 'neverReached' },
|
|
76
76
|
finish: { state: 'branchNotTaken' }, failure: { state: 'ranFailed' }
|
|
77
77
|
} };
|
|
78
|
+
// Log-derived readings (no typed outcome): reached/unfinished nodes; reached/unfinished/failed edges.
|
|
79
|
+
const logNodes: Record<string, MermaidLogReading> = { start: 'reached', fetch: 'reached', normalize: 'unfinished' };
|
|
80
|
+
const logEdges: Record<string, MermaidEdgeReading> = { 'start>fetch': 'reached', 'fetch>normalize': 'unfinished', 'condition>failure': 'failed' };
|
|
81
|
+
const logEvidence = (graph: ReturnType<typeof compactFlowGraph>['graph'], options: { dark: boolean; locale: 'en' | 'vi' }) => {
|
|
82
|
+
// Compact ids are positional over the authored node order; linkStyle indices follow `graph.edges`.
|
|
83
|
+
const authored = groups()[0].nodes.map(node => node.address);
|
|
84
|
+
const address = new Map(graph.nodes.map((node, index) => [node.id, authored[index]] as const));
|
|
85
|
+
const nodes = new Map(graph.nodes.flatMap(node => {
|
|
86
|
+
const reading = logNodes[address.get(node.id) ?? ''];
|
|
87
|
+
return reading ? [[node.id, reading] as const] : [];
|
|
88
|
+
}));
|
|
89
|
+
const edgeReadings = new Map(graph.edges.flatMap((edge, index) => {
|
|
90
|
+
const reading = logEdges[`${address.get(edge.from)}>${address.get(edge.to)}`];
|
|
91
|
+
return reading ? [[index, reading] as const] : [];
|
|
92
|
+
}));
|
|
93
|
+
return mermaidEvidenceStyles(nodes, edgeReadings, options);
|
|
94
|
+
};
|
|
78
95
|
const select = (id: string) => {
|
|
79
96
|
selected.value = id;
|
|
80
97
|
for (const node of currentSvg?.querySelectorAll<SVGGElement>('g.node') ?? []) {
|
|
@@ -86,8 +103,9 @@
|
|
|
86
103
|
const render = () => {
|
|
87
104
|
const ticket = ++revision;
|
|
88
105
|
const options = { dark: dark.value, locale: locale.value };
|
|
89
|
-
const compact = compactFlowGraph(groups(), edges, { overlay: execution.value ? overlay : undefined });
|
|
90
|
-
const
|
|
106
|
+
const compact = compactFlowGraph(groups(), edges, { overlay: execution.value === 'typed' ? overlay : undefined });
|
|
107
|
+
const base = compactFlowMermaid(compact.graph, direction.value);
|
|
108
|
+
const definition = execution.value === 'log' ? `${base}\n${logEvidence(compact.graph, options)}` : base;
|
|
91
109
|
// Mermaid owns global initialization and measurement: serialize this page's demos.
|
|
92
110
|
renders = renders.then(async () => {
|
|
93
111
|
if (disposed || ticket !== revision) return;
|
|
@@ -180,7 +198,7 @@
|
|
|
180
198
|
h('p', { 'data-bh-font': 'body-small' }, words.value.choose),
|
|
181
199
|
h(Space, { wrap: true, size: tokenPixels('space.100', locale.value, rootFontSize.value), align: 'center' }, () => [
|
|
182
200
|
h('label', { for: `${controlId}-execution` }, words.value.run),
|
|
183
|
-
h(
|
|
201
|
+
h(Select, { id: `${controlId}-execution`, value: execution.value, options: [{ value: 'none', label: words.value.none }, { value: 'typed', label: words.value.typed }, { value: 'log', label: words.value.log }], 'onUpdate:value': (value: unknown) => { if (value === 'none' || value === 'typed' || value === 'log') execution.value = value; } }),
|
|
184
202
|
h('label', { for: `${controlId}-direction` }, words.value.direction),
|
|
185
203
|
h(Select, { id: `${controlId}-direction`, value: direction.value, options: [{ value: 'TD', label: words.value.vertical }, { value: 'LR', label: words.value.horizontal }], 'onUpdate:value': (value: unknown) => { if (value === 'TD' || value === 'LR') direction.value = value; } }),
|
|
186
204
|
h(Button, { disabled: zoom.value <= 50, onClick: () => { zoom.value -= 25; } }, () => words.value.zoomOut),
|
|
@@ -136,6 +136,9 @@ The companion CSS provides opt-in native structural contracts, not application s
|
|
|
136
136
|
AntD4 caches the first portal container. Nested scopes inherit the enclosing target.
|
|
137
137
|
Native ConfigProvider theme/locale, menus, focus and no-trigger body portals
|
|
138
138
|
remain native; no editor/model/graph rekey or global popup z-index is involved.
|
|
139
|
+
Opt-in `feedback` (default `false`) sends trigger-less containers to the mounted
|
|
140
|
+
scope host instead, so a `notification.useNotification()` / `message.useMessage()`
|
|
141
|
+
holder inside the scope follows the overlay owner into native fullscreen.
|
|
139
142
|
Fullscreen capture handlers yield menu/listbox Escape via
|
|
140
143
|
`isAntDesignVueMenuEvent(event)` before closing their own overlay.
|
|
141
144
|
Native Drawer portals can use the same stable host through the public scoped
|
|
@@ -11,8 +11,11 @@ import NativeFlowDemo from '../../components/NativeFlowDemo.astro';
|
|
|
11
11
|
<NativeFlowDemo />
|
|
12
12
|
|
|
13
13
|
This is the public native compact model rendered by Mermaid, not a set of HTML
|
|
14
|
-
lookalike cards.
|
|
15
|
-
|
|
14
|
+
lookalike cards. Set execution evidence to none to inspect the untouched definition,
|
|
15
|
+
to typed outcomes for `ranOk` / `ranFailed` / `neverReached` / `branchNotTaken` (the
|
|
16
|
+
edge into the not-taken branch is dashed `6 3`), or to log-derived readings for
|
|
17
|
+
`mermaidEvidenceStyles` node `reached` / `unfinished` and edge `reached` / `unfinished`
|
|
18
|
+
(dashed `4 3`) / `failed`. The run readings are explicitly sample data, not business-success claims.
|
|
16
19
|
Change the site theme/language, direction and zoom, select with a pointer or keyboard,
|
|
17
20
|
then export the actual SVG. Category masks, native shapes, edge labels and typed
|
|
18
21
|
state geometry survive those changes.
|
|
@@ -188,6 +188,33 @@ boundary is dashed. Selection, hover and keyboard focus stay on independent
|
|
|
188
188
|
outer-ring geometry, so a selected failed node remains visibly failed.
|
|
189
189
|
Repetition, logos and group disclosure remain domain metadata.
|
|
190
190
|
|
|
191
|
+
Log-derived node readings `reached` (a legacy log says the step ran, no typed outcome) and
|
|
192
|
+
`unfinished` (started, no recorded end) are not typed run outcomes. The companion paints them
|
|
193
|
+
with `diagram.log-reached` / `diagram.log-unfinished` as outline and marker ink
|
|
194
|
+
(`--wf-node-state-ink`); nodes keep an independent selection ring, so node `reached` keeps the
|
|
195
|
+
log role. `unfinished` leaves the node's own fill and text (including high-contrast overrides)
|
|
196
|
+
and dashes both the outline and the subroutine edge `4 3`. `--wf-node-execution-outline-width`
|
|
197
|
+
binds `border.width.focused` for `ranOk`, `ranFailed`, `reached` and `unfinished`, as Mermaid
|
|
198
|
+
draws them; `neverReached` / `branchNotTaken` keep the native default.
|
|
199
|
+
Never present either reading as `ranOk` or `ranFailed`.
|
|
200
|
+
|
|
201
|
+
Edge run evidence `WorkflowEdge.execution` (`reached`, `unfinished`, `failed`, `notTaken`) is
|
|
202
|
+
distinct from the authored failure route (`variant: 'failure'`) and from tone. Source binds:
|
|
203
|
+
|
|
204
|
+
- `reached` to `color.text`, not `diagram.log-reached`: that role and the edge highlight
|
|
205
|
+
(`--wf-edge-active`, `diagram.selection-ring`) are the same blue, so a resting walked edge
|
|
206
|
+
would look selected. Its non-colour cue is the bold `--wf-edge-execution-width`
|
|
207
|
+
(`border.width.focused`), like Mermaid's neutral walked edge.
|
|
208
|
+
- `unfinished` to `diagram.log-unfinished`, dashed `4 3`.
|
|
209
|
+
- `failed` to `diagram.fail-stroke`, with the circle-x failure mark.
|
|
210
|
+
- `notTaken` (a declined route) to `diagram.nottaken-stroke` at the ordinary width, dashed `6 3`.
|
|
211
|
+
|
|
212
|
+
`--wf-edge-execution-width` must be a CSS length. Execution ink wins over tone ink; the
|
|
213
|
+
`unfinished` / `notTaken` dash wins over tone and failure dashes, and a displaced authored
|
|
214
|
+
failure keeps its circle-x mark. The legend names each present reading and edge accessible
|
|
215
|
+
names append it (`Edge from A to B, run failed`). In high contrast `reached` shares the edge ink
|
|
216
|
+
(`color.text`) and is distinguished by width; the other readings keep their theme-resolved inks.
|
|
217
|
+
|
|
191
218
|
The real native live demo belongs to the
|
|
192
219
|
[`workflow-canvas` producer playground](https://github.com/hexasync-saas/workflow-canvas#native-source-anatomy-playground),
|
|
193
220
|
not a replacement renderer embedded here. In that checkout run
|
|
@@ -127,7 +127,10 @@ CSS đi kèm cung cấp các quy ước cấu trúc gốc tuỳ chọn, không p
|
|
|
127
127
|
sẵn có đó, không thay chỗ nó. Holder popup gốc ổn định di chuyển cùng owner vì AntD4 cache
|
|
128
128
|
container portal đầu tiên. Scope lồng nhau kế thừa đích bao ngoài. Theme/ngôn ngữ của
|
|
129
129
|
ConfigProvider gốc, menu, focus và portal body không có trigger vẫn là gốc; không có rekey
|
|
130
|
-
editor/model/đồ thị hay z-index popup toàn cục nào liên quan.
|
|
130
|
+
editor/model/đồ thị hay z-index popup toàn cục nào liên quan. Tuỳ chọn `feedback` (mặc định
|
|
131
|
+
`false`) đưa container không có trigger về host scope đã mount, để holder
|
|
132
|
+
`notification.useNotification()` / `message.useMessage()` bên trong scope theo owner overlay
|
|
133
|
+
vào phần tử toàn màn hình gốc. Handler capture toàn màn hình
|
|
131
134
|
nhường Escape cho menu/listbox qua `isAntDesignVueMenuEvent(event)` trước khi đóng overlay
|
|
132
135
|
của chính nó. Portal Drawer gốc có thể dùng cùng host ổn định qua scoped slot công khai:
|
|
133
136
|
`<AntDesignVuePopupScope v-slot="{ getContainer }">` với
|
|
@@ -163,6 +163,30 @@ vẫn là duy nhất (WCAG 1.4.1/1.4.11):
|
|
|
163
163
|
để trang trí (`aria-hidden`); tên jump và chú giải vẫn giữ chữ. Lỗi không có tone giữ màu lỗi
|
|
164
164
|
và nét đứt `5 4`.
|
|
165
165
|
|
|
166
|
+
Bằng chứng chạy trên cạnh `WorkflowEdge.execution` (`reached`, `unfinished`, `failed`,
|
|
167
|
+
`notTaken`) tách biệt với tuyến lỗi được soạn (`variant: 'failure'`) và với tone. Nguồn gắn:
|
|
168
|
+
|
|
169
|
+
- `reached` vào `color.text`, không phải `diagram.log-reached`: vai trò đó và màu làm nổi bật
|
|
170
|
+
cạnh (`--wf-edge-active`, `diagram.selection-ring`) cùng là màu xanh, nên cạnh đã đi qua lúc
|
|
171
|
+
nghỉ sẽ trông như đang được chọn. Dấu hiệu không dựa vào màu là độ dày đậm
|
|
172
|
+
`--wf-edge-execution-width` (`border.width.focused`), như cạnh đã đi qua màu trung tính của Mermaid.
|
|
173
|
+
- `unfinished` vào `diagram.log-unfinished`, nét đứt `4 3`.
|
|
174
|
+
- `failed` vào `diagram.fail-stroke`, kèm dấu lỗi hình tròn có chữ x.
|
|
175
|
+
- `notTaken` (tuyến bị bỏ qua) vào `diagram.nottaken-stroke` với độ dày thường, nét đứt `6 3`.
|
|
176
|
+
|
|
177
|
+
`--wf-edge-execution-width` phải là độ dài CSS. Màu thực thi thắng màu tone; nét đứt của
|
|
178
|
+
`unfinished` / `notTaken` thắng nét đứt của tone và của lỗi, còn tuyến lỗi được soạn bị thay nét
|
|
179
|
+
đứt vẫn giữ dấu tròn chữ x. Chú giải gọi tên từng trạng thái có mặt và tên truy cập của cạnh nối
|
|
180
|
+
thêm trạng thái đó (`Edge from A to B, run failed`). Ở độ tương phản cao, `reached` dùng chung màu
|
|
181
|
+
cạnh (`color.text`) và được phân biệt bằng độ dày; các trạng thái khác giữ màu theo theme.
|
|
182
|
+
|
|
183
|
+
Trạng thái node `reached`/`unfinished` chỉ suy ra từ log, không phải kết quả chạy có kiểu: viền
|
|
184
|
+
và dấu dùng `diagram.log-reached` / `diagram.log-unfinished` (`--wf-node-state-ink`); node có vòng
|
|
185
|
+
chọn độc lập nên `reached` của node giữ vai trò log. `unfinished` giữ nguyên nền và chữ của node
|
|
186
|
+
(kể cả ghi đè độ tương phản cao), vẽ nét đứt `4 3` cho cả viền lẫn cạnh subroutine.
|
|
187
|
+
`--wf-node-execution-outline-width` gắn `border.width.focused` cho `ranOk`, `ranFailed`,
|
|
188
|
+
`reached` và `unfinished`, như Mermaid; `neverReached` / `branchNotTaken` giữ mặc định gốc.
|
|
189
|
+
|
|
166
190
|
Có thể xảy ra và ngữ cảnh có thể kết hợp. Truyền tên nhóm đã bản địa hóa qua `familyLabel`:
|
|
167
191
|
chip và danh sách jump có tên `{family} jump to {target}`, đánh số `(n of m)` khi các jump song
|
|
168
192
|
song trùng tên. Bản địa hóa toàn bộ tên, cách đánh số và tiêu đề danh sách qua `texts.jumps`
|