@j2inn/fin5-ui-utils 0.0.2 → 0.0.3

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.
Files changed (43) hide show
  1. package/dist_es/fantomProps/fantomPropsToObject.d.ts +8 -0
  2. package/dist_es/fantomProps/fantomPropsToObject.js +176 -0
  3. package/dist_es/fantomProps/fantomPropsToObject.js.map +1 -0
  4. package/dist_es/fantomProps/generateJsonFromFantomPropsFile.d.ts +4 -0
  5. package/dist_es/fantomProps/generateJsonFromFantomPropsFile.js +10 -0
  6. package/dist_es/fantomProps/generateJsonFromFantomPropsFile.js.map +1 -0
  7. package/dist_es/fantomProps/localePropsToJson.d.ts +1 -0
  8. package/dist_es/fantomProps/localePropsToJson.js +19 -0
  9. package/dist_es/fantomProps/localePropsToJson.js.map +1 -0
  10. package/dist_es/fantomProps/readFantomPropsFile.d.ts +5 -0
  11. package/dist_es/fantomProps/readFantomPropsFile.js +33 -0
  12. package/dist_es/fantomProps/readFantomPropsFile.js.map +1 -0
  13. package/dist_es/fin5Top/fin5Top.d.ts +111 -0
  14. package/dist_es/fin5Top/fin5Top.js +52 -0
  15. package/dist_es/fin5Top/fin5Top.js.map +1 -0
  16. package/dist_es/fin5Top/getFin5BinUrl.d.ts +2 -0
  17. package/dist_es/fin5Top/getFin5BinUrl.js +3 -0
  18. package/dist_es/fin5Top/getFin5BinUrl.js.map +1 -0
  19. package/dist_es/fin5Top/openFin5Alarm.d.ts +22 -0
  20. package/dist_es/fin5Top/openFin5Alarm.js +17 -0
  21. package/dist_es/fin5Top/openFin5Alarm.js.map +1 -0
  22. package/dist_es/fin5Top/openFin5Historian.d.ts +3 -0
  23. package/dist_es/fin5Top/openFin5Historian.js +13 -0
  24. package/dist_es/fin5Top/openFin5Historian.js.map +1 -0
  25. package/dist_es/index.d.ts +12 -0
  26. package/dist_es/index.js +22 -0
  27. package/dist_es/index.js.map +1 -0
  28. package/dist_es/react/components/ErrorDisplayer.d.ts +19 -0
  29. package/dist_es/react/components/ErrorDisplayer.jsx +36 -0
  30. package/dist_es/react/components/ErrorDisplayer.jsx.map +1 -0
  31. package/dist_es/react/components/LoadingSpinner.d.ts +3 -0
  32. package/dist_es/react/components/LoadingSpinner.jsx +7 -0
  33. package/dist_es/react/components/LoadingSpinner.jsx.map +1 -0
  34. package/dist_es/react/components/navigation/BasicLayout.d.ts +20 -0
  35. package/dist_es/react/components/navigation/BasicLayout.jsx +100 -0
  36. package/dist_es/react/components/navigation/BasicLayout.jsx.map +1 -0
  37. package/dist_es/react/components/navigation/MenuPage.d.ts +33 -0
  38. package/dist_es/react/components/navigation/MenuPage.jsx +28 -0
  39. package/dist_es/react/components/navigation/MenuPage.jsx.map +1 -0
  40. package/dist_es/react/components/navigation/Router.d.ts +12 -0
  41. package/dist_es/react/components/navigation/Router.jsx +16 -0
  42. package/dist_es/react/components/navigation/Router.jsx.map +1 -0
  43. package/package.json +2 -2
@@ -0,0 +1,8 @@
1
+ export interface Props {
2
+ [key: string]: string;
3
+ }
4
+ /**
5
+ * Convert the given fantom props as string to JS object (@see https://fantom.org/doc/sys/InStream#readProps)
6
+ */
7
+ export default function fantomPropsToObject(props: string): Props;
8
+ export declare function parseFantomProps(readChar: () => number, unreadChar: (char: number) => void): Props;
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Convert the given fantom props as string to JS object (@see https://fantom.org/doc/sys/InStream#readProps)
3
+ */
4
+ export default function fantomPropsToObject(props) {
5
+ let i = 0;
6
+ const readChar = () => {
7
+ if (i < props.length) {
8
+ i++;
9
+ return props.charCodeAt(i - 1);
10
+ }
11
+ else
12
+ return -1;
13
+ };
14
+ const unreadChar = () => {
15
+ if (i > 0) {
16
+ i--;
17
+ }
18
+ };
19
+ return parseFantomProps(readChar, unreadChar);
20
+ }
21
+ var UTF_8;
22
+ (function (UTF_8) {
23
+ UTF_8[UTF_8["tab"] = 9] = "tab";
24
+ UTF_8[UTF_8["lf"] = 10] = "lf";
25
+ UTF_8[UTF_8["cr"] = 13] = "cr";
26
+ UTF_8[UTF_8["space"] = 32] = "space";
27
+ UTF_8[UTF_8["numberSign"] = 35] = "numberSign";
28
+ UTF_8[UTF_8["asterisk"] = 42] = "asterisk";
29
+ UTF_8[UTF_8["solidus"] = 47] = "solidus";
30
+ UTF_8[UTF_8["equalSign"] = 61] = "equalSign";
31
+ UTF_8[UTF_8["reverseSolidus"] = 92] = "reverseSolidus";
32
+ UTF_8[UTF_8["n"] = 110] = "n";
33
+ UTF_8[UTF_8["r"] = 114] = "r";
34
+ UTF_8[UTF_8["t"] = 116] = "t";
35
+ UTF_8[UTF_8["u"] = 117] = "u";
36
+ })(UTF_8 || (UTF_8 = {}));
37
+ const isSpace = (char) => char === UTF_8.space ||
38
+ char === UTF_8.tab ||
39
+ char === UTF_8.lf ||
40
+ char === UTF_8.cr;
41
+ const hex = function (c) {
42
+ if (48 <= c && c <= 57)
43
+ return c - 48;
44
+ if (97 <= c && c <= 102)
45
+ return c - 97 + 10;
46
+ if (65 <= c && c <= 70)
47
+ return c - 65 + 10;
48
+ return -1;
49
+ };
50
+ /*
51
+ * Parse the Fantom props file character by character.
52
+ * Implementation based on https://github.com/fantom-lang/fantom/blob/master/src/sys/js/fan/InStream.js
53
+ */
54
+ export function parseFantomProps(readChar, unreadChar) {
55
+ const props = {};
56
+ let name = '';
57
+ let value = null;
58
+ let inBlockComment = 0;
59
+ let inEndOfLineComment = false;
60
+ let char = UTF_8.space, lastChar = UTF_8.space;
61
+ let lineNum = 1;
62
+ while (true) {
63
+ lastChar = char;
64
+ char = readChar();
65
+ if (char < 0)
66
+ break;
67
+ // end of line
68
+ if (char == UTF_8.lf || char == UTF_8.cr) {
69
+ inEndOfLineComment = false;
70
+ if (lastChar == UTF_8.cr && char == UTF_8.lf)
71
+ continue;
72
+ const n = name.trim();
73
+ if (value !== null) {
74
+ props[n] = value.trim();
75
+ name = '';
76
+ value = null;
77
+ }
78
+ else if (n.length > 0)
79
+ throw new Error('Invalid name/value pair [Line ' + lineNum + ']');
80
+ lineNum++;
81
+ continue;
82
+ }
83
+ // if in comment
84
+ if (inEndOfLineComment)
85
+ continue;
86
+ // block comment
87
+ if (inBlockComment > 0) {
88
+ if (lastChar == UTF_8.solidus && char == UTF_8.asterisk)
89
+ inBlockComment++;
90
+ if (lastChar == UTF_8.asterisk && char == UTF_8.solidus)
91
+ inBlockComment--;
92
+ continue;
93
+ }
94
+ // equal
95
+ if (char == UTF_8.equalSign && value === null) {
96
+ value = '';
97
+ continue;
98
+ }
99
+ // line comment
100
+ if (char === UTF_8.numberSign &&
101
+ (lastChar == UTF_8.lf || lastChar == UTF_8.cr)) {
102
+ inEndOfLineComment = true;
103
+ continue;
104
+ }
105
+ // end of line comment
106
+ if (char == UTF_8.solidus && isSpace(lastChar)) {
107
+ const peek = readChar();
108
+ if (peek < 0)
109
+ break;
110
+ if (peek == UTF_8.solidus) {
111
+ inEndOfLineComment = true;
112
+ continue;
113
+ }
114
+ if (peek == UTF_8.asterisk) {
115
+ inBlockComment++;
116
+ continue;
117
+ }
118
+ unreadChar(peek);
119
+ }
120
+ // escape or line continuation
121
+ if (char == UTF_8.reverseSolidus) {
122
+ let peek = readChar();
123
+ if (peek < 0)
124
+ break;
125
+ else if (peek == UTF_8.n)
126
+ char = UTF_8.lf;
127
+ else if (peek == UTF_8.r)
128
+ char = UTF_8.cr;
129
+ else if (peek == UTF_8.t)
130
+ char = UTF_8.tab;
131
+ else if (peek == UTF_8.reverseSolidus)
132
+ char = UTF_8.reverseSolidus;
133
+ else if (peek == UTF_8.cr || peek == UTF_8.lf) {
134
+ // line continuation
135
+ lineNum++;
136
+ if (peek == UTF_8.cr) {
137
+ peek = readChar();
138
+ if (peek != UTF_8.lf)
139
+ unreadChar(peek);
140
+ }
141
+ while (true) {
142
+ peek = readChar();
143
+ if (peek == UTF_8.space || peek == UTF_8.tab)
144
+ continue;
145
+ unreadChar(peek);
146
+ break;
147
+ }
148
+ continue;
149
+ }
150
+ else if (peek == UTF_8.u) {
151
+ const n3 = hex(readChar());
152
+ const n2 = hex(readChar());
153
+ const n1 = hex(readChar());
154
+ const n0 = hex(readChar());
155
+ if (n3 < 0 || n2 < 0 || n1 < 0 || n0 < 0)
156
+ throw new Error('Invalid hex value for \\uxxxx [Line ' + lineNum + ']');
157
+ char = (n3 << 12) | (n2 << 8) | (n1 << 4) | n0;
158
+ }
159
+ else
160
+ throw new Error('Invalid escape sequence [Line ' + lineNum + ']');
161
+ }
162
+ // normal character
163
+ if (value === null)
164
+ name += String.fromCharCode(char);
165
+ else
166
+ value += String.fromCharCode(char);
167
+ }
168
+ const n = name.trim();
169
+ if (value !== null) {
170
+ props[n] = value.trim();
171
+ }
172
+ else if (n.length > 0)
173
+ throw new Error('Invalid name/value pair [Line ' + lineNum + ']');
174
+ return props;
175
+ }
176
+ //# sourceMappingURL=fantomPropsToObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fantomPropsToObject.js","sourceRoot":"","sources":["../../src/fantomProps/fantomPropsToObject.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,KAAa;IACxD,IAAI,CAAC,GAAG,CAAC,CAAA;IAET,MAAM,QAAQ,GAAG,GAAW,EAAE;QAC7B,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE;YACrB,CAAC,EAAE,CAAA;YACH,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;SAC9B;;YAAM,OAAO,CAAC,CAAC,CAAA;IACjB,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACvB,IAAI,CAAC,GAAG,CAAC,EAAE;YACV,CAAC,EAAE,CAAA;SACH;IACF,CAAC,CAAA;IAED,OAAO,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;AAC9C,CAAC;AAED,IAAK,KAcJ;AAdD,WAAK,KAAK;IACT,+BAAO,CAAA;IACP,8BAAO,CAAA;IACP,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G,IAAI,CAAC,IAAI,EAAE,CAAA;IACrB,IAAI,KAAK,KAAK,IAAI,EAAE;QACnB,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;KACvB;SAAM,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,gCAAgC,GAAG,OAAO,GAAG,GAAG,CAAC,CAAA;IAElE,OAAO,KAAK,CAAA;AACb,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Converts props file to json file.
3
+ */
4
+ export default function generateJsonFromFantomPropsFile(inputPath?: string, outputPath?: string): Promise<void>;
@@ -0,0 +1,10 @@
1
+ import * as fs from 'fs';
2
+ import readFantomPropsFile from './readFantomPropsFile';
3
+ /**
4
+ * Converts props file to json file.
5
+ */
6
+ export default async function generateJsonFromFantomPropsFile(inputPath = '../locale/en.props', outputPath = './src/localeKeys.json') {
7
+ const result = await readFantomPropsFile(inputPath);
8
+ fs.writeFileSync(outputPath, JSON.stringify(result, null, '\t'));
9
+ }
10
+ //# sourceMappingURL=generateJsonFromFantomPropsFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateJsonFromFantomPropsFile.js","sourceRoot":"","sources":["../../src/fantomProps/generateJsonFromFantomPropsFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AAEvD;;GAEG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,+BAA+B,CAC5D,SAAS,GAAG,oBAAoB,EAChC,UAAU,GAAG,uBAAuB;IAEpC,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,SAAS,CAAC,CAAA;IAEnD,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AACjE,CAAC"}
@@ -0,0 +1 @@
1
+ export default function localePropsToJson(inputPath?: string, outputPath?: string, includeOnlyPrefixedBy?: string): Promise<void>;
@@ -0,0 +1,19 @@
1
+ import * as fs from 'fs';
2
+ import readFantomPropsFile from './readFantomPropsFile';
3
+ export default async function localePropsToJson(inputPath = '../locale/en.props', outputPath = './src/localeKeys.json', includeOnlyPrefixedBy = '') {
4
+ const props = await readFantomPropsFile(inputPath);
5
+ let localeKeys;
6
+ if (includeOnlyPrefixedBy) {
7
+ localeKeys = Object.fromEntries(Object.keys(props)
8
+ .filter((key) => key.startsWith(includeOnlyPrefixedBy))
9
+ .map((key) => [
10
+ key.replace(includeOnlyPrefixedBy, '').replaceAll('.', '_'),
11
+ key,
12
+ ]));
13
+ }
14
+ else {
15
+ localeKeys = Object.fromEntries(Object.keys(props).map((key) => [key.replaceAll('.', '_'), key]));
16
+ }
17
+ fs.writeFileSync(outputPath, JSON.stringify(localeKeys, null, '\t'));
18
+ }
19
+ //# sourceMappingURL=localePropsToJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localePropsToJson.js","sourceRoot":"","sources":["../../src/fantomProps/localePropsToJson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AAEvD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,iBAAiB,CAC9C,SAAS,GAAG,oBAAoB,EAChC,UAAU,GAAG,uBAAuB,EACpC,qBAAqB,GAAG,EAAE;IAE1B,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,SAAS,CAAC,CAAA;IAElD,IAAI,UAAU,CAAA;IACd,IAAI,qBAAqB,EAAE;QAC1B,UAAU,GAAG,MAAM,CAAC,WAAW,CAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aAChB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;aACtD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;YACb,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;YAC3D,GAAG;SACH,CAAC,CACH,CAAA;KACD;SAAM;QACN,UAAU,GAAG,MAAM,CAAC,WAAW,CAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAChE,CAAA;KACD;IAED,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AACrE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Props } from './fantomPropsToObject';
2
+ /**
3
+ * Asynchronously read the given Fantom props file to JS object (@see https://fantom.org/doc/sys/InStream#readProps)
4
+ */
5
+ export default function readFantomPropsFile(path: string): Promise<Props>;
@@ -0,0 +1,33 @@
1
+ import * as fs from 'fs';
2
+ import { parseFantomProps } from './fantomPropsToObject';
3
+ /**
4
+ * Asynchronously read the given Fantom props file to JS object (@see https://fantom.org/doc/sys/InStream#readProps)
5
+ */
6
+ export default function readFantomPropsFile(path) {
7
+ return new Promise((resolve, reject) => {
8
+ const fileStream = fs.createReadStream(path);
9
+ fileStream.once('readable', function () {
10
+ const readChar = () => {
11
+ return fileStream.read(1)?.[0] ?? -1;
12
+ };
13
+ const unreadChar = (char) => {
14
+ return fileStream.unshift(new Uint8Array([char]));
15
+ };
16
+ try {
17
+ resolve(parseFantomProps(readChar, unreadChar));
18
+ }
19
+ catch (error) {
20
+ reject(error);
21
+ }
22
+ finally {
23
+ try {
24
+ fileStream.close();
25
+ }
26
+ catch (err) {
27
+ console.error(err);
28
+ }
29
+ }
30
+ });
31
+ });
32
+ }
33
+ //# sourceMappingURL=readFantomPropsFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readFantomPropsFile.js","sourceRoot":"","sources":["../../src/fantomProps/readFantomPropsFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,gBAAgB,EAAS,MAAM,uBAAuB,CAAA;AAE/D;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,IAAY;IACvD,OAAO,IAAI,OAAO,CAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;QAE5C,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE;YAC3B,MAAM,QAAQ,GAAG,GAAW,EAAE;gBAC7B,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;YACrC,CAAC,CAAA;YAED,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE;gBACnC,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAClD,CAAC,CAAA;YAED,IAAI;gBACH,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAA;aAC/C;YAAC,OAAO,KAAK,EAAE;gBACf,MAAM,CAAC,KAAK,CAAC,CAAA;aACb;oBAAS;gBACT,IAAI;oBACH,UAAU,CAAC,KAAK,EAAE,CAAA;iBAClB;gBAAC,OAAO,GAAG,EAAE;oBACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;iBAClB;aACD;QACF,CAAC,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,111 @@
1
+ import { AlarmFilter } from './openFin5Alarm';
2
+ import { HistorianArgs, HistorianType } from './openFin5Historian';
3
+ export declare const getFin5top: (notifyFailure?: () => void) => Fin5Top | null;
4
+ export declare const fin5Top: Fin5Top | null;
5
+ export declare function isWindowTopFin5(notifyFailure?: () => void): boolean;
6
+ export interface Fin5Top {
7
+ app: Fin5App;
8
+ languageManager: LanguageManager;
9
+ finstack?: {
10
+ projectName?: string;
11
+ device?: {
12
+ currentUser?: {
13
+ toObj: () => unknown;
14
+ };
15
+ };
16
+ };
17
+ }
18
+ export interface Fin5App {
19
+ /**
20
+ * Toggles FIN right side menu.
21
+ * The forceTo parameter can be used to enforce a specific status instead of a toggling behaviour,
22
+ * where: true -> menu closed, false -> menu open
23
+ */
24
+ ToggleCollapse: (forceTo: boolean) => void;
25
+ /**
26
+ * Returns current target record id.
27
+ */
28
+ TargetRef: () => TargetRef;
29
+ /**
30
+ * Updates the current target record id.
31
+ * Navigates the current app to the specified
32
+ * <code>targetRef</code>. Target Ref is the id of any equip/site etc..
33
+ */
34
+ NavigateToTargetRef: (targetRef: TargetRef, maintainView: boolean) => void;
35
+ /**
36
+ * Navigates to a particular application (trends, notes .. etc) under a specific target.
37
+ * @param {Fin5AppNames} appName name of the application
38
+ * @param {TargetRef} targetRef id of the target. Is the id of the equip/site.. etc to where the app should navigate
39
+ * @param {boolean} skipRef is the flag indicating where to ignore the target ref if not mentioned. If this flag is true and the target ref is not provided, then the navigation will be made to the root target ref and will not be obtained from where the app already is
40
+ */
41
+ NavigateToApp: (appName: Fin5AppNames, targetRef?: TargetRef, skipRef?: boolean, params?: string[]) => Promise<void>;
42
+ /**
43
+ * Method to open a url on the application LHS. The LHS here is the <code>iframe</code> where all
44
+ * the graphics etc are opened.
45
+ *
46
+ * @method LoadApplication
47
+ * @param {string} url - Is the url which is to be loaded
48
+ * @param {string} title - Specifies the title to be displayed on the iframe object
49
+ * @param {string} targetId - Specifies the id of the equip (etc) to which the main navigation update.
50
+ * @param {object} settings - extra settings that can be passed in when calling hte func
51
+ * @param {boolean} settings.collapse - flag indicating the collapse state of the RHS app panel
52
+ */
53
+ LoadApplication: (url: string, title?: string, targetRef?: TargetRef, settings?: {
54
+ collapse?: boolean;
55
+ }) => Promise<void>;
56
+ /**
57
+ * Get the filters object from the alarms application.
58
+ */
59
+ GetAlarmFilters: () => AlarmFilter;
60
+ /**
61
+ * Sets the filter settings for the alarms.
62
+ * @param {AlarmFilter} filters Is the object that defines the filter properties.
63
+ * @param {boolean} historical Flag indicating if the filter properties need to be applied to the historical alarms.
64
+ */
65
+ SetAlarmFilters: (filters: AlarmFilter, historical?: boolean) => void;
66
+ /**
67
+ * Navigates to the historian app and loads the graphs as per the passed arguments. The graph will be drawn for the passed "point" ids or for a "query" id or for a "string" query
68
+ * @param {HistorianType} type is the type of graph arg. Available args are:
69
+ * - point : the args will have point ids in an array
70
+ * - query : the arg will be the id of a saved chart query
71
+ * - string : the arg will be a query string
72
+ * @param {HistorianArgs} args is the array/string for point ids, the query id or the raw query string
73
+ */
74
+ OpenHistorianWithOptions: (type: HistorianType, args: HistorianArgs) => void;
75
+ findComponent: (name: string) => Fin5AppComponent;
76
+ /**
77
+ * @see https://ractive.js.org/api/#ractiveobserve
78
+ */
79
+ observe: (keypath: string, callback: (newValue: unknown, oldValue: unknown, keypath: string) => void) => {
80
+ cancel: () => void;
81
+ };
82
+ set: (name: string, value: unknown) => Promise<undefined>;
83
+ get: (name: string) => Promise<unknown>;
84
+ APP_NAMES: typeof Fin5AppNames;
85
+ }
86
+ export declare enum Fin5AppNames {
87
+ EQUIP = "equip",
88
+ GRAPHICS = "graphics",
89
+ POINTS = "points",
90
+ ALARMS = "alarms",
91
+ NOTES = "notes",
92
+ SUMMARY = "summary",
93
+ SUMMARY_TOPICS = "summaryList",
94
+ TOOLS = "tools",
95
+ SCHEDULES = "schedules",
96
+ SCHEDULE_LIST = "scheduleList",
97
+ HISTORIAN = "trends",
98
+ TREND_LIST = "trendList",
99
+ SEARCH = "search",
100
+ LOGOUT = "logout",
101
+ GENERIC = "generic",
102
+ REPORTS = "reports"
103
+ }
104
+ interface LanguageManager {
105
+ currentLang: string;
106
+ }
107
+ interface Fin5AppComponent {
108
+ set: (value: unknown) => Promise<undefined>;
109
+ }
110
+ export declare type TargetRef = string | null | undefined;
111
+ export {};
@@ -0,0 +1,52 @@
1
+ class Fin5TopRetriever {
2
+ static _fin5Top;
3
+ static get fin5Top() {
4
+ return this.getFin5top();
5
+ }
6
+ static getFin5top = (notifyFailure) => {
7
+ if (this._fin5Top === undefined) {
8
+ this._fin5Top = isWindowTopFin5(notifyFailure)
9
+ ? window.top // Cast to unknown to obscure properties from Window to simplify usage.
10
+ : null;
11
+ }
12
+ return this._fin5Top;
13
+ };
14
+ }
15
+ export const getFin5top = Fin5TopRetriever.getFin5top;
16
+ export const fin5Top = Fin5TopRetriever.fin5Top;
17
+ export function isWindowTopFin5(notifyFailure) {
18
+ try {
19
+ window?.top?.origin;
20
+ if (window.top.finstack) {
21
+ return true;
22
+ }
23
+ else {
24
+ throw new Error('FIN 5 top not available');
25
+ }
26
+ }
27
+ catch (err) {
28
+ console.warn(err);
29
+ notifyFailure?.();
30
+ return false;
31
+ }
32
+ }
33
+ export var Fin5AppNames;
34
+ (function (Fin5AppNames) {
35
+ Fin5AppNames["EQUIP"] = "equip";
36
+ Fin5AppNames["GRAPHICS"] = "graphics";
37
+ Fin5AppNames["POINTS"] = "points";
38
+ Fin5AppNames["ALARMS"] = "alarms";
39
+ Fin5AppNames["NOTES"] = "notes";
40
+ Fin5AppNames["SUMMARY"] = "summary";
41
+ Fin5AppNames["SUMMARY_TOPICS"] = "summaryList";
42
+ Fin5AppNames["TOOLS"] = "tools";
43
+ Fin5AppNames["SCHEDULES"] = "schedules";
44
+ Fin5AppNames["SCHEDULE_LIST"] = "scheduleList";
45
+ Fin5AppNames["HISTORIAN"] = "trends";
46
+ Fin5AppNames["TREND_LIST"] = "trendList";
47
+ Fin5AppNames["SEARCH"] = "search";
48
+ Fin5AppNames["LOGOUT"] = "logout";
49
+ Fin5AppNames["GENERIC"] = "generic";
50
+ Fin5AppNames["REPORTS"] = "reports";
51
+ })(Fin5AppNames || (Fin5AppNames = {}));
52
+ //# sourceMappingURL=fin5Top.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fin5Top.js","sourceRoot":"","sources":["../../src/fin5Top/fin5Top.ts"],"names":[],"mappings":"AAGA,MAAM,gBAAgB;IACb,MAAM,CAAC,QAAQ,CAAgB;IAEvC,MAAM,KAAK,OAAO;QACjB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAA;IACzB,CAAC;IACD,MAAM,CAAC,UAAU,GAAG,CAAC,aAA0B,EAAkB,EAAE;QAClE,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAChC,IAAI,CAAC,QAAQ,GAAG,eAAe,CAAC,aAAa,CAAC;gBAC7C,CAAC,CAAE,MAAM,CAAC,GAA0B,CAAC,uEAAuE;gBAC5G,CAAC,CAAC,IAAI,CAAA;SACP;QACD,OAAO,IAAI,CAAC,QAAQ,CAAA;IACrB,CAAC,CAAA;;AAGF,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAA;AAErD,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAA;AAE/C,MAAM,UAAU,eAAe,CAAC,aAA0B;IACzD,IAAI;QACH,MAAM,EAAE,GAAG,EAAE,MAAM,CAAA;QACnB,IAAK,MAAM,CAAC,GAA0B,CAAC,QAAQ,EAAE;YAChD,OAAO,IAAI,CAAA;SACX;aAAM;YACN,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;SAC1C;KACD;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACjB,aAAa,EAAE,EAAE,CAAA;QACjB,OAAO,KAAK,CAAA;KACZ;AACF,CAAC;AA8GD,MAAM,CAAN,IAAY,YAiBX;AAjBD,WAAY,YAAY;IACvB,+BAAe,CAAA;IACf,qCAAqB,CAAA;IACrB,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;IACjB,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,8CAA8B,CAAA;IAC9B,+BAAe,CAAA;IACf,uCAAuB,CAAA;IACvB,8CAA8B,CAAA;IAC9B,oCAAoB,CAAA;IACpB,wCAAwB,CAAA;IACxB,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;IACjB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;AACpB,CAAC,EAjBW,YAAY,KAAZ,YAAY,QAiBvB"}
@@ -0,0 +1,2 @@
1
+ import { HRef } from 'haystack-core';
2
+ export declare const getFin5BinUrl: (id: HRef) => string;
@@ -0,0 +1,3 @@
1
+ import { fin5Top } from './fin5Top';
2
+ export const getFin5BinUrl = (id) => `/finGetFile/${fin5Top?.finstack?.projectName}?fileRef=${id?.toString()}`;
3
+ //# sourceMappingURL=getFin5BinUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFin5BinUrl.js","sourceRoot":"","sources":["../../src/fin5Top/getFin5BinUrl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAQ,EAAU,EAAE,CACjD,eAAe,OAAO,EAAE,QAAQ,EAAE,WAAW,YAAY,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { TargetRef } from './fin5Top';
2
+ export interface AlarmFilterTypes {
3
+ alarms: boolean;
4
+ events: boolean;
5
+ acks: boolean;
6
+ }
7
+ export interface AlarmFilter {
8
+ range?: string;
9
+ priorityThreshold?: string;
10
+ acked?: boolean;
11
+ unacked?: boolean;
12
+ inAlarm?: boolean;
13
+ notInAlarm?: boolean;
14
+ search?: string;
15
+ types?: AlarmFilterTypes;
16
+ }
17
+ export declare type AlarmOptions = {
18
+ targetRef?: TargetRef;
19
+ filter: AlarmFilter;
20
+ historical?: boolean;
21
+ };
22
+ export declare const openFin5AlarmsApp: ({ targetRef, filter, historical, }: AlarmOptions) => Promise<void>;
@@ -0,0 +1,17 @@
1
+ //////////////////////////////////////////////////////////////////////////
2
+ // Alarms
3
+ //////////////////////////////////////////////////////////////////////////
4
+ import { fin5Top } from './fin5Top';
5
+ export const openFin5AlarmsApp = async ({ targetRef, filter, historical = false, }) => {
6
+ await fin5Top?.app.NavigateToApp(fin5Top?.app?.APP_NAMES?.ALARMS, targetRef);
7
+ fin5Top?.app.ToggleCollapse(false);
8
+ let alarmFilters = fin5Top?.app?.GetAlarmFilters() ?? {};
9
+ if (filter) {
10
+ alarmFilters = {
11
+ ...alarmFilters,
12
+ ...filter,
13
+ };
14
+ }
15
+ fin5Top?.app?.SetAlarmFilters(alarmFilters, historical);
16
+ };
17
+ //# sourceMappingURL=openFin5Alarm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openFin5Alarm.js","sourceRoot":"","sources":["../../src/fin5Top/openFin5Alarm.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,SAAS;AACT,0EAA0E;AAE1E,OAAO,EAAE,OAAO,EAAa,MAAM,WAAW,CAAA;AAyB9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACvC,SAAS,EACT,MAAM,EACN,UAAU,GAAG,KAAK,GACJ,EAAiB,EAAE;IACjC,MAAM,OAAO,EAAE,GAAG,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;IAC5E,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IAElC,IAAI,YAAY,GAAG,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,CAAA;IACxD,IAAI,MAAM,EAAE;QACX,YAAY,GAAG;YACd,GAAG,YAAY;YACf,GAAG,MAAM;SACT,CAAA;KACD;IAED,OAAO,EAAE,GAAG,EAAE,eAAe,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;AACxD,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare type HistorianType = 'point' | 'query' | 'string';
2
+ export declare type HistorianArgs = string | (string | undefined)[];
3
+ export declare const openFin5HistorianApp: (queryType?: HistorianType, args?: HistorianArgs) => Promise<void>;
@@ -0,0 +1,13 @@
1
+ //////////////////////////////////////////////////////////////////////////
2
+ // Historian
3
+ //////////////////////////////////////////////////////////////////////////
4
+ import { fin5Top } from './fin5Top';
5
+ export const openFin5HistorianApp = async (queryType, args) => {
6
+ if (fin5Top) {
7
+ queryType && args
8
+ ? fin5Top.app.OpenHistorianWithOptions(queryType, args)
9
+ : fin5Top.app.NavigateToApp(fin5Top.app.APP_NAMES.TREND_LIST);
10
+ fin5Top?.app.ToggleCollapse(false);
11
+ }
12
+ };
13
+ //# sourceMappingURL=openFin5Historian.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openFin5Historian.js","sourceRoot":"","sources":["../../src/fin5Top/openFin5Historian.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,YAAY;AACZ,0EAA0E;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAMnC,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACxC,SAAyB,EACzB,IAAoB,EACJ,EAAE;IAClB,IAAI,OAAO,EAAE;QACZ,SAAS,IAAI,IAAI;YAChB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,SAAS,EAAE,IAAI,CAAC;YACvD,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QAC9D,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;KAClC;AACF,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ export * from './fantomProps/fantomPropsToObject';
2
+ export * from './fantomProps/generateJsonFromFantomPropsFile';
3
+ export * from './fantomProps/readFantomPropsFile';
4
+ export * from './fin5Top/fin5Top';
5
+ export * from './fin5Top/getFin5BinUrl';
6
+ export * from './fin5Top/openFin5Alarm';
7
+ export * from './fin5Top/openFin5Historian';
8
+ export * from './react/components/ErrorDisplayer';
9
+ export * from './react/components/LoadingSpinner';
10
+ export * from './react/components/navigation/BasicLayout';
11
+ export * from './react/components/navigation/MenuPage';
12
+ export * from './react/components/navigation/Router';
@@ -0,0 +1,22 @@
1
+ //////////////////////////////////////////////////////////////////////////
2
+ // Fantom Props
3
+ //////////////////////////////////////////////////////////////////////////
4
+ export * from './fantomProps/fantomPropsToObject';
5
+ export * from './fantomProps/generateJsonFromFantomPropsFile';
6
+ export * from './fantomProps/readFantomPropsFile';
7
+ //////////////////////////////////////////////////////////////////////////
8
+ // Fin5 APIs related modules
9
+ //////////////////////////////////////////////////////////////////////////
10
+ export * from './fin5Top/fin5Top';
11
+ export * from './fin5Top/getFin5BinUrl';
12
+ export * from './fin5Top/openFin5Alarm';
13
+ export * from './fin5Top/openFin5Historian';
14
+ //////////////////////////////////////////////////////////////////////////
15
+ // React components
16
+ //////////////////////////////////////////////////////////////////////////
17
+ export * from './react/components/ErrorDisplayer';
18
+ export * from './react/components/LoadingSpinner';
19
+ export * from './react/components/navigation/BasicLayout';
20
+ export * from './react/components/navigation/MenuPage';
21
+ export * from './react/components/navigation/Router';
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,eAAe;AACf,0EAA0E;AAC1E,cAAc,mCAAmC,CAAA;AACjD,cAAc,+CAA+C,CAAA;AAC7D,cAAc,mCAAmC,CAAA;AACjD,0EAA0E;AAC1E,4BAA4B;AAC5B,0EAA0E;AAC1E,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,6BAA6B,CAAA;AAC3C,0EAA0E;AAC1E,mBAAmB;AACnB,0EAA0E;AAC1E,cAAc,mCAAmC,CAAA;AACjD,cAAc,mCAAmC,CAAA;AACjD,cAAc,2CAA2C,CAAA;AACzD,cAAc,wCAAwC,CAAA;AACtD,cAAc,sCAAsC,CAAA"}
@@ -0,0 +1,19 @@
1
+ import React, { ErrorInfo, ReactNode } from 'react';
2
+ interface ErrorBoundaryState {
3
+ error?: Error;
4
+ }
5
+ interface ErrorBoundaryProps {
6
+ children: ReactNode;
7
+ }
8
+ export declare class DefaultErrorBoundary extends React.Component<ErrorBoundaryProps> {
9
+ state: ErrorBoundaryState;
10
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
11
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
12
+ render(): ReactNode;
13
+ }
14
+ export interface ErrorDisplayerProps {
15
+ error: Error;
16
+ extra: React.ReactNode;
17
+ }
18
+ export declare const ErrorDisplayer: React.FC<ErrorDisplayerProps>;
19
+ export {};
@@ -0,0 +1,36 @@
1
+ import { Button, Collapse, Container, Result, Typography } from '@j2inn/ui';
2
+ import React from 'react';
3
+ export class DefaultErrorBoundary extends React.Component {
4
+ state = {};
5
+ static getDerivedStateFromError(error) {
6
+ // Update state so the next render will show the fallback UI.
7
+ return { error: error };
8
+ }
9
+ componentDidCatch(error, errorInfo) {
10
+ // You can also log the error to an error reporting service
11
+ console.error(error, errorInfo);
12
+ }
13
+ render() {
14
+ if (this.state.error) {
15
+ // You can render any custom fallback UI
16
+ return (<ErrorDisplayer error={this.state.error} extra={[
17
+ <Button type='primary' key='refresh' onClick={() => window.location.reload()}>
18
+ Refresh The Page
19
+ </Button>,
20
+ ]}/>);
21
+ }
22
+ return this.props.children;
23
+ }
24
+ }
25
+ export const ErrorDisplayer = ({ error, extra, }) => {
26
+ return (<Result status='error' title='Ouch... Something Went Wrong' subTitle={<Container center>
27
+ <Collapse style={{ width: 600, textAlign: 'left' }}>
28
+ <Collapse.Panel header={`${error.toString()}`} key='1'>
29
+ <Typography.Text style={{ width: 400 }}>
30
+ {error.stack}
31
+ </Typography.Text>
32
+ </Collapse.Panel>
33
+ </Collapse>
34
+ </Container>} extra={extra}/>);
35
+ };
36
+ //# sourceMappingURL=ErrorDisplayer.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorDisplayer.jsx","sourceRoot":"","sources":["../../../src/react/components/ErrorDisplayer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC3E,OAAO,KAA+B,MAAM,OAAO,CAAA;AAUnD,MAAM,OAAO,oBAAqB,SAAQ,KAAK,CAAC,SAA6B;IACnE,KAAK,GAAuB,EAAE,CAAA;IAEvC,MAAM,CAAC,wBAAwB,CAAC,KAAY;QAC3C,6DAA6D;QAC7D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACxB,CAAC;IAEQ,iBAAiB,CAAC,KAAY,EAAE,SAAoB;QAC5D,2DAA2D;QAC3D,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IAChC,CAAC;IAEQ,MAAM;QACd,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;YACrB,wCAAwC;YACxC,OAAO,CACN,CAAC,cAAc,CACd,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CACxB,KAAK,CAAC,CAAC;oBACN,CAAC,MAAM,CACN,IAAI,CAAC,SAAS,CACd,GAAG,CAAC,SAAS,CACb,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CACxC;;MACD,EAAE,MAAM,CAAC;iBACT,CAAC,EACD,CACF,CAAA;SACD;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAA;IAC3B,CAAC;CACD;AAOD,MAAM,CAAC,MAAM,cAAc,GAAkC,CAAC,EAC7D,KAAK,EACL,KAAK,GACL,EAAE,EAAE;IACJ,OAAO,CACN,CAAC,MAAM,CACN,MAAM,CAAC,OAAO,CACd,KAAK,CAAC,8BAA8B,CACpC,QAAQ,CAAC,CACR,CAAC,SAAS,CAAC,MAAM,CAChB;KAAA,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAClD;MAAA,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CACrD;OAAA,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CACtC;QAAA,CAAC,KAAK,CAAC,KAAK,CACb;OAAA,EAAE,UAAU,CAAC,IAAI,CAClB;MAAA,EAAE,QAAQ,CAAC,KAAK,CACjB;KAAA,EAAE,QAAQ,CACX;IAAA,EAAE,SAAS,CAAC,CACZ,CACD,KAAK,CAAC,CAAC,KAAK,CAAC,EACZ,CACF,CAAA;AACF,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const LoadingSpinner: React.FC;
3
+ export default LoadingSpinner;
@@ -0,0 +1,7 @@
1
+ import { Container, Spin } from '@j2inn/ui';
2
+ import React from 'react';
3
+ const LoadingSpinner = () => (<Container center style={{ height: '100%', width: '100%' }}>
4
+ <Spin size='large'></Spin>
5
+ </Container>);
6
+ export default LoadingSpinner;
7
+ //# sourceMappingURL=LoadingSpinner.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoadingSpinner.jsx","sourceRoot":"","sources":["../../../src/react/components/LoadingSpinner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,cAAc,GAAa,GAAG,EAAE,CAAC,CACtC,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAC1D;EAAA,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAC1B;CAAA,EAAE,SAAS,CAAC,CACZ,CAAA;AAED,eAAe,cAAc,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { LayoutProps, MenuProps } from 'antd';
2
+ import React from 'react';
3
+ import { MenuPage } from './MenuPage';
4
+ export interface BasicLayoutProps {
5
+ /**
6
+ * List of pages for the menu and the routing
7
+ */
8
+ pages?: MenuPage[];
9
+ defaultPage?: string;
10
+ onPageChange?: (page: string) => void;
11
+ compactSider?: boolean;
12
+ layoutProps?: LayoutProps;
13
+ mobileHeaderProps?: LayoutProps;
14
+ contentProps?: LayoutProps;
15
+ menuProps?: Omit<MenuProps, 'items' | 'selectedKeys' | 'onSelect'>;
16
+ }
17
+ /**
18
+ * Basic layout that combines menu and routing into one.
19
+ */
20
+ export declare const BasicLayout: React.FC<BasicLayoutProps>;
@@ -0,0 +1,100 @@
1
+ import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
2
+ import { Button, Layout, Menu } from '@j2inn/ui';
3
+ import React, { useEffect, useState } from 'react';
4
+ import { createUseStyles } from 'react-jss';
5
+ import { ErrorDisplayer } from '../ErrorDisplayer';
6
+ import { findPageByName } from './MenuPage';
7
+ import { Router } from './Router';
8
+ const HEADER_HEIGHT = 45;
9
+ const useStyles = createUseStyles((theme) => {
10
+ return {
11
+ header: {
12
+ position: 'fixed',
13
+ width: '100%',
14
+ zIndex: 1000,
15
+ padding: 0,
16
+ height: HEADER_HEIGHT,
17
+ lineHeight: '45px',
18
+ },
19
+ sider: {
20
+ overflow: 'auto',
21
+ height: '100vh',
22
+ position: 'fixed',
23
+ left: 0,
24
+ top: 0,
25
+ bottom: 0,
26
+ zIndex: 999,
27
+ paddingTop: ({ isMobile }) => isMobile ? HEADER_HEIGHT : 0,
28
+ },
29
+ menuTrigger: {
30
+ width: 45,
31
+ height: '100%',
32
+ textAlign: 'center',
33
+ fontSize: 18,
34
+ cursor: 'pointer',
35
+ transition: 'color 0.3s ease-in-out',
36
+ backgroundColor: 'transparent',
37
+ color: 'white',
38
+ '&:hover': {
39
+ color: theme.linkActiveColor,
40
+ },
41
+ },
42
+ content: ({ isMobile, compactSider }) => ({
43
+ paddingLeft: isMobile ? 0 : compactSider ? 45 : 200,
44
+ paddingTop: isMobile ? HEADER_HEIGHT : 0,
45
+ }),
46
+ };
47
+ });
48
+ // Workaround j2inn/ui exporting problem
49
+ const Header = Layout.Header;
50
+ const Sider = Layout.Sider;
51
+ const Content = Layout.Content;
52
+ /**
53
+ * Basic layout that combines menu and routing into one.
54
+ */
55
+ export const BasicLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', onPageChange, compactSider, layoutProps, mobileHeaderProps, contentProps, menuProps, }) => {
56
+ const [currentPage, setCurrentPage] = useState(defaultPage);
57
+ // Fire onChange
58
+ useEffect(() => {
59
+ onPageChange?.(currentPage);
60
+ }, [currentPage]);
61
+ // manage mobile navigation
62
+ const [isMobile, setIsMobile] = useState(false);
63
+ const [hiddenSider, setHiddenSider] = useState(false);
64
+ const classes = useStyles({ isMobile, compactSider });
65
+ return (<Layout hasSider {...layoutProps}>
66
+ {isMobile && (<Header className={classes.header} {...mobileHeaderProps}>
67
+ {hiddenSider ? (<MenuUnfoldOutlined className={classes.menuTrigger} onClick={() => {
68
+ setHiddenSider(!hiddenSider);
69
+ }}/>) : (<MenuFoldOutlined className={classes.menuTrigger} onClick={() => {
70
+ setHiddenSider(!hiddenSider);
71
+ }}/>)}
72
+ </Header>)}
73
+ <Sider breakpoint='md' onBreakpoint={(broken) => {
74
+ setIsMobile(broken);
75
+ setHiddenSider(true);
76
+ }} collapsed={(isMobile && hiddenSider) || compactSider} collapsedWidth={isMobile && hiddenSider
77
+ ? 0
78
+ : compactSider
79
+ ? HEADER_HEIGHT
80
+ : 0} trigger={null} className={classes.sider}>
81
+ <Menu {...menuProps} items={pages} selectedKeys={[currentPage]} onSelect={({ key }) => {
82
+ if (!hiddenSider) {
83
+ setHiddenSider(true);
84
+ }
85
+ const page = findPageByName(pages, key);
86
+ if (page?.component) {
87
+ setCurrentPage(key);
88
+ }
89
+ }}/>
90
+ </Sider>
91
+ <Content className={classes.content} {...contentProps}>
92
+ <Router pages={pages} currentPage={currentPage ?? defaultPage} fallbackComponent={<ErrorDisplayer error={new Error('Page Not Found')} extra={[
93
+ <Button type='primary' key='refresh' onClick={() => setCurrentPage(defaultPage)}>
94
+ Go Home
95
+ </Button>,
96
+ ]}/>}/>
97
+ </Content>
98
+ </Layout>);
99
+ };
100
+ //# sourceMappingURL=BasicLayout.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BasicLayout.jsx","sourceRoot":"","sources":["../../../../src/react/components/navigation/BasicLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,WAAW,CAAA;AAE1D,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAY,MAAM,YAAY,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,MAAM,aAAa,GAAG,EAAE,CAAA;AAOxB,MAAM,SAAS,GAAG,eAAe,CAAC,CAAC,KAAe,EAAE,EAAE;IACrD,OAAO;QACN,MAAM,EAAE;YACP,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,MAAM;YACb,MAAM,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C,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CACnC,KAAK,CAAC,CAAC;gBACN,CAAC,MAAM,CACN,IAAI,CAAC,SAAS,CACd,GAAG,CAAC,SAAS,CACb,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAC3C;;QACD,EAAE,MAAM,CAAC;aACT,CAAC,EACD,CACF,EAEH;GAAA,EAAE,OAAO,CACV;EAAA,EAAE,MAAM,CAAC,CACT,CAAA;AACF,CAAC,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { ItemType } from 'antd/lib/menu/hooks/useItems';
2
+ import React, { PropsWithChildren } from 'react';
3
+ /**
4
+ * Menu page has both the data required by the menu and the data required to actually render the page.
5
+ */
6
+ export declare type MenuPage<T = Record<string, unknown>> = ItemType & Page<T>;
7
+ /**
8
+ * Menu Item that represents an application page
9
+ */
10
+ interface Page<T = Record<string, unknown>> {
11
+ key: string;
12
+ component?: React.LazyExoticComponent<React.FC<T>>;
13
+ props?: PropsWithChildren<T>;
14
+ children?: Page<T>[];
15
+ disabled?: boolean;
16
+ }
17
+ /**
18
+ * Retrieve a specific page or subPage from a root page list
19
+ * @param name the name of the searched page
20
+ * @param pages the list of root pages
21
+ */
22
+ export declare function findPageByName<T extends MenuPage>(pages: T[], name?: string): T | undefined;
23
+ /**
24
+ * Expands the list of pages to include all the subpages
25
+ */
26
+ export declare function pageTreeToPageList<T extends MenuPage>(pages: T[]): T[];
27
+ /**
28
+ * Recursively get all the subPages of a root page
29
+ * @param page root page
30
+ * @returns the whole tree of subPages as a list
31
+ */
32
+ export declare function getAllSubPages<T extends MenuPage>(page: T): T[];
33
+ export {};
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Retrieve a specific page or subPage from a root page list
3
+ * @param name the name of the searched page
4
+ * @param pages the list of root pages
5
+ */
6
+ export function findPageByName(pages, name) {
7
+ return pageTreeToPageList(pages).find((page) => page.key === name && !page.disabled);
8
+ }
9
+ /**
10
+ * Expands the list of pages to include all the subpages
11
+ */
12
+ export function pageTreeToPageList(pages) {
13
+ return pages.flatMap((page) => getAllSubPages(page));
14
+ }
15
+ /**
16
+ * Recursively get all the subPages of a root page
17
+ * @param page root page
18
+ * @returns the whole tree of subPages as a list
19
+ */
20
+ export function getAllSubPages(page) {
21
+ if (page.children) {
22
+ return [page].concat(...page.children.map((subPage) => getAllSubPages(subPage)));
23
+ }
24
+ else {
25
+ return [page];
26
+ }
27
+ }
28
+ //# sourceMappingURL=MenuPage.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuPage.jsx","sourceRoot":"","sources":["../../../../src/react/components/navigation/MenuPage.tsx"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC7B,KAAU,EACV,IAAa;IAEb,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,IAAI,CACpC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAC7C,CAAA;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAqB,KAAU;IAChE,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAS,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAqB,IAAO;IACzD,IAAI,IAAI,CAAC,QAAQ,EAAE;QAClB,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CACnB,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,OAAY,CAAC,CAAC,CAC/D,CAAA;KACD;SAAM;QACN,OAAO,CAAC,IAAI,CAAC,CAAA;KACb;AACF,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { PropsWithChildren, ReactElement } from 'react';
2
+ import { MenuPage } from './MenuPage';
3
+ export interface RouterProps<T extends MenuPage> {
4
+ pages?: T[];
5
+ currentPage: string;
6
+ onPageChange?: (selectedPage?: T) => void;
7
+ fallbackComponent?: ReactElement;
8
+ }
9
+ /**
10
+ * Renders the currently selected page from a tree of pages
11
+ */
12
+ export declare function Router<T extends MenuPage>({ pages, currentPage, onPageChange, fallbackComponent, }: PropsWithChildren<RouterProps<T>>): JSX.Element;
@@ -0,0 +1,16 @@
1
+ import React, { Suspense, useEffect, useMemo, } from 'react';
2
+ import LoadingSpinner from '../LoadingSpinner';
3
+ import { findPageByName } from './MenuPage';
4
+ /**
5
+ * Renders the currently selected page from a tree of pages
6
+ */
7
+ export function Router({ pages = [], currentPage, onPageChange, fallbackComponent, }) {
8
+ const page = useMemo(() => findPageByName(pages, currentPage), [pages, currentPage]);
9
+ useEffect(() => {
10
+ onPageChange?.(page);
11
+ }, [page]);
12
+ return page?.component ? (<Suspense fallback={<LoadingSpinner />}>
13
+ {React.createElement(page.component, page?.props)}
14
+ </Suspense>) : (fallbackComponent ?? <div>{currentPage} page not found</div>);
15
+ }
16
+ //# sourceMappingURL=Router.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Router.jsx","sourceRoot":"","sources":["../../../../src/react/components/navigation/Router.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAGb,QAAQ,EACR,SAAS,EACT,OAAO,GACP,MAAM,OAAO,CAAA;AACd,OAAO,cAAc,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAY,MAAM,YAAY,CAAA;AASrD;;GAEG;AACH,MAAM,UAAU,MAAM,CAAqB,EAC1C,KAAK,GAAG,EAAE,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,GACkB;IACnC,MAAM,IAAI,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,CAAC,EACxC,CAAC,KAAK,EAAE,WAAW,CAAC,CACpB,CAAA;IAED,SAAS,CAAC,GAAG,EAAE;QACd,YAAY,EAAE,CAAC,IAAI,CAAC,CAAA;IACrB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,OAAO,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CACxB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,AAAD,EAAG,CAAC,CACtC;GAAA,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAClD;EAAA,EAAE,QAAQ,CAAC,CACX,CAAC,CAAC,CAAC,CACH,iBAAiB,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,CAAE,eAAc,EAAE,GAAG,CAAC,CAC5D,CAAA;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j2inn/fin5-ui-utils",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "A set of useful client-side utilities useful for creating UI applications on top of FIN 5",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "license": "ISC",
24
24
  "files": [
25
25
  "dist/**/*",
26
- "scripts/**/*"
26
+ "dist_es/**/*"
27
27
  ],
28
28
  "dependencies": {
29
29
  "@hot-loader/react-dom": "^17.0.2",