@jylups/flowable-simple-view 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,73 @@
1
+ import { caseOutline } from '../core/outline.js';
2
+ import { badges, el, icon, line, mountView } from './common.js';
3
+ function tooltip(item) {
4
+ return [item.name, item.persona && `Who: ${item.persona}`, item.screen, item.detail, ...item.startsWhen.map((start) => `Starts: ${start}`)].filter(Boolean).join('\n');
5
+ }
6
+ function itemBox(item, options) {
7
+ const box = el('div', `fsv-box fsv-item fsv-kind-${item.kind}`);
8
+ const marks = badges(item);
9
+ box.dataset.id = item.id;
10
+ box.title = tooltip(item);
11
+ box.append(el('div', 'fsv-kind', item.kindLabel), el('div', 'fsv-name', item.name));
12
+ if (item.persona) {
13
+ box.appendChild(line(options, 'user', item.persona));
14
+ }
15
+ if (item.screen) {
16
+ box.appendChild(line(options, 'file', item.screen));
17
+ }
18
+ if (item.detail) {
19
+ box.appendChild(line(options, 'info', item.detail, 'fsv-muted'));
20
+ }
21
+ item.startsWhen.forEach((start) => box.appendChild(line(options, 'play', start, 'fsv-starts')));
22
+ if (marks) {
23
+ box.appendChild(marks);
24
+ }
25
+ return box;
26
+ }
27
+ function stageBox(stage, options, root) {
28
+ const box = el('div', root ? 'fsv-stage fsv-root' : 'fsv-stage');
29
+ const header = el('div', 'fsv-stage-header');
30
+ const marks = badges(stage);
31
+ box.dataset.id = stage.id;
32
+ header.append(el('span', 'fsv-kind', stage.kindLabel), el('strong', 'fsv-stage-name', stage.name));
33
+ if (marks) {
34
+ header.appendChild(marks);
35
+ }
36
+ box.appendChild(header);
37
+ if (!root) {
38
+ box.appendChild(line(options, 'play', stage.startsWhen.join('; or '), 'fsv-starts'));
39
+ }
40
+ if (stage.events?.length) {
41
+ const events = el('div', 'fsv-events');
42
+ events.appendChild(el('span', 'fsv-kind', 'Events'));
43
+ stage.events.forEach((event) => {
44
+ const badge = el('span', 'fsv-badge', `${event.kindLabel}: ${event.name}`);
45
+ badge.title = event.startsWhen.join('; or ');
46
+ events.appendChild(badge);
47
+ });
48
+ box.appendChild(events);
49
+ }
50
+ (stage.rows || []).forEach((items, index) => {
51
+ if (index > 0) {
52
+ const then = el('div', 'fsv-then');
53
+ then.appendChild(icon(options, 'arrow-down'));
54
+ box.appendChild(then);
55
+ }
56
+ const row = el('div', 'fsv-row');
57
+ items.forEach((item) => row.appendChild(item.kind === 'stage' ? stageBox(item, options, false) : itemBox(item, options)));
58
+ box.appendChild(row);
59
+ });
60
+ return box;
61
+ }
62
+ /**
63
+ * Draws the Simple view of a CMMN case plan into an element: its stages as
64
+ * groups of plain boxes, in each the items in the order their sentries start
65
+ * them, each with what starts it in plain words, who works it and which
66
+ * screen it shows.
67
+ */
68
+ export function renderCaseOutline(container, xml, options = {}) {
69
+ return mountView(container, 'fsv-case', xml, options, (root, source) => {
70
+ root.appendChild(stageBox(caseOutline(source).plan, options, true));
71
+ });
72
+ }
73
+ //# sourceMappingURL=case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"case.js","sourceRoot":"","sources":["../../src/render/case.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAKhE,SAAS,OAAO,CAAC,IAAc;IAC3B,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,IAAI,QAAQ,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3K,CAAC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,IAAI,EAAE,MAAM,EAAE,EAAE;QACnE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { caseOutline } from '../core/outline.js';\nimport type { CaseItem } from '../core/outline.js';\nimport { badges, el, icon, line, mountView } from './common.js';\nimport type { SimpleView, SimpleViewOptions } from './common.js';\n\nexport type CaseViewOptions = SimpleViewOptions;\n\nfunction tooltip(item: CaseItem): string {\n return [item.name, item.persona && `Who: ${item.persona}`, item.screen, item.detail, ...item.startsWhen.map((start) => `Starts: ${start}`)].filter(Boolean).join('\\n');\n}\n\nfunction itemBox(item: CaseItem, options: CaseViewOptions): HTMLDivElement {\n const box = el('div', `fsv-box fsv-item fsv-kind-${item.kind}`);\n const marks = badges(item);\n\n box.dataset.id = item.id;\n box.title = tooltip(item);\n box.append(el('div', 'fsv-kind', item.kindLabel), el('div', 'fsv-name', item.name));\n\n if (item.persona) {\n box.appendChild(line(options, 'user', item.persona));\n }\n\n if (item.screen) {\n box.appendChild(line(options, 'file', item.screen));\n }\n\n if (item.detail) {\n box.appendChild(line(options, 'info', item.detail, 'fsv-muted'));\n }\n\n item.startsWhen.forEach((start) => box.appendChild(line(options, 'play', start, 'fsv-starts')));\n\n if (marks) {\n box.appendChild(marks);\n }\n\n return box;\n}\n\nfunction stageBox(stage: CaseItem, options: CaseViewOptions, root: boolean): HTMLDivElement {\n const box = el('div', root ? 'fsv-stage fsv-root' : 'fsv-stage');\n const header = el('div', 'fsv-stage-header');\n const marks = badges(stage);\n\n box.dataset.id = stage.id;\n header.append(el('span', 'fsv-kind', stage.kindLabel), el('strong', 'fsv-stage-name', stage.name));\n\n if (marks) {\n header.appendChild(marks);\n }\n\n box.appendChild(header);\n\n if (!root) {\n box.appendChild(line(options, 'play', stage.startsWhen.join('; or '), 'fsv-starts'));\n }\n\n if (stage.events?.length) {\n const events = el('div', 'fsv-events');\n\n events.appendChild(el('span', 'fsv-kind', 'Events'));\n stage.events.forEach((event) => {\n const badge = el('span', 'fsv-badge', `${event.kindLabel}: ${event.name}`);\n\n badge.title = event.startsWhen.join('; or ');\n events.appendChild(badge);\n });\n box.appendChild(events);\n }\n\n (stage.rows || []).forEach((items, index) => {\n if (index > 0) {\n const then = el('div', 'fsv-then');\n\n then.appendChild(icon(options, 'arrow-down'));\n box.appendChild(then);\n }\n\n const row = el('div', 'fsv-row');\n\n items.forEach((item) => row.appendChild(item.kind === 'stage' ? stageBox(item, options, false) : itemBox(item, options)));\n box.appendChild(row);\n });\n\n return box;\n}\n\n/**\n * Draws the Simple view of a CMMN case plan into an element: its stages as\n * groups of plain boxes, in each the items in the order their sentries start\n * them, each with what starts it in plain words, who works it and which\n * screen it shows.\n */\nexport function renderCaseOutline(container: HTMLElement, xml: string, options: CaseViewOptions = {}): SimpleView {\n return mountView(container, 'fsv-case', xml, options, (root, source) => {\n root.appendChild(stageBox(caseOutline(source).plan, options, true));\n });\n}\n"]}
@@ -0,0 +1,47 @@
1
+ /** What both DOM views share: options, icons, element helpers and error handling. */
2
+ /** The icons the views draw. */
3
+ export type IconName = 'user' | 'file' | 'info' | 'play' | 'arrow-down';
4
+ export interface SimpleViewOptions {
5
+ /** The node for an icon. Defaults to small inline SVG icons; an app can return its own icon font instead. */
6
+ icon?: (name: IconName) => Node;
7
+ /** Called with the message when the XML can't be shown. */
8
+ onError?: (message: string) => void;
9
+ /** Show the message in the view when the XML can't be shown (default true). An app that shows errors its own way passes false. */
10
+ showError?: boolean;
11
+ }
12
+ /** A view drawn into an element. */
13
+ export interface SimpleView {
14
+ /** Draws the view again from other XML, for example after an edit. */
15
+ update(xml: string): void;
16
+ /** Removes the view from its element. */
17
+ destroy(): void;
18
+ }
19
+ export declare function defaultIcon(name: IconName): Node;
20
+ /** The icon from the app or the default, marked with fsv-icon. */
21
+ export declare function icon(options: SimpleViewOptions, name: IconName): Node;
22
+ /** A new element with classes and, optionally, its text. */
23
+ export declare function el<K extends keyof HTMLElementTagNameMap>(tag: K, className?: string, text?: string): HTMLElementTagNameMap[K];
24
+ export declare function svgEl<K extends keyof SVGElementTagNameMap>(tag: K, attributes?: Record<string, string | number>): SVGElementTagNameMap[K];
25
+ /** A line of a box: an icon and its text. */
26
+ export declare function line(options: SimpleViewOptions, name: IconName, text: string, className?: string): HTMLDivElement;
27
+ /** Positions an absolutely placed element. */
28
+ export declare function place(element: HTMLElement, box: {
29
+ x: number;
30
+ y: number;
31
+ width?: number;
32
+ height?: number;
33
+ }): void;
34
+ /** The message for XML that can't be shown. */
35
+ export declare function errorMessage(error: unknown): string;
36
+ /**
37
+ * Draws a view into a root element of its own inside the container, and
38
+ * draws it again on update. A model that can't be shown gives an error box
39
+ * (unless showError is false) and onError, never an exception.
40
+ */
41
+ export declare function mountView(container: HTMLElement, className: string, xml: string, options: SimpleViewOptions, draw: (root: HTMLElement, xml: string) => void): SimpleView;
42
+ /** Badges for an item a user starts, that can repeat or that is required. */
43
+ export declare function badges(item: {
44
+ manual: boolean;
45
+ repeats: boolean;
46
+ required: boolean;
47
+ }): HTMLDivElement | undefined;
@@ -0,0 +1,109 @@
1
+ /** What both DOM views share: options, icons, element helpers and error handling. */
2
+ const SVG = 'http://www.w3.org/2000/svg';
3
+ /** Icon paths on a 16 × 16 grid, drawn with the text colour. */
4
+ const ICON_PATHS = {
5
+ user: 'M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6Zm-5.5 6.5c0-3 2.5-4.5 5.5-4.5s5.5 1.5 5.5 4.5',
6
+ file: 'M4 1.5h5l3.5 3.5v9.5h-8.5v-13ZM9 1.5V5h3.5',
7
+ info: 'M8 14.5a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13ZM8 7v4.5M8 4.5v.5',
8
+ play: 'M4.5 2.5v11l9-5.5-9-5.5Z',
9
+ 'arrow-down': 'M8 2v11.5M3.5 9 8 13.5 12.5 9'
10
+ };
11
+ export function defaultIcon(name) {
12
+ const svg = document.createElementNS(SVG, 'svg');
13
+ const path = document.createElementNS(SVG, 'path');
14
+ svg.setAttribute('viewBox', '0 0 16 16');
15
+ svg.setAttribute('aria-hidden', 'true');
16
+ svg.setAttribute('focusable', 'false');
17
+ path.setAttribute('d', ICON_PATHS[name]);
18
+ svg.appendChild(path);
19
+ return svg;
20
+ }
21
+ /** The icon from the app or the default, marked with fsv-icon. */
22
+ export function icon(options, name) {
23
+ const node = (options.icon || defaultIcon)(name);
24
+ if (node.nodeType === Node.ELEMENT_NODE) {
25
+ node.classList.add('fsv-icon', `fsv-icon-${name}`);
26
+ }
27
+ return node;
28
+ }
29
+ /** A new element with classes and, optionally, its text. */
30
+ export function el(tag, className, text) {
31
+ const element = document.createElement(tag);
32
+ if (className) {
33
+ element.className = className;
34
+ }
35
+ if (text !== undefined) {
36
+ element.textContent = text;
37
+ }
38
+ return element;
39
+ }
40
+ export function svgEl(tag, attributes = {}) {
41
+ const element = document.createElementNS(SVG, tag);
42
+ Object.entries(attributes).forEach(([name, value]) => element.setAttribute(name, String(value)));
43
+ return element;
44
+ }
45
+ /** A line of a box: an icon and its text. */
46
+ export function line(options, name, text, className = '') {
47
+ const row = el('div', `fsv-line ${className}`.trim());
48
+ row.append(icon(options, name), el('span', undefined, text));
49
+ return row;
50
+ }
51
+ /** Positions an absolutely placed element. */
52
+ export function place(element, box) {
53
+ element.style.left = `${box.x}px`;
54
+ element.style.top = `${box.y}px`;
55
+ if (box.width !== undefined) {
56
+ element.style.width = `${box.width}px`;
57
+ }
58
+ if (box.height !== undefined) {
59
+ element.style.height = `${box.height}px`;
60
+ }
61
+ }
62
+ /** The message for XML that can't be shown. */
63
+ export function errorMessage(error) {
64
+ return `Failed to show the simple view: ${error?.message || 'Unknown error'}`;
65
+ }
66
+ /**
67
+ * Draws a view into a root element of its own inside the container, and
68
+ * draws it again on update. A model that can't be shown gives an error box
69
+ * (unless showError is false) and onError, never an exception.
70
+ */
71
+ export function mountView(container, className, xml, options, draw) {
72
+ const root = el('div', `fsv ${className}`);
73
+ const render = (source) => {
74
+ root.replaceChildren();
75
+ if (!source?.trim()) {
76
+ return;
77
+ }
78
+ try {
79
+ draw(root, source);
80
+ }
81
+ catch (error) {
82
+ const message = errorMessage(error);
83
+ root.replaceChildren();
84
+ if (options.showError !== false) {
85
+ const box = el('div', 'fsv-error', message);
86
+ box.setAttribute('role', 'alert');
87
+ root.appendChild(box);
88
+ }
89
+ options.onError?.(message);
90
+ }
91
+ };
92
+ container.replaceChildren(root);
93
+ render(xml);
94
+ return {
95
+ update: render,
96
+ destroy: () => root.remove()
97
+ };
98
+ }
99
+ /** Badges for an item a user starts, that can repeat or that is required. */
100
+ export function badges(item) {
101
+ const texts = [item.manual && 'Started by a user', item.repeats && 'Can repeat', item.required && 'Required'].filter(Boolean);
102
+ if (!texts.length) {
103
+ return undefined;
104
+ }
105
+ const box = el('div', 'fsv-badges');
106
+ box.append(...texts.map((text) => el('span', 'fsv-badge', text)));
107
+ return box;
108
+ }
109
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/render/common.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAsBrF,MAAM,GAAG,GAAG,4BAA4B,CAAC;AAEzC,gEAAgE;AAChE,MAAM,UAAU,GAA6B;IACzC,IAAI,EAAE,gFAAgF;IACtF,IAAI,EAAE,4CAA4C;IAClD,IAAI,EAAE,iEAAiE;IACvE,IAAI,EAAE,0BAA0B;IAChC,YAAY,EAAE,+BAA+B;CAChD,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,IAAc;IACtC,MAAM,GAAG,GAAG,QAAQ,CAAC,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAEnD,GAAG,CAAC,YAAY,CAAC,SAAS,EAAE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M,CAAC,OAAO,CAAa,CAAC;IAE1I,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,GAAG,GAAG,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAEpC,GAAG,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAElE,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["/** What both DOM views share: options, icons, element helpers and error handling. */\n\n/** The icons the views draw. */\nexport type IconName = 'user' | 'file' | 'info' | 'play' | 'arrow-down';\n\nexport interface SimpleViewOptions {\n /** The node for an icon. Defaults to small inline SVG icons; an app can return its own icon font instead. */\n icon?: (name: IconName) => Node;\n /** Called with the message when the XML can't be shown. */\n onError?: (message: string) => void;\n /** Show the message in the view when the XML can't be shown (default true). An app that shows errors its own way passes false. */\n showError?: boolean;\n}\n\n/** A view drawn into an element. */\nexport interface SimpleView {\n /** Draws the view again from other XML, for example after an edit. */\n update(xml: string): void;\n /** Removes the view from its element. */\n destroy(): void;\n}\n\nconst SVG = 'http://www.w3.org/2000/svg';\n\n/** Icon paths on a 16 × 16 grid, drawn with the text colour. */\nconst ICON_PATHS: Record<IconName, string> = {\n user: 'M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6Zm-5.5 6.5c0-3 2.5-4.5 5.5-4.5s5.5 1.5 5.5 4.5',\n file: 'M4 1.5h5l3.5 3.5v9.5h-8.5v-13ZM9 1.5V5h3.5',\n info: 'M8 14.5a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13ZM8 7v4.5M8 4.5v.5',\n play: 'M4.5 2.5v11l9-5.5-9-5.5Z',\n 'arrow-down': 'M8 2v11.5M3.5 9 8 13.5 12.5 9'\n};\n\nexport function defaultIcon(name: IconName): Node {\n const svg = document.createElementNS(SVG, 'svg');\n const path = document.createElementNS(SVG, 'path');\n\n svg.setAttribute('viewBox', '0 0 16 16');\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('focusable', 'false');\n path.setAttribute('d', ICON_PATHS[name]);\n svg.appendChild(path);\n\n return svg;\n}\n\n/** The icon from the app or the default, marked with fsv-icon. */\nexport function icon(options: SimpleViewOptions, name: IconName): Node {\n const node = (options.icon || defaultIcon)(name);\n\n if (node.nodeType === Node.ELEMENT_NODE) {\n (node as Element).classList.add('fsv-icon', `fsv-icon-${name}`);\n }\n\n return node;\n}\n\n/** A new element with classes and, optionally, its text. */\nexport function el<K extends keyof HTMLElementTagNameMap>(tag: K, className?: string, text?: string): HTMLElementTagNameMap[K] {\n const element = document.createElement(tag);\n\n if (className) {\n element.className = className;\n }\n\n if (text !== undefined) {\n element.textContent = text;\n }\n\n return element;\n}\n\nexport function svgEl<K extends keyof SVGElementTagNameMap>(tag: K, attributes: Record<string, string | number> = {}): SVGElementTagNameMap[K] {\n const element = document.createElementNS(SVG, tag);\n\n Object.entries(attributes).forEach(([name, value]) => element.setAttribute(name, String(value)));\n\n return element;\n}\n\n/** A line of a box: an icon and its text. */\nexport function line(options: SimpleViewOptions, name: IconName, text: string, className = ''): HTMLDivElement {\n const row = el('div', `fsv-line ${className}`.trim());\n\n row.append(icon(options, name), el('span', undefined, text));\n\n return row;\n}\n\n/** Positions an absolutely placed element. */\nexport function place(element: HTMLElement, box: { x: number; y: number; width?: number; height?: number }): void {\n element.style.left = `${box.x}px`;\n element.style.top = `${box.y}px`;\n\n if (box.width !== undefined) {\n element.style.width = `${box.width}px`;\n }\n\n if (box.height !== undefined) {\n element.style.height = `${box.height}px`;\n }\n}\n\n/** The message for XML that can't be shown. */\nexport function errorMessage(error: unknown): string {\n return `Failed to show the simple view: ${(error as Error)?.message || 'Unknown error'}`;\n}\n\n/**\n * Draws a view into a root element of its own inside the container, and\n * draws it again on update. A model that can't be shown gives an error box\n * (unless showError is false) and onError, never an exception.\n */\nexport function mountView(container: HTMLElement, className: string, xml: string, options: SimpleViewOptions, draw: (root: HTMLElement, xml: string) => void): SimpleView {\n const root = el('div', `fsv ${className}`);\n\n const render = (source: string) => {\n root.replaceChildren();\n\n if (!source?.trim()) {\n return;\n }\n\n try {\n draw(root, source);\n } catch (error) {\n const message = errorMessage(error);\n\n root.replaceChildren();\n\n if (options.showError !== false) {\n const box = el('div', 'fsv-error', message);\n\n box.setAttribute('role', 'alert');\n root.appendChild(box);\n }\n\n options.onError?.(message);\n }\n };\n\n container.replaceChildren(root);\n render(xml);\n\n return {\n update: render,\n destroy: () => root.remove()\n };\n}\n\n/** Badges for an item a user starts, that can repeat or that is required. */\nexport function badges(item: { manual: boolean; repeats: boolean; required: boolean }): HTMLDivElement | undefined {\n const texts = [item.manual && 'Started by a user', item.repeats && 'Can repeat', item.required && 'Required'].filter(Boolean) as string[];\n\n if (!texts.length) {\n return undefined;\n }\n\n const box = el('div', 'fsv-badges');\n\n box.append(...texts.map((text) => el('span', 'fsv-badge', text)));\n\n return box;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { SimpleView, SimpleViewOptions } from './common.js';
2
+ export interface ProcessViewOptions extends SimpleViewOptions {
3
+ /** The size of a task box (default 210 × 118). */
4
+ boxSize?: {
5
+ width: number;
6
+ height: number;
7
+ };
8
+ /** The room between columns, for the branch names on the arrows (default 140). */
9
+ columnGap?: number;
10
+ }
11
+ /**
12
+ * Draws the Simple view of a BPMN process into an element: its steps as
13
+ * plain boxes with arrows, left to right, each with who works it and which
14
+ * screen it shows, and the branches named on the arrows. Event subprocesses
15
+ * and the pools of a collaboration follow as flows of their own.
16
+ */
17
+ export declare function renderProcessOutline(container: HTMLElement, xml: string, options?: ProcessViewOptions): SimpleView;
@@ -0,0 +1,88 @@
1
+ import { processOutline } from '../core/outline.js';
2
+ import { layoutFlow } from '../core/layout.js';
3
+ import { el, line, mountView, place, svgEl } from './common.js';
4
+ const TASK = { width: 210, height: 118 };
5
+ const GATEWAY = { width: 40, height: 40 };
6
+ const EVENT = { width: 32, height: 32 };
7
+ const COLUMN_GAP = 140;
8
+ let viewCount = 0;
9
+ function tooltip(node) {
10
+ return [node.name, node.persona && `Who: ${node.persona}`, node.personaDetail && `Assignment: ${node.personaDetail}`, node.screen, node.detail].filter(Boolean).join('\n');
11
+ }
12
+ function taskBox(node, options) {
13
+ const box = el('div', `fsv-box fsv-node fsv-kind-${node.kind}`);
14
+ box.append(el('div', 'fsv-kind', node.kindLabel), el('div', 'fsv-name', node.name));
15
+ if (node.persona) {
16
+ box.appendChild(line(options, 'user', node.persona));
17
+ }
18
+ if (node.screen) {
19
+ box.appendChild(line(options, 'file', node.screen));
20
+ }
21
+ if (node.detail) {
22
+ box.appendChild(line(options, 'info', node.detail, 'fsv-muted'));
23
+ }
24
+ return box;
25
+ }
26
+ function mark(node) {
27
+ const box = el('div', 'fsv-mark fsv-node');
28
+ box.classList.toggle('fsv-gateway', node.shape === 'gateway');
29
+ box.classList.toggle('fsv-end', node.kind === 'endEvent');
30
+ box.appendChild(el('span', 'fsv-mark-label', node.name || node.kindLabel));
31
+ return box;
32
+ }
33
+ /**
34
+ * Draws the Simple view of a BPMN process into an element: its steps as
35
+ * plain boxes with arrows, left to right, each with who works it and which
36
+ * screen it shows, and the branches named on the arrows. Event subprocesses
37
+ * and the pools of a collaboration follow as flows of their own.
38
+ */
39
+ export function renderProcessOutline(container, xml, options = {}) {
40
+ const markerId = `fsv-arrow-${++viewCount}-${Math.random().toString(36).slice(2, 8)}`;
41
+ const task = options.boxSize || TASK;
42
+ return mountView(container, 'fsv-process', xml, options, (root, source) => {
43
+ processOutline(source).sections.forEach((section) => {
44
+ const layout = layoutFlow(section.nodes.map((node) => ({ id: node.id, ...(node.shape === 'task' ? task : node.shape === 'gateway' ? GATEWAY : EVENT) })), section.edges, { columnGap: options.columnGap ?? COLUMN_GAP });
45
+ const view = el('section', 'fsv-section');
46
+ const canvas = el('div', 'fsv-canvas');
47
+ const arrows = svgEl('svg', { class: 'fsv-arrows', width: layout.width, height: layout.height, 'aria-hidden': 'true' });
48
+ const marker = svgEl('marker', { id: markerId, viewBox: '0 0 10 10', refX: 9, refY: 5, markerWidth: 7, markerHeight: 7, orient: 'auto-start-reverse' });
49
+ if (section.title) {
50
+ const title = el('div', 'fsv-section-title', section.title);
51
+ title.setAttribute('role', 'heading');
52
+ title.setAttribute('aria-level', '3');
53
+ view.appendChild(title);
54
+ }
55
+ canvas.style.width = `${layout.width}px`;
56
+ canvas.style.height = `${layout.height}px`;
57
+ marker.appendChild(svgEl('path', { d: 'M 0 0 L 10 5 L 0 10 z', class: 'fsv-arrowhead' }));
58
+ arrows.appendChild(svgEl('defs')).appendChild(marker);
59
+ layout.edges.forEach((edge) => {
60
+ arrows.appendChild(svgEl('path', { d: edge.path, class: edge.back ? 'fsv-arrow fsv-back' : 'fsv-arrow', 'marker-end': `url(#${markerId})` }));
61
+ });
62
+ canvas.appendChild(arrows);
63
+ section.nodes.forEach((node) => {
64
+ const placed = layout.nodes.get(node.id);
65
+ if (!placed) {
66
+ return;
67
+ }
68
+ const box = node.shape === 'task' ? taskBox(node, options) : mark(node);
69
+ place(box, placed);
70
+ box.dataset.id = node.id;
71
+ box.title = tooltip(node);
72
+ canvas.appendChild(box);
73
+ });
74
+ const placedEdges = new Map(layout.edges.map((edge) => [edge.id, edge]));
75
+ section.edges.forEach((edge) => {
76
+ const placed = placedEdges.get(edge.id);
77
+ if (edge.label && placed) {
78
+ const label = el('span', 'fsv-edge-label', edge.label);
79
+ place(label, { x: placed.labelX, y: placed.labelY });
80
+ canvas.appendChild(label);
81
+ }
82
+ });
83
+ view.appendChild(canvas);
84
+ root.appendChild(view);
85
+ });
86
+ });
87
+ }
88
+ //# sourceMappingURL=process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/render/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAA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'../core/outline.js';\nimport { layoutFlow } from '../core/layout.js';\nimport { el, line, mountView, place, svgEl } from './common.js';\nimport type { SimpleView, SimpleViewOptions } from './common.js';\n\nexport interface ProcessViewOptions extends SimpleViewOptions {\n /** The size of a task box (default 210 × 118). */\n boxSize?: { width: number; height: number };\n /** The room between columns, for the branch names on the arrows (default 140). */\n columnGap?: number;\n}\n\nconst TASK = { width: 210, height: 118 };\nconst GATEWAY = { width: 40, height: 40 };\nconst EVENT = { width: 32, height: 32 };\nconst COLUMN_GAP = 140;\n\nlet viewCount = 0;\n\nfunction tooltip(node: FlowNode): string {\n return [node.name, node.persona && `Who: ${node.persona}`, node.personaDetail && `Assignment: ${node.personaDetail}`, node.screen, node.detail].filter(Boolean).join('\\n');\n}\n\nfunction taskBox(node: FlowNode, options: ProcessViewOptions): HTMLDivElement {\n const box = el('div', `fsv-box fsv-node fsv-kind-${node.kind}`);\n\n box.append(el('div', 'fsv-kind', node.kindLabel), el('div', 'fsv-name', node.name));\n\n if (node.persona) {\n box.appendChild(line(options, 'user', node.persona));\n }\n\n if (node.screen) {\n box.appendChild(line(options, 'file', node.screen));\n }\n\n if (node.detail) {\n box.appendChild(line(options, 'info', node.detail, 'fsv-muted'));\n }\n\n return box;\n}\n\nfunction mark(node: FlowNode): HTMLDivElement {\n const box = el('div', 'fsv-mark fsv-node');\n\n box.classList.toggle('fsv-gateway', node.shape === 'gateway');\n box.classList.toggle('fsv-end', node.kind === 'endEvent');\n box.appendChild(el('span', 'fsv-mark-label', node.name || node.kindLabel));\n\n return box;\n}\n\n/**\n * Draws the Simple view of a BPMN process into an element: its steps as\n * plain boxes with arrows, left to right, each with who works it and which\n * screen it shows, and the branches named on the arrows. Event subprocesses\n * and the pools of a collaboration follow as flows of their own.\n */\nexport function renderProcessOutline(container: HTMLElement, xml: string, options: ProcessViewOptions = {}): SimpleView {\n const markerId = `fsv-arrow-${++viewCount}-${Math.random().toString(36).slice(2, 8)}`;\n const task = options.boxSize || TASK;\n\n return mountView(container, 'fsv-process', xml, options, (root, source) => {\n processOutline(source).sections.forEach((section) => {\n const layout = layoutFlow(\n section.nodes.map((node) => ({ id: node.id, ...(node.shape === 'task' ? task : node.shape === 'gateway' ? GATEWAY : EVENT) })),\n section.edges,\n { columnGap: options.columnGap ?? COLUMN_GAP }\n );\n const view = el('section', 'fsv-section');\n const canvas = el('div', 'fsv-canvas');\n const arrows = svgEl('svg', { class: 'fsv-arrows', width: layout.width, height: layout.height, 'aria-hidden': 'true' });\n const marker = svgEl('marker', { id: markerId, viewBox: '0 0 10 10', refX: 9, refY: 5, markerWidth: 7, markerHeight: 7, orient: 'auto-start-reverse' });\n\n if (section.title) {\n const title = el('div', 'fsv-section-title', section.title);\n\n title.setAttribute('role', 'heading');\n title.setAttribute('aria-level', '3');\n view.appendChild(title);\n }\n\n canvas.style.width = `${layout.width}px`;\n canvas.style.height = `${layout.height}px`;\n marker.appendChild(svgEl('path', { d: 'M 0 0 L 10 5 L 0 10 z', class: 'fsv-arrowhead' }));\n arrows.appendChild(svgEl('defs')).appendChild(marker);\n layout.edges.forEach((edge) => {\n arrows.appendChild(svgEl('path', { d: edge.path, class: edge.back ? 'fsv-arrow fsv-back' : 'fsv-arrow', 'marker-end': `url(#${markerId})` }));\n });\n canvas.appendChild(arrows);\n\n section.nodes.forEach((node) => {\n const placed = layout.nodes.get(node.id);\n\n if (!placed) {\n return;\n }\n\n const box = node.shape === 'task' ? taskBox(node, options) : mark(node);\n\n place(box, placed);\n box.dataset.id = node.id;\n box.title = tooltip(node);\n canvas.appendChild(box);\n });\n\n const placedEdges = new Map(layout.edges.map((edge) => [edge.id, edge]));\n\n section.edges.forEach((edge) => {\n const placed = placedEdges.get(edge.id);\n\n if (edge.label && placed) {\n const label = el('span', 'fsv-edge-label', edge.label);\n\n place(label, { x: placed.labelX, y: placed.labelY });\n canvas.appendChild(label);\n }\n });\n\n view.appendChild(canvas);\n root.appendChild(view);\n });\n });\n}\n"]}