@apia/speed-ui 5.0.0 → 5.0.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/data/SpeedUIExecution.d.ts +11 -0
- package/dist/data/SpeedUIExecution.d.ts.map +1 -0
- package/dist/data/SpeedUIExecution.js +13 -0
- package/dist/data/SpeedUIExecution.js.map +1 -0
- package/dist/data/SpeedUIForm.d.ts +13 -0
- package/dist/data/SpeedUIForm.d.ts.map +1 -0
- package/dist/data/SpeedUIForm.js +14 -0
- package/dist/data/SpeedUIForm.js.map +1 -0
- package/dist/data/SpeedUIRunable.d.ts +41 -0
- package/dist/data/SpeedUIRunable.d.ts.map +1 -0
- package/dist/data/SpeedUIRunable.js +35 -0
- package/dist/data/SpeedUIRunable.js.map +1 -0
- package/dist/data/SpeedUIScreen.d.ts +10 -0
- package/dist/data/SpeedUIScreen.d.ts.map +1 -0
- package/dist/data/SpeedUIScreen.js +12 -0
- package/dist/data/SpeedUIScreen.js.map +1 -0
- package/dist/graphLoader/graphLoader.d.ts +59 -0
- package/dist/graphLoader/graphLoader.d.ts.map +1 -0
- package/dist/graphLoader/graphLoader.js +52 -0
- package/dist/graphLoader/graphLoader.js.map +1 -0
- package/dist/index.d.ts +9 -173
- package/dist/index.js +9 -351
- package/dist/index.js.map +1 -1
- package/dist/ui/SpeedUIReact.d.ts +23 -0
- package/dist/ui/SpeedUIReact.d.ts.map +1 -0
- package/dist/ui/SpeedUIReact.js +54 -0
- package/dist/ui/SpeedUIReact.js.map +1 -0
- package/dist/ui/SpeedUIReactVisitor.d.ts +36 -0
- package/dist/ui/SpeedUIReactVisitor.d.ts.map +1 -0
- package/dist/ui/SpeedUIReactVisitor.js +8 -0
- package/dist/ui/SpeedUIReactVisitor.js.map +1 -0
- package/dist/ui/defaults/SpeedUIExecutionReact/SpeedUIExecutionReact.js +17 -0
- package/dist/ui/defaults/SpeedUIExecutionReact/SpeedUIExecutionReact.js.map +1 -0
- package/dist/ui/defaults/SpeedUIFormReact/SpeedUIFormReact.d.ts +9 -0
- package/dist/ui/defaults/SpeedUIFormReact/SpeedUIFormReact.d.ts.map +1 -0
- package/dist/ui/defaults/SpeedUIFormReact/SpeedUIFormReact.js +30 -0
- package/dist/ui/defaults/SpeedUIFormReact/SpeedUIFormReact.js.map +1 -0
- package/dist/ui/defaults/SpeedUIScreenReact/Selector.js +85 -0
- package/dist/ui/defaults/SpeedUIScreenReact/Selector.js.map +1 -0
- package/dist/ui/defaults/SpeedUIScreenReact/SpeedUIScreenReact.d.ts +11 -0
- package/dist/ui/defaults/SpeedUIScreenReact/SpeedUIScreenReact.d.ts.map +1 -0
- package/dist/ui/defaults/SpeedUIScreenReact/SpeedUIScreenReact.js +81 -0
- package/dist/ui/defaults/SpeedUIScreenReact/SpeedUIScreenReact.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SpeedUIRunable } from './SpeedUIRunable.js';
|
|
2
|
+
|
|
3
|
+
declare class SpeedUIExecution extends SpeedUIRunable {
|
|
4
|
+
label: string;
|
|
5
|
+
cb: () => unknown;
|
|
6
|
+
readonly parent?: SpeedUIRunable | undefined;
|
|
7
|
+
constructor(label: string, cb: () => unknown, parent?: SpeedUIRunable | undefined);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { SpeedUIExecution };
|
|
11
|
+
//# sourceMappingURL=SpeedUIExecution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpeedUIExecution.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SpeedUIRunable } from './SpeedUIRunable.js';
|
|
2
|
+
|
|
3
|
+
class SpeedUIExecution extends SpeedUIRunable {
|
|
4
|
+
constructor(label, cb, parent) {
|
|
5
|
+
super(label, parent);
|
|
6
|
+
this.label = label;
|
|
7
|
+
this.cb = cb;
|
|
8
|
+
this.parent = parent;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { SpeedUIExecution };
|
|
13
|
+
//# sourceMappingURL=SpeedUIExecution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpeedUIExecution.js","sources":["../../src/data/SpeedUIExecution.ts"],"sourcesContent":["import { SpeedUIRunable } from './SpeedUIRunable';\r\n\r\nexport class SpeedUIExecution extends SpeedUIRunable {\r\n constructor(\r\n public label: string,\r\n public cb: () => unknown,\r\n public readonly parent?: SpeedUIRunable,\r\n ) {\r\n super(label, parent);\r\n }\r\n}\r\n"],"names":[],"mappings":";;AAEO,MAAM,yBAAyB,cAAA,CAAe;AAAA,EACnD,WAAA,CACS,KAAA,EACA,EAAA,EACS,MAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,MAAM,CAAA;AAJZ,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AACA,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA;AACS,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA;AAIpB;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Collector } from '@apia/validations';
|
|
2
|
+
import { SpeedUIRunable } from './SpeedUIRunable.js';
|
|
3
|
+
|
|
4
|
+
declare class SpeedUIForm extends SpeedUIRunable {
|
|
5
|
+
protected label: string;
|
|
6
|
+
makeFields: (collector: Collector) => void;
|
|
7
|
+
onConfirm: (fields: any) => unknown;
|
|
8
|
+
readonly parent?: SpeedUIRunable | undefined;
|
|
9
|
+
constructor(label: string, makeFields: (collector: Collector) => void, onConfirm: (fields: any) => unknown, parent?: SpeedUIRunable | undefined);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { SpeedUIForm };
|
|
13
|
+
//# sourceMappingURL=SpeedUIForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpeedUIForm.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SpeedUIRunable } from './SpeedUIRunable.js';
|
|
2
|
+
|
|
3
|
+
class SpeedUIForm extends SpeedUIRunable {
|
|
4
|
+
constructor(label, makeFields, onConfirm, parent) {
|
|
5
|
+
super(label, parent);
|
|
6
|
+
this.label = label;
|
|
7
|
+
this.makeFields = makeFields;
|
|
8
|
+
this.onConfirm = onConfirm;
|
|
9
|
+
this.parent = parent;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { SpeedUIForm };
|
|
14
|
+
//# sourceMappingURL=SpeedUIForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpeedUIForm.js","sources":["../../src/data/SpeedUIForm.ts"],"sourcesContent":["import { Collector } from '@apia/validations';\r\nimport { SpeedUIRunable } from './SpeedUIRunable';\r\n\r\nexport class SpeedUIForm extends SpeedUIRunable {\r\n constructor(\r\n protected label: string,\r\n public makeFields: (collector: Collector) => void,\r\n public onConfirm: (fields: any) => unknown,\r\n public readonly parent?: SpeedUIRunable,\r\n ) {\r\n super(label, parent);\r\n }\r\n}\r\n"],"names":[],"mappings":";;AAGO,MAAM,oBAAoB,cAAA,CAAe;AAAA,EAC9C,WAAA,CACY,KAAA,EACH,UAAA,EACA,SAAA,EACS,MAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,MAAM,CAAA;AALT,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AACH,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AACS,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA;AAIpB;;;;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as _apia_util from '@apia/util';
|
|
2
|
+
import { EventEmitter } from '@apia/util';
|
|
3
|
+
|
|
4
|
+
type SpeedUIEvent<Type extends string, T extends Record<string, unknown>> = T & {
|
|
5
|
+
type: Type;
|
|
6
|
+
};
|
|
7
|
+
declare abstract class SpeedUIRunable {
|
|
8
|
+
protected label: string;
|
|
9
|
+
readonly parent?: SpeedUIRunable | undefined;
|
|
10
|
+
protected emitter: EventEmitter<{
|
|
11
|
+
cancel: SpeedUIEvent<"cancel", {
|
|
12
|
+
target: SpeedUIRunable;
|
|
13
|
+
}>;
|
|
14
|
+
finish: SpeedUIEvent<"finish", {
|
|
15
|
+
target: SpeedUIRunable;
|
|
16
|
+
}>;
|
|
17
|
+
start: SpeedUIEvent<"start", {
|
|
18
|
+
target: SpeedUIRunable;
|
|
19
|
+
}>;
|
|
20
|
+
}>;
|
|
21
|
+
constructor(label: string, parent?: SpeedUIRunable | undefined);
|
|
22
|
+
getLabel(): string;
|
|
23
|
+
cancel(): void;
|
|
24
|
+
finish(): void;
|
|
25
|
+
protected emit: (typeof this.emitter)['emit'];
|
|
26
|
+
on: <K extends "cancel" | "finish" | "start">(event: K, cb: _apia_util.Callback<{
|
|
27
|
+
cancel: SpeedUIEvent<"cancel", {
|
|
28
|
+
target: SpeedUIRunable;
|
|
29
|
+
}>;
|
|
30
|
+
finish: SpeedUIEvent<"finish", {
|
|
31
|
+
target: SpeedUIRunable;
|
|
32
|
+
}>;
|
|
33
|
+
start: SpeedUIEvent<"start", {
|
|
34
|
+
target: SpeedUIRunable;
|
|
35
|
+
}>;
|
|
36
|
+
}, K>) => _apia_util.UnSubscriber;
|
|
37
|
+
run(): void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { SpeedUIRunable };
|
|
41
|
+
//# sourceMappingURL=SpeedUIRunable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpeedUIRunable.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EventEmitter } from '@apia/util';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __publicField = (obj, key, value) => {
|
|
6
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
return value;
|
|
8
|
+
};
|
|
9
|
+
class SpeedUIRunable {
|
|
10
|
+
constructor(label, parent) {
|
|
11
|
+
this.label = label;
|
|
12
|
+
this.parent = parent;
|
|
13
|
+
__publicField(this, "emitter", new EventEmitter());
|
|
14
|
+
__publicField(this, "emit", (evName, ev) => {
|
|
15
|
+
this.emitter.emit(evName, ev);
|
|
16
|
+
this.parent?.emit(evName, ev);
|
|
17
|
+
});
|
|
18
|
+
__publicField(this, "on", this.emitter.on.bind(this.emitter));
|
|
19
|
+
}
|
|
20
|
+
getLabel() {
|
|
21
|
+
return this.label;
|
|
22
|
+
}
|
|
23
|
+
cancel() {
|
|
24
|
+
this.emit("cancel", { target: this, type: "cancel" });
|
|
25
|
+
}
|
|
26
|
+
finish() {
|
|
27
|
+
this.emit("finish", { target: this, type: "finish" });
|
|
28
|
+
}
|
|
29
|
+
run() {
|
|
30
|
+
this.emit("start", { target: this, type: "start" });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { SpeedUIRunable };
|
|
35
|
+
//# sourceMappingURL=SpeedUIRunable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpeedUIRunable.js","sources":["../../src/data/SpeedUIRunable.ts"],"sourcesContent":["import { EventEmitter } from '@apia/util';\r\n\r\ntype SpeedUIEvent<\r\n Type extends string,\r\n T extends Record<string, unknown>,\r\n> = T & {\r\n type: Type;\r\n};\r\n\r\nexport abstract class SpeedUIRunable {\r\n protected emitter = new EventEmitter<{\r\n cancel: SpeedUIEvent<'cancel', { target: SpeedUIRunable }>;\r\n finish: SpeedUIEvent<'finish', { target: SpeedUIRunable }>;\r\n start: SpeedUIEvent<'start', { target: SpeedUIRunable }>;\r\n }>();\r\n\r\n constructor(\r\n protected label: string,\r\n public readonly parent?: SpeedUIRunable,\r\n ) {}\r\n\r\n getLabel(): string {\r\n return this.label;\r\n }\r\n\r\n cancel() {\r\n this.emit('cancel', { target: this, type: 'cancel' });\r\n }\r\n\r\n finish() {\r\n this.emit('finish', { target: this, type: 'finish' });\r\n }\r\n\r\n protected emit: (typeof this.emitter)['emit'] = (evName, ev) => {\r\n this.emitter.emit(evName, ev);\r\n this.parent?.emit(evName, ev);\r\n };\r\n\r\n on = this.emitter.on.bind(this.emitter);\r\n\r\n run() {\r\n this.emit('start', { target: this, type: 'start' });\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;AASO,MAAe,cAAA,CAAe;AAAA,EAOnC,WAAA,CACY,OACM,MAAA,EAChB;AAFU,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AACM,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AARlB,IAAA,aAAA,CAAA,IAAA,EAAU,SAAA,EAAU,IAAI,YAAA,EAIrB,CAAA;AAmBH,IAAA,aAAA,CAAA,IAAA,EAAU,MAAA,EAAsC,CAAC,MAAA,EAAQ,EAAA,KAAO;AAC9D,MAAA,IAAA,CAAK,OAAA,CAAQ,IAAA,CAAK,MAAA,EAAQ,EAAE,CAAA;AAC5B,MAAA,IAAA,CAAK,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAQ,EAAE,CAAA;AAAA,KAC9B,CAAA;AAEA,IAAA,aAAA,CAAA,IAAA,EAAA,IAAA,EAAK,IAAA,CAAK,OAAA,CAAQ,EAAA,CAAG,IAAA,CAAK,KAAK,OAAO,CAAA,CAAA;AAAA;AAnBnC,EAEH,QAAA,GAAmB;AACjB,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA;AACd,EAEA,MAAA,GAAS;AACP,IAAA,IAAA,CAAK,KAAK,QAAA,EAAU,EAAE,QAAQ,IAAA,EAAM,IAAA,EAAM,UAAU,CAAA;AAAA;AACtD,EAEA,MAAA,GAAS;AACP,IAAA,IAAA,CAAK,KAAK,QAAA,EAAU,EAAE,QAAQ,IAAA,EAAM,IAAA,EAAM,UAAU,CAAA;AAAA;AACtD,EASA,GAAA,GAAM;AACJ,IAAA,IAAA,CAAK,KAAK,OAAA,EAAS,EAAE,QAAQ,IAAA,EAAM,IAAA,EAAM,SAAS,CAAA;AAAA;AAEtD;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SpeedUIRunable } from './SpeedUIRunable.js';
|
|
2
|
+
|
|
3
|
+
declare class SpeedUIScreen extends SpeedUIRunable {
|
|
4
|
+
getChildren: () => SpeedUIRunable[];
|
|
5
|
+
readonly parent?: SpeedUIRunable | undefined;
|
|
6
|
+
constructor(label: string, getChildren: () => SpeedUIRunable[], parent?: SpeedUIRunable | undefined);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { SpeedUIScreen };
|
|
10
|
+
//# sourceMappingURL=SpeedUIScreen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpeedUIScreen.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SpeedUIRunable } from './SpeedUIRunable.js';
|
|
2
|
+
|
|
3
|
+
class SpeedUIScreen extends SpeedUIRunable {
|
|
4
|
+
constructor(label, getChildren, parent) {
|
|
5
|
+
super(label, parent);
|
|
6
|
+
this.getChildren = getChildren;
|
|
7
|
+
this.parent = parent;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { SpeedUIScreen };
|
|
12
|
+
//# sourceMappingURL=SpeedUIScreen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpeedUIScreen.js","sources":["../../src/data/SpeedUIScreen.ts"],"sourcesContent":["import { SpeedUIRunable } from './SpeedUIRunable';\r\n\r\nexport class SpeedUIScreen extends SpeedUIRunable {\r\n constructor(\r\n label: string,\r\n public getChildren: () => SpeedUIRunable[],\r\n public readonly parent?: SpeedUIRunable,\r\n ) {\r\n super(label, parent);\r\n }\r\n}\r\n"],"names":[],"mappings":";;AAEO,MAAM,sBAAsB,cAAA,CAAe;AAAA,EAChD,WAAA,CACE,KAAA,EACO,WAAA,EACS,MAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,MAAM,CAAA;AAHZ,IAAA,IAAA,CAAA,WAAA,GAAA,WAAA;AACS,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA;AAIpB;;;;"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Collector } from '@apia/validations';
|
|
2
|
+
import { SpeedUIScreen } from '../data/SpeedUIScreen.js';
|
|
3
|
+
import { SpeedUIExecution } from '../data/SpeedUIExecution.js';
|
|
4
|
+
import { SpeedUIForm } from '../data/SpeedUIForm.js';
|
|
5
|
+
import { SpeedUIRunable } from '../data/SpeedUIRunable.js';
|
|
6
|
+
|
|
7
|
+
type SpeedAction = {
|
|
8
|
+
label: string;
|
|
9
|
+
action: () => unknown;
|
|
10
|
+
};
|
|
11
|
+
type SpeedForm = {
|
|
12
|
+
label: string;
|
|
13
|
+
getItems(collector: Collector): void;
|
|
14
|
+
action: (res: any) => unknown;
|
|
15
|
+
};
|
|
16
|
+
type SpeedScreen = {
|
|
17
|
+
children: (() => SpeedItem[]) | SpeedItem[];
|
|
18
|
+
label: string;
|
|
19
|
+
};
|
|
20
|
+
type SpeedItem = SpeedScreen | SpeedAction | SpeedForm;
|
|
21
|
+
declare function isSpeedAction(item: SpeedItem): item is SpeedAction;
|
|
22
|
+
declare function isSpeedForm(item: SpeedItem): item is SpeedForm;
|
|
23
|
+
declare function isSpeedScreen(item: SpeedItem): item is SpeedScreen;
|
|
24
|
+
/**
|
|
25
|
+
* Esta función permite cargar un árbol de SpeedUI desde un objeto sencillo.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
*
|
|
29
|
+
* export const BPASpeedGraph: SpeedScreen = {
|
|
30
|
+
label: 'BPA',
|
|
31
|
+
children: [
|
|
32
|
+
{
|
|
33
|
+
label: 'Using',
|
|
34
|
+
children: [
|
|
35
|
+
{
|
|
36
|
+
label: 'Process',
|
|
37
|
+
children: () => {
|
|
38
|
+
return window.analysisTree.collections.processes
|
|
39
|
+
.getAll()
|
|
40
|
+
.map((c) => {
|
|
41
|
+
return {
|
|
42
|
+
label: c.serialize().title,
|
|
43
|
+
children: [],
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const speedScreen = loadGraph(BPASpeedGraph);
|
|
54
|
+
*/
|
|
55
|
+
declare function loadGraph(level: SpeedScreen, parent?: SpeedUIRunable): SpeedUIScreen;
|
|
56
|
+
declare function loadRunableItem(c: SpeedItem): SpeedUIScreen | SpeedUIExecution | SpeedUIForm;
|
|
57
|
+
|
|
58
|
+
export { type SpeedAction, type SpeedForm, type SpeedItem, type SpeedScreen, isSpeedAction, isSpeedForm, isSpeedScreen, loadGraph, loadRunableItem };
|
|
59
|
+
//# sourceMappingURL=graphLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphLoader.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SpeedUIScreen } from '../data/SpeedUIScreen.js';
|
|
2
|
+
import { SpeedUIExecution } from '../data/SpeedUIExecution.js';
|
|
3
|
+
import { SpeedUIForm } from '../data/SpeedUIForm.js';
|
|
4
|
+
|
|
5
|
+
function isSpeedAction(item) {
|
|
6
|
+
const spi = item;
|
|
7
|
+
return !!spi.label && !!spi.action && Object.keys(spi).length === 2;
|
|
8
|
+
}
|
|
9
|
+
function isSpeedForm(item) {
|
|
10
|
+
const spf = item;
|
|
11
|
+
return !!spf.label && !!spf.action && !!spf.getItems && Object.keys(spf).length === 3;
|
|
12
|
+
}
|
|
13
|
+
function isSpeedScreen(item) {
|
|
14
|
+
const sps = item;
|
|
15
|
+
return !!sps.children && !!sps.label && Object.keys(sps).length === 2 || !!sps.children && !!sps.label && Object.keys(sps).length === 3;
|
|
16
|
+
}
|
|
17
|
+
function loadGraph(level, parent) {
|
|
18
|
+
const screen = new SpeedUIScreen(
|
|
19
|
+
level.label,
|
|
20
|
+
() => {
|
|
21
|
+
const children = Array.isArray(level.children) ? level.children : level.children();
|
|
22
|
+
const newChildren = children.map((c) => {
|
|
23
|
+
if (isSpeedAction(c)) {
|
|
24
|
+
return new SpeedUIExecution(c.label, c.action, screen);
|
|
25
|
+
} else if (isSpeedForm(c)) {
|
|
26
|
+
return new SpeedUIForm(c.label, c.getItems, c.action, screen);
|
|
27
|
+
} else if (isSpeedScreen(c)) {
|
|
28
|
+
return loadGraph(c, screen);
|
|
29
|
+
} else {
|
|
30
|
+
throw new Error("Cannot parse item", c);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return newChildren;
|
|
34
|
+
},
|
|
35
|
+
parent
|
|
36
|
+
);
|
|
37
|
+
return screen;
|
|
38
|
+
}
|
|
39
|
+
function loadRunableItem(c) {
|
|
40
|
+
if (isSpeedAction(c)) {
|
|
41
|
+
return new SpeedUIExecution(c.label, c.action);
|
|
42
|
+
} else if (isSpeedForm(c)) {
|
|
43
|
+
return new SpeedUIForm(c.label, c.getItems, c.action);
|
|
44
|
+
} else if (isSpeedScreen(c)) {
|
|
45
|
+
return loadGraph(c);
|
|
46
|
+
} else {
|
|
47
|
+
throw new Error("Cannot parse item", c);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { isSpeedAction, isSpeedForm, isSpeedScreen, loadGraph, loadRunableItem };
|
|
52
|
+
//# sourceMappingURL=graphLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphLoader.js","sources":["../../src/graphLoader/graphLoader.ts"],"sourcesContent":["import { Collector } from '@apia/validations';\r\nimport { SpeedUIScreen } from '../data/SpeedUIScreen';\r\nimport { SpeedUIExecution } from '../data/SpeedUIExecution';\r\nimport { SpeedUIForm } from '../data/SpeedUIForm';\r\nimport { SpeedUIRunable } from '../data/SpeedUIRunable';\r\n\r\nexport type SpeedAction = {\r\n label: string;\r\n action: () => unknown;\r\n};\r\n\r\nexport type SpeedForm = {\r\n label: string;\r\n getItems(collector: Collector): void;\r\n action: (res: any) => unknown;\r\n};\r\n\r\nexport type SpeedScreen = {\r\n children: (() => SpeedItem[]) | SpeedItem[];\r\n label: string;\r\n};\r\n\r\nexport type SpeedItem = SpeedScreen | SpeedAction | SpeedForm;\r\n\r\nexport function isSpeedAction(item: SpeedItem): item is SpeedAction {\r\n const spi = item as SpeedAction;\r\n return !!spi.label && !!spi.action && Object.keys(spi).length === 2;\r\n}\r\n\r\nexport function isSpeedForm(item: SpeedItem): item is SpeedForm {\r\n const spf = item as SpeedForm;\r\n return (\r\n !!spf.label &&\r\n !!spf.action &&\r\n !!spf.getItems &&\r\n Object.keys(spf).length === 3\r\n );\r\n}\r\n\r\nexport function isSpeedScreen(item: SpeedItem): item is SpeedScreen {\r\n const sps = item as SpeedScreen;\r\n return (\r\n (!!sps.children && !!sps.label && Object.keys(sps).length === 2) ||\r\n (!!sps.children && !!sps.label && Object.keys(sps).length === 3)\r\n );\r\n}\r\n\r\n/**\r\n * Esta función permite cargar un árbol de SpeedUI desde un objeto sencillo.\r\n *\r\n * @example\r\n *\r\n * export const BPASpeedGraph: SpeedScreen = {\r\n label: 'BPA',\r\n children: [\r\n {\r\n label: 'Using',\r\n children: [\r\n {\r\n label: 'Process',\r\n children: () => {\r\n return window.analysisTree.collections.processes\r\n .getAll()\r\n .map((c) => {\r\n return {\r\n label: c.serialize().title,\r\n children: [],\r\n };\r\n });\r\n },\r\n },\r\n ],\r\n },\r\n ],\r\n };\r\n\r\n const speedScreen = loadGraph(BPASpeedGraph);\r\n */\r\nexport function loadGraph(\r\n level: SpeedScreen,\r\n parent?: SpeedUIRunable,\r\n): SpeedUIScreen {\r\n const screen = new SpeedUIScreen(\r\n level.label,\r\n () => {\r\n const children = Array.isArray(level.children)\r\n ? level.children\r\n : level.children();\r\n\r\n const newChildren = children.map((c) => {\r\n if (isSpeedAction(c)) {\r\n return new SpeedUIExecution(c.label, c.action, screen);\r\n } else if (isSpeedForm(c)) {\r\n return new SpeedUIForm(c.label, c.getItems, c.action, screen);\r\n } else if (isSpeedScreen(c)) {\r\n return loadGraph(c, screen);\r\n } else {\r\n throw new Error('Cannot parse item', c);\r\n }\r\n }) as SpeedUIRunable[];\r\n\r\n return newChildren;\r\n },\r\n parent,\r\n );\r\n\r\n return screen;\r\n}\r\n\r\nexport function loadRunableItem(c: SpeedItem) {\r\n if (isSpeedAction(c)) {\r\n return new SpeedUIExecution(c.label, c.action);\r\n } else if (isSpeedForm(c)) {\r\n return new SpeedUIForm(c.label, c.getItems, c.action);\r\n } else if (isSpeedScreen(c)) {\r\n return loadGraph(c);\r\n } else {\r\n throw new Error('Cannot parse item', c);\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;AAwBO,SAAS,cAAc,IAAA,EAAsC;AAClE,EAAA,MAAM,GAAA,GAAM,IAAA;AACZ,EAAA,OAAO,CAAC,CAAC,GAAA,CAAI,KAAA,IAAS,CAAC,CAAC,GAAA,CAAI,MAAA,IAAU,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,CAAE,MAAA,KAAW,CAAA;AACpE;AAEO,SAAS,YAAY,IAAA,EAAoC;AAC9D,EAAA,MAAM,GAAA,GAAM,IAAA;AACZ,EAAA,OACE,CAAC,CAAC,GAAA,CAAI,KAAA,IACN,CAAC,CAAC,GAAA,CAAI,MAAA,IACN,CAAC,CAAC,IAAI,QAAA,IACN,MAAA,CAAO,IAAA,CAAK,GAAG,EAAE,MAAA,KAAW,CAAA;AAEhC;AAEO,SAAS,cAAc,IAAA,EAAsC;AAClE,EAAA,MAAM,GAAA,GAAM,IAAA;AACZ,EAAA,OACG,CAAC,CAAC,GAAA,CAAI,QAAA,IAAY,CAAC,CAAC,GAAA,CAAI,KAAA,IAAS,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,CAAE,MAAA,KAAW,KAC7D,CAAC,CAAC,GAAA,CAAI,QAAA,IAAY,CAAC,CAAC,GAAA,CAAI,KAAA,IAAS,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,CAAE,MAAA,KAAW,CAAA;AAElE;AAiCO,SAAS,SAAA,CACd,OACA,MAAA,EACe;AACf,EAAA,MAAM,SAAS,IAAI,aAAA;AAAA,IACjB,KAAA,CAAM,KAAA;AAAA,IACN,MAAM;AACJ,MAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,KAAA,CAAM,QAAQ,CAAA,GACzC,KAAA,CAAM,QAAA,GACN,KAAA,CAAM,QAAA,EAAS;AAEnB,MAAA,MAAM,WAAA,GAAc,QAAA,CAAS,GAAA,CAAI,CAAC,CAAA,KAAM;AACtC,QAAA,IAAI,aAAA,CAAc,CAAC,CAAA,EAAG;AACpB,UAAA,OAAO,IAAI,gBAAA,CAAiB,CAAA,CAAE,KAAA,EAAO,CAAA,CAAE,QAAQ,MAAM,CAAA;AAAA,SACvD,MAAA,IAAW,WAAA,CAAY,CAAC,CAAA,EAAG;AACzB,UAAA,OAAO,IAAI,YAAY,CAAA,CAAE,KAAA,EAAO,EAAE,QAAA,EAAU,CAAA,CAAE,QAAQ,MAAM,CAAA;AAAA,SAC9D,MAAA,IAAW,aAAA,CAAc,CAAC,CAAA,EAAG;AAC3B,UAAA,OAAO,SAAA,CAAU,GAAG,MAAM,CAAA;AAAA,SAC5B,MAAO;AACL,UAAA,MAAM,IAAI,KAAA,CAAM,mBAAA,EAAqB,CAAC,CAAA;AAAA;AACxC,OACD,CAAA;AAED,MAAA,OAAO,WAAA;AAAA,KACT;AAAA,IACA;AAAA,GACF;AAEA,EAAA,OAAO,MAAA;AACT;AAEO,SAAS,gBAAgB,CAAA,EAAc;AAC5C,EAAA,IAAI,aAAA,CAAc,CAAC,CAAA,EAAG;AACpB,IAAA,OAAO,IAAI,gBAAA,CAAiB,CAAA,CAAE,KAAA,EAAO,EAAE,MAAM,CAAA;AAAA,GAC/C,MAAA,IAAW,WAAA,CAAY,CAAC,CAAA,EAAG;AACzB,IAAA,OAAO,IAAI,WAAA,CAAY,CAAA,CAAE,OAAO,CAAA,CAAE,QAAA,EAAU,EAAE,MAAM,CAAA;AAAA,GACtD,MAAA,IAAW,aAAA,CAAc,CAAC,CAAA,EAAG;AAC3B,IAAA,OAAO,UAAU,CAAC,CAAA;AAAA,GACpB,MAAO;AACL,IAAA,MAAM,IAAI,KAAA,CAAM,mBAAA,EAAqB,CAAC,CAAA;AAAA;AAE1C;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,174 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
readonly parent?: SpeedUIRunable | undefined;
|
|
11
|
-
protected emitter: EventEmitter<{
|
|
12
|
-
cancel: SpeedUIEvent<"cancel", {
|
|
13
|
-
target: SpeedUIRunable;
|
|
14
|
-
}>;
|
|
15
|
-
finish: SpeedUIEvent<"finish", {
|
|
16
|
-
target: SpeedUIRunable;
|
|
17
|
-
}>;
|
|
18
|
-
start: SpeedUIEvent<"start", {
|
|
19
|
-
target: SpeedUIRunable;
|
|
20
|
-
}>;
|
|
21
|
-
}>;
|
|
22
|
-
constructor(label: string, parent?: SpeedUIRunable | undefined);
|
|
23
|
-
getLabel(): string;
|
|
24
|
-
cancel(): void;
|
|
25
|
-
finish(): void;
|
|
26
|
-
protected emit: (typeof this.emitter)['emit'];
|
|
27
|
-
on: <K extends "cancel" | "finish" | "start">(event: K, cb: _apia_util.Callback<{
|
|
28
|
-
cancel: SpeedUIEvent<"cancel", {
|
|
29
|
-
target: SpeedUIRunable;
|
|
30
|
-
}>;
|
|
31
|
-
finish: SpeedUIEvent<"finish", {
|
|
32
|
-
target: SpeedUIRunable;
|
|
33
|
-
}>;
|
|
34
|
-
start: SpeedUIEvent<"start", {
|
|
35
|
-
target: SpeedUIRunable;
|
|
36
|
-
}>;
|
|
37
|
-
}, K>) => _apia_util.UnSubscriber;
|
|
38
|
-
run(): void;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare class SpeedUIScreen extends SpeedUIRunable {
|
|
42
|
-
getChildren: () => SpeedUIRunable[];
|
|
43
|
-
readonly parent?: SpeedUIRunable | undefined;
|
|
44
|
-
constructor(label: string, getChildren: () => SpeedUIRunable[], parent?: SpeedUIRunable | undefined);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
declare class SpeedUIExecution extends SpeedUIRunable {
|
|
48
|
-
label: string;
|
|
49
|
-
cb: () => unknown;
|
|
50
|
-
readonly parent?: SpeedUIRunable | undefined;
|
|
51
|
-
constructor(label: string, cb: () => unknown, parent?: SpeedUIRunable | undefined);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
declare class SpeedUIForm extends SpeedUIRunable {
|
|
55
|
-
protected label: string;
|
|
56
|
-
makeFields: (collector: Collector) => void;
|
|
57
|
-
onConfirm: (fields: any) => unknown;
|
|
58
|
-
readonly parent?: SpeedUIRunable | undefined;
|
|
59
|
-
constructor(label: string, makeFields: (collector: Collector) => void, onConfirm: (fields: any) => unknown, parent?: SpeedUIRunable | undefined);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
type SpeedAction = {
|
|
63
|
-
label: string;
|
|
64
|
-
action: () => unknown;
|
|
65
|
-
};
|
|
66
|
-
type SpeedForm = {
|
|
67
|
-
label: string;
|
|
68
|
-
getItems(collector: Collector): void;
|
|
69
|
-
action: (res: any) => unknown;
|
|
70
|
-
};
|
|
71
|
-
type SpeedScreen = {
|
|
72
|
-
children: (() => SpeedItem[]) | SpeedItem[];
|
|
73
|
-
label: string;
|
|
74
|
-
};
|
|
75
|
-
type SpeedItem = SpeedScreen | SpeedAction | SpeedForm;
|
|
76
|
-
declare function isSpeedAction(item: SpeedItem): item is SpeedAction;
|
|
77
|
-
declare function isSpeedForm(item: SpeedItem): item is SpeedForm;
|
|
78
|
-
declare function isSpeedScreen(item: SpeedItem): item is SpeedScreen;
|
|
79
|
-
/**
|
|
80
|
-
* Esta función permite cargar un árbol de SpeedUI desde un objeto sencillo.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
*
|
|
84
|
-
* export const BPASpeedGraph: SpeedScreen = {
|
|
85
|
-
label: 'BPA',
|
|
86
|
-
children: [
|
|
87
|
-
{
|
|
88
|
-
label: 'Using',
|
|
89
|
-
children: [
|
|
90
|
-
{
|
|
91
|
-
label: 'Process',
|
|
92
|
-
children: () => {
|
|
93
|
-
return window.analysisTree.collections.processes
|
|
94
|
-
.getAll()
|
|
95
|
-
.map((c) => {
|
|
96
|
-
return {
|
|
97
|
-
label: c.serialize().title,
|
|
98
|
-
children: [],
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const speedScreen = loadGraph(BPASpeedGraph);
|
|
109
|
-
*/
|
|
110
|
-
declare function loadGraph(level: SpeedScreen, parent?: SpeedUIRunable): SpeedUIScreen;
|
|
111
|
-
declare function loadRunableItem(c: SpeedItem): SpeedUIScreen | SpeedUIExecution | SpeedUIForm;
|
|
112
|
-
|
|
113
|
-
declare class SpeedUIReactVisitResult {
|
|
114
|
-
/**
|
|
115
|
-
* Esta clase representa el resutlado de una ejecución de SpeedUIReactVisitor.
|
|
116
|
-
*
|
|
117
|
-
* Los valores posibles para result son:
|
|
118
|
-
*
|
|
119
|
-
* - **null**: No hacer nada.
|
|
120
|
-
* - **SpeedUIRunable**: Ejecutar este SpeedUIRunable a continuación.
|
|
121
|
-
* - **'finish'**: Terminar la ejecución del SpeedUIRunable actual.
|
|
122
|
-
* - **'exit'**: Termina la ejecución del SpeedUI
|
|
123
|
-
*/
|
|
124
|
-
readonly result: null | SpeedUIRunable | 'exit' | 'finish';
|
|
125
|
-
constructor(
|
|
126
|
-
/**
|
|
127
|
-
* Esta clase representa el resutlado de una ejecución de SpeedUIReactVisitor.
|
|
128
|
-
*
|
|
129
|
-
* Los valores posibles para result son:
|
|
130
|
-
*
|
|
131
|
-
* - **null**: No hacer nada.
|
|
132
|
-
* - **SpeedUIRunable**: Ejecutar este SpeedUIRunable a continuación.
|
|
133
|
-
* - **'finish'**: Terminar la ejecución del SpeedUIRunable actual.
|
|
134
|
-
* - **'exit'**: Termina la ejecución del SpeedUI
|
|
135
|
-
*/
|
|
136
|
-
result: null | SpeedUIRunable | 'exit' | 'finish');
|
|
137
|
-
}
|
|
138
|
-
interface SpeedUIReactVisitor {
|
|
139
|
-
/**
|
|
140
|
-
* @see SpeedUIReactVisitResult.result
|
|
141
|
-
*/
|
|
142
|
-
visit(host: SpeedUIRunable): Promise<SpeedUIReactVisitResult>;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
declare class SpeedUIFormReact implements SpeedUIReactVisitor {
|
|
146
|
-
visit(host: SpeedUIRunable): Promise<SpeedUIReactVisitResult>;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
declare class SpeedUIScreenReact implements SpeedUIReactVisitor {
|
|
150
|
-
private RenderUI;
|
|
151
|
-
private modal;
|
|
152
|
-
visit(host: SpeedUIRunable): Promise<SpeedUIReactVisitResult>;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
declare class SpeedUIReactBusyError extends Error {
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Esta clase será la encargada de implementar el rol de Visitor en la estructura,
|
|
159
|
-
* decidiendo qué se debe hacer con cada elemento.
|
|
160
|
-
*
|
|
161
|
-
* Además, la clase SpeedUIReact también implementará el patrón Chain of Responsibility,
|
|
162
|
-
* delegando la actuación en cada visita a clases que implementen SpeedUIReactVisitor
|
|
163
|
-
*/
|
|
164
|
-
declare class SpeedUIReact {
|
|
165
|
-
protected visitors: SpeedUIReactVisitor[];
|
|
166
|
-
protected runStack: SpeedUIRunable[];
|
|
167
|
-
constructor();
|
|
168
|
-
findVisitor(fn: (current: SpeedUIReactVisitor) => boolean): void;
|
|
169
|
-
registerVisitor(visitor: SpeedUIReactVisitor): void;
|
|
170
|
-
run(ui: SpeedUIRunable): Promise<void>;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export { type SpeedAction, type SpeedForm, type SpeedItem, type SpeedScreen, SpeedUIExecution, SpeedUIForm, SpeedUIFormReact, SpeedUIReact, SpeedUIReactBusyError, SpeedUIReactVisitResult, type SpeedUIReactVisitor, SpeedUIRunable, SpeedUIScreen, SpeedUIScreenReact, isSpeedAction, isSpeedForm, isSpeedScreen, loadGraph, loadRunableItem };
|
|
1
|
+
export { SpeedAction, SpeedForm, SpeedItem, SpeedScreen, isSpeedAction, isSpeedForm, isSpeedScreen, loadGraph, loadRunableItem } from './graphLoader/graphLoader.js';
|
|
2
|
+
export { SpeedUIExecution } from './data/SpeedUIExecution.js';
|
|
3
|
+
export { SpeedUIForm } from './data/SpeedUIForm.js';
|
|
4
|
+
export { SpeedUIRunable } from './data/SpeedUIRunable.js';
|
|
5
|
+
export { SpeedUIScreen } from './data/SpeedUIScreen.js';
|
|
6
|
+
export { SpeedUIFormReact } from './ui/defaults/SpeedUIFormReact/SpeedUIFormReact.js';
|
|
7
|
+
export { SpeedUIScreenReact } from './ui/defaults/SpeedUIScreenReact/SpeedUIScreenReact.js';
|
|
8
|
+
export { SpeedUIReact, SpeedUIReactBusyError } from './ui/SpeedUIReact.js';
|
|
9
|
+
export { SpeedUIReactVisitResult, SpeedUIReactVisitor } from './ui/SpeedUIReactVisitor.js';
|
|
174
10
|
//# sourceMappingURL=index.d.ts.map
|