wenay-react2 1.0.38 → 1.0.40
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/lib/common/src/components/Dnd/FloatingWindow.d.ts +29 -12
- package/lib/common/src/components/Dnd/FloatingWindow.js +100 -91
- package/lib/common/src/components/Input.d.ts +25 -6
- package/lib/common/src/components/Input.js +27 -8
- package/lib/common/src/components/Menu/RightMenu.d.ts +28 -1
- package/lib/common/src/components/Menu/RightMenu.js +62 -35
- package/lib/common/src/components/Modal/LeftModal.js +5 -4
- package/lib/common/src/components/Modal/Modal.js +8 -7
- package/lib/common/src/components/ParamsEditor.d.ts +15 -0
- package/lib/common/src/components/ParamsEditor.js +45 -18
- package/lib/common/src/components/Settings/SettingsDialog.d.ts +68 -6
- package/lib/common/src/components/Settings/SettingsDialog.js +73 -13
- package/lib/common/src/components/Toolbar/Toolbar.js +64 -19
- package/lib/common/src/components/UiSlot/UiSlot.js +5 -4
- package/lib/common/src/grid/columnState/ColumnDots.d.ts +1 -1
- package/lib/common/src/grid/columnState/ColumnDots.js +1 -1
- package/lib/common/src/grid/columnState/ColumnsMenu.js +10 -18
- package/lib/common/src/grid/columnState/columnState.js +8 -6
- package/lib/common/src/hooks/useKeyboard.js +4 -3
- package/lib/common/src/logs/logs.d.ts +13 -133
- package/lib/common/src/logs/logs.js +20 -39
- package/lib/common/src/logs/logsContext.d.ts +26 -0
- package/lib/common/src/logs/logsContext.js +25 -20
- package/lib/common/src/logs/logsController.d.ts +88 -0
- package/lib/common/src/logs/logsController.js +54 -0
- package/lib/common/src/logs/miniLogs.d.ts +69 -3
- package/lib/common/src/logs/miniLogs.js +70 -15
- package/lib/common/src/menu/menu.d.ts +15 -3
- package/lib/common/src/menu/menu.js +81 -17
- package/lib/common/src/menu/menuMouse.d.ts +35 -0
- package/lib/common/src/menu/menuMouse.js +113 -4
- package/lib/common/src/styles/tokens.d.ts +79 -1
- package/lib/common/src/styles/tokens.js +79 -1
- package/lib/common/src/utils/memoryStore.d.ts +1 -10
- package/lib/common/src/utils/searchHistory.js +4 -3
- package/lib/style/style.css +122 -50
- package/lib/style/tokens.css +76 -2
- package/package.json +49 -49
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ColDef, GridReadyEvent } from 'ag-grid-community';
|
|
2
3
|
/** -----------------------------
|
|
3
4
|
* 1. Log types
|
|
4
5
|
* -----------------------------
|
|
@@ -42,7 +43,32 @@ export declare function useLogsContext(): LogsContextValue;
|
|
|
42
43
|
* (PageLogs equivalent)
|
|
43
44
|
* -----------------------------
|
|
44
45
|
*/
|
|
46
|
+
export type LogsTableController = {
|
|
47
|
+
logs: LogEntry[];
|
|
48
|
+
minVarLogs: number;
|
|
49
|
+
gridRef: React.MutableRefObject<GridReadyEvent | null>;
|
|
50
|
+
columnDefs: ColDef[];
|
|
51
|
+
defaultColDef: ColDef;
|
|
52
|
+
onGridReady(params: GridReadyEvent): void;
|
|
53
|
+
};
|
|
54
|
+
export declare function useLogsTableController(): LogsTableController;
|
|
45
55
|
export declare function LogsTable(): import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
/** -----------------------------
|
|
57
|
+
* 7. LogsNotifications component
|
|
58
|
+
* (MessageEventLogs equivalent)
|
|
59
|
+
* -----------------------------
|
|
60
|
+
*/
|
|
61
|
+
export interface NotificationItem {
|
|
62
|
+
id: number;
|
|
63
|
+
log: LogEntry;
|
|
64
|
+
}
|
|
65
|
+
export type LogsNotificationsController = {
|
|
66
|
+
showMessages: boolean;
|
|
67
|
+
setShowMessages(value: boolean): void;
|
|
68
|
+
notifications: NotificationItem[];
|
|
69
|
+
visibleNotifications: NotificationItem[];
|
|
70
|
+
};
|
|
71
|
+
export declare function useLogsNotificationsController(): LogsNotificationsController;
|
|
46
72
|
export declare function LogsNotifications(): import("react/jsx-runtime").JSX.Element;
|
|
47
73
|
/** -----------------------------
|
|
48
74
|
* 8. LogsSettings component
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { AgGridTable, colDefCentered } from '../grid/agGrid4';
|
|
4
4
|
import { logDividerGradient, logSeverityBackground, logStyleTokens } from './logStyles';
|
|
5
5
|
/** -----------------------------
|
|
6
6
|
* 2. memoryGetOrCreate function -
|
|
@@ -93,15 +93,9 @@ export function useLogsContext() {
|
|
|
93
93
|
}
|
|
94
94
|
return ctx;
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
* 6. LogsTable component
|
|
98
|
-
* (PageLogs equivalent)
|
|
99
|
-
* -----------------------------
|
|
100
|
-
*/
|
|
101
|
-
export function LogsTable() {
|
|
96
|
+
export function useLogsTableController() {
|
|
102
97
|
const { logs, minVarLogs } = useLogsContext();
|
|
103
98
|
const gridRef = useRef(null);
|
|
104
|
-
// Column definitions
|
|
105
99
|
const columnDefs = useMemo(() => [
|
|
106
100
|
{
|
|
107
101
|
field: 'time',
|
|
@@ -126,12 +120,9 @@ export function LogsTable() {
|
|
|
126
120
|
}
|
|
127
121
|
], []);
|
|
128
122
|
const defaultColDef = useMemo(() => ({
|
|
129
|
-
|
|
130
|
-
sortable: true,
|
|
131
|
-
filter: true,
|
|
123
|
+
...colDefCentered,
|
|
132
124
|
wrapText: true,
|
|
133
125
|
}), []);
|
|
134
|
-
// Watch minVarLogs and configure the AG Grid filter
|
|
135
126
|
useEffect(() => {
|
|
136
127
|
if (gridRef.current?.api) {
|
|
137
128
|
if (minVarLogs > 0) {
|
|
@@ -148,14 +139,19 @@ export function LogsTable() {
|
|
|
148
139
|
}
|
|
149
140
|
}
|
|
150
141
|
}, [minVarLogs]);
|
|
142
|
+
const onGridReady = useCallback((params) => {
|
|
143
|
+
gridRef.current = params;
|
|
144
|
+
params.api.sizeColumnsToFit();
|
|
145
|
+
}, []);
|
|
146
|
+
return { logs, minVarLogs, gridRef, columnDefs, defaultColDef, onGridReady };
|
|
147
|
+
}
|
|
148
|
+
export function LogsTable() {
|
|
149
|
+
const table = useLogsTableController();
|
|
151
150
|
return (
|
|
152
151
|
// <div className="ag-theme-alpine-dark" style={{ width: '100%', height: '100%' }}>
|
|
153
|
-
_jsx("div", { style: { width: '100%', height: '100%' }, children: _jsx(
|
|
154
|
-
gridRef.current = params;
|
|
155
|
-
params.api.sizeColumnsToFit();
|
|
156
|
-
}, rowData: logs, columnDefs: columnDefs, defaultColDef: defaultColDef, headerHeight: 30, rowHeight: 26 }) }));
|
|
152
|
+
_jsx("div", { style: { width: '100%', height: '100%' }, children: _jsx(AgGridTable, { onGridReady: table.onGridReady, rowData: table.logs, columnDefs: table.columnDefs, defaultColDef: table.defaultColDef, headerHeight: 30, rowHeight: 26 }) }));
|
|
157
153
|
}
|
|
158
|
-
export function
|
|
154
|
+
export function useLogsNotificationsController() {
|
|
159
155
|
const { logs, minVarMessage, timeShow, showMessages, setShowMessages } = useLogsContext();
|
|
160
156
|
const [notifications, setNotifications] = useState([]);
|
|
161
157
|
const counterRef = useRef(0);
|
|
@@ -183,13 +179,22 @@ export function LogsNotifications() {
|
|
|
183
179
|
timersRef.current.add(timer);
|
|
184
180
|
}, [logs, minVarMessage, timeShow]);
|
|
185
181
|
useEffect(() => () => { timersRef.current.forEach(clearTimeout); }, []);
|
|
186
|
-
|
|
182
|
+
return {
|
|
183
|
+
showMessages,
|
|
184
|
+
setShowMessages,
|
|
185
|
+
notifications,
|
|
186
|
+
visibleNotifications: notifications.slice(0, 10),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export function LogsNotifications() {
|
|
190
|
+
const controller = useLogsNotificationsController();
|
|
191
|
+
if (!controller.showMessages) {
|
|
187
192
|
// If popups are hidden, show only "log"
|
|
188
193
|
return (_jsx("div", { style: { position: 'absolute', right: 10, top: 10, zIndex: 999 }, children: _jsx("div", { style: {
|
|
189
194
|
background: logStyleTokens.toggleOffBg,
|
|
190
195
|
padding: '6px 10px',
|
|
191
196
|
cursor: 'pointer'
|
|
192
|
-
}, onClick: () => setShowMessages(true), children: "log" }) }));
|
|
197
|
+
}, onClick: () => controller.setShowMessages(true), children: "log" }) }));
|
|
193
198
|
}
|
|
194
199
|
// Otherwise render the current notification list
|
|
195
200
|
return (_jsxs("div", { style: { position: 'absolute', right: 10, top: 10, zIndex: 999 }, children: [_jsx("div", { style: {
|
|
@@ -197,7 +202,7 @@ export function LogsNotifications() {
|
|
|
197
202
|
fontSize: '20px',
|
|
198
203
|
padding: '6px 10px',
|
|
199
204
|
cursor: 'pointer'
|
|
200
|
-
}, onClick: () => setShowMessages(false), children: "X" }), _jsx("div", { children:
|
|
205
|
+
}, onClick: () => controller.setShowMessages(false), children: "X" }), _jsx("div", { children: controller.visibleNotifications.map(({ id, log }) => (_jsxs("div", { className: "testAnime example-exit", style: {
|
|
201
206
|
width: 200,
|
|
202
207
|
color: logStyleTokens.text,
|
|
203
208
|
marginTop: 10,
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Params } from "wenay-common2";
|
|
2
|
+
export type LogInput<T extends object = {}> = T & {
|
|
3
|
+
id: string;
|
|
4
|
+
var?: number;
|
|
5
|
+
time: Date;
|
|
6
|
+
txt: string;
|
|
7
|
+
};
|
|
8
|
+
export type LogEntry<T extends object = {}> = LogInput<T> & {
|
|
9
|
+
num: number;
|
|
10
|
+
};
|
|
11
|
+
export type LogsApiOptions = {
|
|
12
|
+
limit?: number;
|
|
13
|
+
limitPer: number;
|
|
14
|
+
varMin?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const getSettingLogs: () => {
|
|
17
|
+
minVarLogs: {
|
|
18
|
+
name: string;
|
|
19
|
+
range: {
|
|
20
|
+
min: number;
|
|
21
|
+
max: number;
|
|
22
|
+
step: number;
|
|
23
|
+
};
|
|
24
|
+
value: number;
|
|
25
|
+
};
|
|
26
|
+
minVarMessage: {
|
|
27
|
+
name: string;
|
|
28
|
+
range: {
|
|
29
|
+
min: number;
|
|
30
|
+
max: number;
|
|
31
|
+
step: number;
|
|
32
|
+
};
|
|
33
|
+
value: number;
|
|
34
|
+
};
|
|
35
|
+
timeShow: {
|
|
36
|
+
name: string;
|
|
37
|
+
range: {
|
|
38
|
+
min: number;
|
|
39
|
+
max: number;
|
|
40
|
+
step: number;
|
|
41
|
+
};
|
|
42
|
+
value: number;
|
|
43
|
+
};
|
|
44
|
+
show: {
|
|
45
|
+
name: string;
|
|
46
|
+
value: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export type LogsSettingsDefinition = ReturnType<typeof getSettingLogs>;
|
|
50
|
+
export type LogsSettings = Params.SimpleParams<LogsSettingsDefinition>;
|
|
51
|
+
export type LogsFullState<T extends object = {}> = {
|
|
52
|
+
map: Map<string, LogEntry<T>[]>;
|
|
53
|
+
};
|
|
54
|
+
export type LogsMiniState<T extends object = {}> = {
|
|
55
|
+
last: LogEntry<T>[];
|
|
56
|
+
};
|
|
57
|
+
export type LogsSettingsState = {
|
|
58
|
+
params: LogsSettings;
|
|
59
|
+
};
|
|
60
|
+
export type LogsControllerState<T extends object = {}> = {
|
|
61
|
+
full: LogsFullState<T>;
|
|
62
|
+
mini: LogsMiniState<T>;
|
|
63
|
+
settings: LogsSettingsState;
|
|
64
|
+
};
|
|
65
|
+
export type LogsControllerEvents = {
|
|
66
|
+
onFullChange?: () => void;
|
|
67
|
+
onMiniChange?: () => void;
|
|
68
|
+
onSettingsChange?: () => void;
|
|
69
|
+
};
|
|
70
|
+
export type CreateLogsControllerOptions<T extends object = {}> = LogsControllerEvents & {
|
|
71
|
+
options: LogsApiOptions;
|
|
72
|
+
state?: LogsControllerState<T>;
|
|
73
|
+
};
|
|
74
|
+
export type LogsController<T extends object = {}> = {
|
|
75
|
+
state: LogsControllerState<T>;
|
|
76
|
+
options: LogsApiOptions;
|
|
77
|
+
addLogs(input: LogInput<T>): LogEntry<T>;
|
|
78
|
+
getRows(): LogEntry<T>[];
|
|
79
|
+
getMiniRows(): LogEntry<T>[];
|
|
80
|
+
getLatest(): LogEntry<T> | undefined;
|
|
81
|
+
params: {
|
|
82
|
+
def: typeof getSettingLogs;
|
|
83
|
+
get(): LogsSettings;
|
|
84
|
+
set(settings: LogsSettings): void;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
export declare function createLogsControllerState<T extends object = {}>(state?: Partial<LogsControllerState<T>>): LogsControllerState<T>;
|
|
88
|
+
export declare function createLogsController<T extends object = {}>({ options, state, onFullChange, onMiniChange, onSettingsChange, }: CreateLogsControllerOptions<T>): LogsController<T>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Params } from "wenay-common2";
|
|
2
|
+
export const getSettingLogs = () => ({
|
|
3
|
+
minVarLogs: { name: "min. importance for notifications", range: { min: 0, max: 25, step: 1 }, value: 0 },
|
|
4
|
+
minVarMessage: { name: "min. importance for log table", range: { min: 0, max: 25, step: 1 }, value: 0 },
|
|
5
|
+
timeShow: { name: "screen display time", range: { min: 1, max: 20, step: 1 }, value: 2 },
|
|
6
|
+
show: { name: "show", value: true }
|
|
7
|
+
});
|
|
8
|
+
function addToArr(arr, data, limit) {
|
|
9
|
+
arr.unshift(data);
|
|
10
|
+
if (arr.length > limit)
|
|
11
|
+
arr.length = limit;
|
|
12
|
+
}
|
|
13
|
+
export function createLogsControllerState(state = {}) {
|
|
14
|
+
return {
|
|
15
|
+
full: state.full ?? { map: new Map() },
|
|
16
|
+
mini: state.mini ?? { last: [] },
|
|
17
|
+
settings: state.settings ?? { params: Params.GetSimpleParams(getSettingLogs()) },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function createLogsController({ options, state = createLogsControllerState(), onFullChange, onMiniChange, onSettingsChange, }) {
|
|
21
|
+
let num = 0;
|
|
22
|
+
return {
|
|
23
|
+
state,
|
|
24
|
+
options,
|
|
25
|
+
addLogs(input) {
|
|
26
|
+
const item = { ...input, num: num++ };
|
|
27
|
+
addToArr(state.mini.last, item, options.limit ?? 50);
|
|
28
|
+
const perId = state.full.map.get(input.id) ?? state.full.map.set(input.id, []).get(input.id);
|
|
29
|
+
addToArr(perId, item, options.limitPer);
|
|
30
|
+
onFullChange?.();
|
|
31
|
+
onMiniChange?.();
|
|
32
|
+
return item;
|
|
33
|
+
},
|
|
34
|
+
getRows() {
|
|
35
|
+
return [...state.full.map.values()].flat();
|
|
36
|
+
},
|
|
37
|
+
getMiniRows() {
|
|
38
|
+
return state.mini.last.slice();
|
|
39
|
+
},
|
|
40
|
+
getLatest() {
|
|
41
|
+
return state.mini.last[0];
|
|
42
|
+
},
|
|
43
|
+
params: {
|
|
44
|
+
def: getSettingLogs,
|
|
45
|
+
get() { return state.settings.params; },
|
|
46
|
+
set(settings) {
|
|
47
|
+
state.settings.params = settings;
|
|
48
|
+
onSettingsChange?.();
|
|
49
|
+
onMiniChange?.();
|
|
50
|
+
onFullChange?.();
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -1,5 +1,71 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { CellMouseDownEvent, ColDef, GridApi, GridPreDestroyedEvent, GridReadyEvent } from "ag-grid-community";
|
|
3
|
+
import { type AgGridTableProps } from "../grid/agGrid4";
|
|
4
|
+
export declare const miniLogsColumnDefs: ({
|
|
5
|
+
field: string;
|
|
6
|
+
sort: "desc";
|
|
7
|
+
width: number;
|
|
8
|
+
valueFormatter: (e: import("ag-grid-community").ValueFormatterParams<any, any, any>) => any;
|
|
9
|
+
wrapText?: undefined;
|
|
10
|
+
autoHeight?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
field: string;
|
|
13
|
+
width: number;
|
|
14
|
+
sort?: undefined;
|
|
15
|
+
valueFormatter?: undefined;
|
|
16
|
+
wrapText?: undefined;
|
|
17
|
+
autoHeight?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
field: string;
|
|
20
|
+
wrapText: true;
|
|
21
|
+
autoHeight: true;
|
|
22
|
+
width: number;
|
|
23
|
+
sort?: undefined;
|
|
24
|
+
valueFormatter?: undefined;
|
|
25
|
+
})[];
|
|
26
|
+
export declare const miniLogsDefaultColDef: {
|
|
27
|
+
wrapText: true;
|
|
28
|
+
headerClass: () => string;
|
|
29
|
+
resizable: true;
|
|
30
|
+
cellStyle: {
|
|
31
|
+
textAlign: string;
|
|
32
|
+
};
|
|
33
|
+
sortable: true;
|
|
34
|
+
filter: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type UseMiniLogsTableOptions<T = any> = {
|
|
3
37
|
data: T[];
|
|
4
38
|
onClick?: (e: CellMouseDownEvent<T>) => any;
|
|
5
|
-
|
|
39
|
+
columnDefs?: ColDef<T>[];
|
|
40
|
+
defaultColDef?: ColDef<T>;
|
|
41
|
+
};
|
|
42
|
+
export type MiniLogsTableController<T = any> = {
|
|
43
|
+
rows: T[];
|
|
44
|
+
columns: ColDef<T>[];
|
|
45
|
+
columnDefs: ColDef<T>[];
|
|
46
|
+
defaultColDef: ColDef<T>;
|
|
47
|
+
apiRef: React.RefObject<GridApi<T> | null>;
|
|
48
|
+
fit: () => boolean;
|
|
49
|
+
getApi: () => GridApi<T> | null;
|
|
50
|
+
withApi: <R>(fn: (api: GridApi<T>) => R) => R | undefined;
|
|
51
|
+
onGridReady: (e: GridReadyEvent<T>) => void;
|
|
52
|
+
onGridPreDestroyed: (e: GridPreDestroyedEvent<T>) => void;
|
|
53
|
+
onCellMouseDown: (e: CellMouseDownEvent<T>) => void;
|
|
54
|
+
props: AgGridTableProps<T>;
|
|
55
|
+
tableProps: AgGridTableProps<T>;
|
|
56
|
+
gridProps: AgGridTableProps<T>;
|
|
57
|
+
};
|
|
58
|
+
export type MiniLogsController<T = any> = MiniLogsTableController<T>;
|
|
59
|
+
export type MiniLogsViewProps<T = any> = {
|
|
60
|
+
controller: MiniLogsTableController<T>;
|
|
61
|
+
className?: string;
|
|
62
|
+
style?: React.CSSProperties;
|
|
63
|
+
};
|
|
64
|
+
export type MiniLogsTableProps<T = any> = UseMiniLogsTableOptions<T> & {
|
|
65
|
+
className?: string;
|
|
66
|
+
style?: React.CSSProperties;
|
|
67
|
+
};
|
|
68
|
+
export declare function useMiniLogsTable<T = any>(options: UseMiniLogsTableOptions<T>): MiniLogsTableController<T>;
|
|
69
|
+
export declare function MiniLogsView<T = any>({ controller, className, style }: MiniLogsViewProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
70
|
+
export declare function MiniLogsTable<T = any>({ className, style, ...options }: MiniLogsTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
71
|
+
export declare function MiniLogs<T = any>(props: MiniLogsTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { timeLocalToStr_hhmmss } from "wenay-common2";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { useCallback, useMemo, useRef } from "react";
|
|
4
|
+
import { AgGridTable, colDefCentered } from "../grid/agGrid4";
|
|
5
|
+
export const miniLogsColumnDefs = [
|
|
5
6
|
{
|
|
6
7
|
field: "time",
|
|
7
8
|
sort: "desc",
|
|
@@ -27,17 +28,71 @@ const columns = [
|
|
|
27
28
|
width: 150,
|
|
28
29
|
},
|
|
29
30
|
];
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
export const miniLogsDefaultColDef = { ...colDefCentered, wrapText: true };
|
|
32
|
+
export function useMiniLogsTable(options) {
|
|
33
|
+
const { data, onClick, columnDefs, defaultColDef: defaultColDefOverride } = options;
|
|
34
|
+
const apiRef = useRef(null);
|
|
35
|
+
const columns = useMemo(() => (columnDefs ?? miniLogsColumnDefs), [columnDefs]);
|
|
36
|
+
const defaultColDef = useMemo(() => ({ ...miniLogsDefaultColDef, ...defaultColDefOverride }), [defaultColDefOverride]);
|
|
37
|
+
const fit = useCallback(() => {
|
|
38
|
+
const api = apiRef.current;
|
|
39
|
+
if (!api)
|
|
40
|
+
return false;
|
|
41
|
+
api.sizeColumnsToFit();
|
|
42
|
+
return true;
|
|
43
|
+
}, []);
|
|
44
|
+
const getApi = useCallback(() => apiRef.current, []);
|
|
45
|
+
const withApi = useCallback(function withApi(fn) {
|
|
46
|
+
const api = apiRef.current;
|
|
47
|
+
return api ? fn(api) : undefined;
|
|
48
|
+
}, []);
|
|
49
|
+
const onGridReady = useCallback((e) => {
|
|
50
|
+
apiRef.current = e.api;
|
|
51
|
+
fit();
|
|
52
|
+
}, [fit]);
|
|
53
|
+
const onGridPreDestroyed = useCallback((_e) => {
|
|
54
|
+
apiRef.current = null;
|
|
55
|
+
}, []);
|
|
56
|
+
const onCellMouseDown = useCallback((e) => {
|
|
57
|
+
onClick?.(e);
|
|
58
|
+
}, [onClick]);
|
|
59
|
+
const props = useMemo(() => ({
|
|
60
|
+
suppressCellFocus: true,
|
|
61
|
+
onGridReady,
|
|
62
|
+
onGridPreDestroyed,
|
|
63
|
+
defaultColDef,
|
|
64
|
+
headerHeight: 30,
|
|
65
|
+
rowHeight: 26,
|
|
66
|
+
autoSizePadding: 1,
|
|
67
|
+
rowData: data,
|
|
68
|
+
columnDefs: columns,
|
|
69
|
+
onCellMouseDown,
|
|
70
|
+
}), [columns, data, defaultColDef, onCellMouseDown, onGridPreDestroyed, onGridReady]);
|
|
71
|
+
return useMemo(() => ({
|
|
72
|
+
rows: data,
|
|
73
|
+
columns,
|
|
74
|
+
columnDefs: columns,
|
|
75
|
+
defaultColDef,
|
|
76
|
+
apiRef,
|
|
77
|
+
fit,
|
|
78
|
+
getApi,
|
|
79
|
+
withApi,
|
|
80
|
+
onGridReady,
|
|
81
|
+
onGridPreDestroyed,
|
|
82
|
+
onCellMouseDown,
|
|
83
|
+
props,
|
|
84
|
+
tableProps: props,
|
|
85
|
+
gridProps: props,
|
|
86
|
+
}), [columns, data, defaultColDef, fit, getApi, onCellMouseDown, onGridPreDestroyed, onGridReady, props, withApi]);
|
|
87
|
+
}
|
|
88
|
+
export function MiniLogsView({ controller, className, style }) {
|
|
89
|
+
const classNames = ["maxSize", className].filter(Boolean).join(" ");
|
|
90
|
+
return _jsx("div", { className: classNames, style: style, children: _jsx(AgGridTable, { ...controller.props }) });
|
|
91
|
+
}
|
|
92
|
+
export function MiniLogsTable({ className, style, ...options }) {
|
|
93
|
+
const table = useMiniLogsTable(options);
|
|
94
|
+
return _jsx(MiniLogsView, { controller: table, className: className, style: style });
|
|
95
|
+
}
|
|
96
|
+
export function MiniLogs(props) {
|
|
97
|
+
return _jsx(MiniLogsTable, { ...props });
|
|
43
98
|
}
|
|
@@ -4,6 +4,8 @@ import React, { ReactElement } from 'react';
|
|
|
4
4
|
*******************************************************/
|
|
5
5
|
export type MenuItemStrict<T = any> = {
|
|
6
6
|
name: string | ((status?: T) => string);
|
|
7
|
+
/** Stable diagnostics key. Stats never fall back to visible labels. */
|
|
8
|
+
actionKey?: string | null;
|
|
7
9
|
getStatus?: (() => T) | null;
|
|
8
10
|
onClick?: ((e: any) => void | undefined | null | ((void | undefined | null | Promise<any> | (() => Promise<any>))[]) | Promise<any>) | null;
|
|
9
11
|
active?: (() => boolean) | null;
|
|
@@ -14,6 +16,14 @@ export type MenuItemStrict<T = any> = {
|
|
|
14
16
|
menuElement?: typeof MenuElement;
|
|
15
17
|
};
|
|
16
18
|
export type MenuItem<T = any> = MenuItemStrict<T> | false | null | undefined;
|
|
19
|
+
export type MenuActionEventType = "click" | "ok" | "error" | "taskOk" | "taskError" | "submenuOpen" | "submenuOk" | "submenuError" | "funcOpen" | "funcOk" | "funcError" | "focusOpen" | "focusOk" | "focusError";
|
|
20
|
+
export type MenuActionEvent = {
|
|
21
|
+
type: MenuActionEventType;
|
|
22
|
+
item: MenuItemStrict;
|
|
23
|
+
actionKey?: string;
|
|
24
|
+
error?: unknown;
|
|
25
|
+
};
|
|
26
|
+
export type MenuActionHandler = (event: MenuActionEvent) => void;
|
|
17
27
|
/*******************************************************
|
|
18
28
|
* Helper type
|
|
19
29
|
*******************************************************/
|
|
@@ -31,12 +41,13 @@ declare function MenuProgress({ data }: {
|
|
|
31
41
|
/*******************************************************
|
|
32
42
|
* Main menu element with onClick and counters
|
|
33
43
|
*******************************************************/
|
|
34
|
-
declare function MenuElement({ data: item, toLeft, className, update, open, }: {
|
|
35
|
-
data: Pick<MenuItemStrict, "onClick" | "active" | "name" | "getStatus">;
|
|
44
|
+
declare function MenuElement({ data: item, toLeft, className, update, open, onActionEvent, }: {
|
|
45
|
+
data: Pick<MenuItemStrict, "onClick" | "active" | "name" | "getStatus" | "actionKey">;
|
|
36
46
|
toLeft: boolean;
|
|
37
47
|
className?: (active?: boolean) => string;
|
|
38
48
|
update: () => void;
|
|
39
49
|
open?: boolean;
|
|
50
|
+
onActionEvent?: MenuActionHandler;
|
|
40
51
|
}): ReactElement;
|
|
41
52
|
/*******************************************************
|
|
42
53
|
* Menu renders the popup menu with support for
|
|
@@ -62,6 +73,7 @@ type MenuProps = {
|
|
|
62
73
|
data: MenuItem[];
|
|
63
74
|
zIndex?: number;
|
|
64
75
|
className?: (active?: boolean) => string;
|
|
76
|
+
onActionEvent?: MenuActionHandler;
|
|
65
77
|
coordinate?: {
|
|
66
78
|
x: number;
|
|
67
79
|
y: number;
|
|
@@ -69,5 +81,5 @@ type MenuProps = {
|
|
|
69
81
|
left?: number;
|
|
70
82
|
};
|
|
71
83
|
};
|
|
72
|
-
export declare function Menu({ coordinate, data, zIndex, menu, className, menuElement, }: MenuProps): ReactElement;
|
|
84
|
+
export declare function Menu({ coordinate, data, zIndex, menu, className, menuElement, onActionEvent, }: MenuProps): ReactElement;
|
|
73
85
|
export { MenuProgress, MenuElement };
|