@etsoo/materialui 1.1.39 → 1.1.42
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/AuditDisplay.d.ts +5 -5
- package/lib/AuditDisplay.js +17 -19
- package/lib/BridgeCloseButton.d.ts +2 -2
- package/lib/BridgeCloseButton.js +7 -8
- package/lib/DataSteps.d.ts +4 -4
- package/lib/DataSteps.js +17 -14
- package/lib/DataTable.d.ts +33 -0
- package/lib/DataTable.js +56 -0
- package/lib/ListMoreDisplay.d.ts +5 -5
- package/lib/ListMoreDisplay.js +8 -10
- package/lib/OptionBool.js +2 -1
- package/lib/SelectBool.js +2 -1
- package/lib/ShowDataComparison.d.ts +1 -1
- package/lib/ShowDataComparison.js +27 -20
- package/lib/SwitchAnt.d.ts +3 -3
- package/lib/SwitchAnt.js +11 -8
- package/lib/SwitchField.d.ts +45 -0
- package/lib/SwitchField.js +33 -0
- package/lib/Tiplist.js +4 -4
- package/lib/UserAvatar.js +7 -8
- package/lib/app/ReactApp.d.ts +7 -7
- package/lib/app/ReactApp.js +26 -26
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/pages/ViewPage.d.ts +7 -7
- package/lib/pages/ViewPage.js +30 -29
- package/package.json +3 -2
- package/src/AuditDisplay.tsx +92 -99
- package/src/BridgeCloseButton.tsx +48 -50
- package/src/DataSteps.tsx +188 -185
- package/src/DataTable.tsx +124 -0
- package/src/ListMoreDisplay.tsx +184 -188
- package/src/OptionBool.tsx +1 -1
- package/src/SelectBool.tsx +1 -1
- package/src/ShowDataComparison.tsx +88 -76
- package/src/SwitchAnt.tsx +82 -78
- package/src/SwitchField.tsx +133 -0
- package/src/Tiplist.tsx +5 -4
- package/src/UserAvatar.tsx +43 -45
- package/src/app/ReactApp.ts +485 -489
- package/src/index.ts +2 -0
- package/src/pages/ViewPage.tsx +272 -277
package/lib/UserAvatar.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Avatar } from
|
|
3
|
-
import { BusinessUtils } from
|
|
4
|
-
import { globalApp } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Avatar } from "@mui/material";
|
|
3
|
+
import { BusinessUtils } from "@etsoo/appscript";
|
|
4
|
+
import { globalApp } from "./app/ReactApp";
|
|
5
5
|
/**
|
|
6
6
|
* User avatar
|
|
7
7
|
* @param props Props
|
|
@@ -10,9 +10,8 @@ import { globalApp } from './app/ReactApp';
|
|
|
10
10
|
export function UserAvatar(props) {
|
|
11
11
|
// Destruct
|
|
12
12
|
const { src, title, formatTitle = (title) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
: globalApp.get('me'));
|
|
13
|
+
var _a;
|
|
14
|
+
return BusinessUtils.formatAvatarTitle(title, 3, (_a = globalApp === null || globalApp === void 0 ? void 0 : globalApp.get("me")) !== null && _a !== void 0 ? _a : "ME");
|
|
16
15
|
} } = props;
|
|
17
16
|
// Format
|
|
18
17
|
const fTitle = formatTitle(title);
|
|
@@ -20,6 +19,6 @@ export function UserAvatar(props) {
|
|
|
20
19
|
return (React.createElement(Avatar, { title: title, src: src, sx: {
|
|
21
20
|
width: 48,
|
|
22
21
|
height: 32,
|
|
23
|
-
fontSize: count <= 2 ?
|
|
22
|
+
fontSize: count <= 2 ? "15px" : "12px"
|
|
24
23
|
} }, fTitle));
|
|
25
24
|
}
|
package/lib/app/ReactApp.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CoreApp, IActionResult, IApp, IAppSettings, ICoreApp, IUser } from
|
|
2
|
-
import { INotifier, NotificationReturn } from
|
|
3
|
-
import { DataTypes } from
|
|
4
|
-
import React from
|
|
5
|
-
import { CultureAction, CultureState, INotificationReact, InputDialogProps, IPageData, IStateProps, NotificationReactCallProps, PageAction, PageState, UserAction, UserState } from
|
|
6
|
-
import { NavigateFunction, NavigateOptions } from
|
|
1
|
+
import { CoreApp, IActionResult, IApp, IAppSettings, ICoreApp, IUser } from "@etsoo/appscript";
|
|
2
|
+
import { INotifier, NotificationReturn } from "@etsoo/notificationbase";
|
|
3
|
+
import { DataTypes } from "@etsoo/shared";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { CultureAction, CultureState, INotificationReact, InputDialogProps, IPageData, IStateProps, NotificationReactCallProps, PageAction, PageState, UserAction, UserState } from "@etsoo/react";
|
|
6
|
+
import { NavigateFunction, NavigateOptions } from "react-router-dom";
|
|
7
7
|
/**
|
|
8
8
|
* React Application Type
|
|
9
9
|
*/
|
|
@@ -11,7 +11,7 @@ export type ReactAppType = IApp & IReactAppBase;
|
|
|
11
11
|
/**
|
|
12
12
|
* Global application
|
|
13
13
|
*/
|
|
14
|
-
export declare let globalApp: ReactAppType;
|
|
14
|
+
export declare let globalApp: ReactAppType | null;
|
|
15
15
|
/**
|
|
16
16
|
* React app state detector
|
|
17
17
|
* Case 1: undefined, when refresh the whole page
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BridgeUtils, CoreApp, createClient } from
|
|
2
|
-
import { NotificationMessageType } from
|
|
3
|
-
import { WindowStorage } from
|
|
4
|
-
import React from
|
|
5
|
-
import { NotifierMU } from
|
|
6
|
-
import { ProgressCount } from
|
|
7
|
-
import { Labels } from
|
|
8
|
-
import { CultureState, PageActionType, PageState, UserActionType, UserState } from
|
|
1
|
+
import { BridgeUtils, CoreApp, createClient } from "@etsoo/appscript";
|
|
2
|
+
import { NotificationMessageType } from "@etsoo/notificationbase";
|
|
3
|
+
import { WindowStorage } from "@etsoo/shared";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { NotifierMU } from "../NotifierMU";
|
|
6
|
+
import { ProgressCount } from "../ProgressCount";
|
|
7
|
+
import { Labels } from "./Labels";
|
|
8
|
+
import { CultureState, PageActionType, PageState, UserActionType, UserState } from "@etsoo/react";
|
|
9
9
|
/**
|
|
10
10
|
* Global application
|
|
11
11
|
*/
|
|
@@ -75,7 +75,7 @@ export class ReactApp extends CoreApp {
|
|
|
75
75
|
this.userState = new UserState();
|
|
76
76
|
if (BridgeUtils.host) {
|
|
77
77
|
BridgeUtils.host.onUpdate((app, version) => {
|
|
78
|
-
this.notifier.message(NotificationMessageType.Success, this.get(
|
|
78
|
+
this.notifier.message(NotificationMessageType.Success, this.get("updateTip") + `(${[app, version].join(", ")})`, this.get("updateReady"));
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
this.cultureState = new CultureState(settings.currentCulture);
|
|
@@ -88,13 +88,13 @@ export class ReactApp extends CoreApp {
|
|
|
88
88
|
* @param callback Callback
|
|
89
89
|
*/
|
|
90
90
|
alertResult(result, callback) {
|
|
91
|
-
const message = typeof result ===
|
|
92
|
-
if (message.endsWith(
|
|
93
|
-
const startPos = message.lastIndexOf(
|
|
91
|
+
const message = typeof result === "string" ? result : this.formatResult(result);
|
|
92
|
+
if (message.endsWith(")")) {
|
|
93
|
+
const startPos = message.lastIndexOf("(");
|
|
94
94
|
if (startPos > 0) {
|
|
95
95
|
const main = message.substring(0, startPos).trim();
|
|
96
96
|
const tip = message.substring(startPos);
|
|
97
|
-
const titleNode = React.createElement(React.Fragment, null, main, React.createElement(
|
|
97
|
+
const titleNode = React.createElement(React.Fragment, null, main, React.createElement("br"), React.createElement("span", { style: { fontSize: "9px" } }, tip));
|
|
98
98
|
this.notifier.alert(titleNode, callback);
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
@@ -112,19 +112,19 @@ export class ReactApp extends CoreApp {
|
|
|
112
112
|
// Update component labels
|
|
113
113
|
Labels.setLabels(culture.resources, {
|
|
114
114
|
notificationMU: {
|
|
115
|
-
alertTitle:
|
|
116
|
-
alertOK:
|
|
117
|
-
confirmTitle:
|
|
118
|
-
confirmYes:
|
|
119
|
-
confirmNo:
|
|
120
|
-
promptTitle:
|
|
121
|
-
promptCancel:
|
|
122
|
-
promptOK:
|
|
115
|
+
alertTitle: "warning",
|
|
116
|
+
alertOK: "ok",
|
|
117
|
+
confirmTitle: "confirm",
|
|
118
|
+
confirmYes: "ok",
|
|
119
|
+
confirmNo: "cancel",
|
|
120
|
+
promptTitle: "prompt",
|
|
121
|
+
promptCancel: "cancel",
|
|
122
|
+
promptOK: "ok"
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
125
|
// Document title
|
|
126
126
|
// Default is servier name's label or appName label
|
|
127
|
-
const title = (_b = (_a = this.get(this.name)) !== null && _a !== void 0 ? _a : this.get(
|
|
127
|
+
const title = (_b = (_a = this.get(this.name)) !== null && _a !== void 0 ? _a : this.get("appName")) !== null && _b !== void 0 ? _b : this.name;
|
|
128
128
|
const host = BridgeUtils.host;
|
|
129
129
|
if (host) {
|
|
130
130
|
// Notify host
|
|
@@ -170,11 +170,11 @@ export class ReactApp extends CoreApp {
|
|
|
170
170
|
*/
|
|
171
171
|
freshCountdownUI(callback) {
|
|
172
172
|
// Labels
|
|
173
|
-
const labels = this.getLabels(
|
|
173
|
+
const labels = this.getLabels("cancel", "tokenExpiry");
|
|
174
174
|
// Progress
|
|
175
175
|
const progress = React.createElement(ProgressCount, {
|
|
176
176
|
seconds: 30,
|
|
177
|
-
valueUnit:
|
|
177
|
+
valueUnit: "s",
|
|
178
178
|
onComplete: () => {
|
|
179
179
|
// Stop the progress
|
|
180
180
|
return false;
|
|
@@ -228,7 +228,7 @@ export class ReactApp extends CoreApp {
|
|
|
228
228
|
navigate(to, options) {
|
|
229
229
|
if (this.navigateFunction == null)
|
|
230
230
|
super.navigate(to, options);
|
|
231
|
-
else if (typeof to ===
|
|
231
|
+
else if (typeof to === "number")
|
|
232
232
|
this.navigateFunction(to);
|
|
233
233
|
else
|
|
234
234
|
this.navigateFunction(to, options);
|
|
@@ -239,7 +239,7 @@ export class ReactApp extends CoreApp {
|
|
|
239
239
|
*/
|
|
240
240
|
setPageKey(key) {
|
|
241
241
|
var _a;
|
|
242
|
-
this.setPageTitle((_a = this.get(key)) !== null && _a !== void 0 ? _a :
|
|
242
|
+
this.setPageTitle((_a = this.get(key)) !== null && _a !== void 0 ? _a : "");
|
|
243
243
|
}
|
|
244
244
|
/**
|
|
245
245
|
* Show input dialog
|
package/lib/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export * from "./CustomFabProps";
|
|
|
38
38
|
export * from "./DataGridEx";
|
|
39
39
|
export * from "./DataGridRenderers";
|
|
40
40
|
export * from "./DataSteps";
|
|
41
|
+
export * from "./DataTable";
|
|
41
42
|
export * from "./DialogButton";
|
|
42
43
|
export * from "./DnDList";
|
|
43
44
|
export * from "./DraggablePaperComponent";
|
|
@@ -77,6 +78,7 @@ export * from "./SelectEx";
|
|
|
77
78
|
export * from "./ShowDataComparison";
|
|
78
79
|
export * from "./Switch";
|
|
79
80
|
export * from "./SwitchAnt";
|
|
81
|
+
export * from "./SwitchField";
|
|
80
82
|
export * from "./TabBox";
|
|
81
83
|
export * from "./TableEx";
|
|
82
84
|
export * from "./TextFieldEx";
|
package/lib/index.js
CHANGED
|
@@ -38,6 +38,7 @@ export * from "./CustomFabProps";
|
|
|
38
38
|
export * from "./DataGridEx";
|
|
39
39
|
export * from "./DataGridRenderers";
|
|
40
40
|
export * from "./DataSteps";
|
|
41
|
+
export * from "./DataTable";
|
|
41
42
|
export * from "./DialogButton";
|
|
42
43
|
export * from "./DnDList";
|
|
43
44
|
export * from "./DraggablePaperComponent";
|
|
@@ -77,6 +78,7 @@ export * from "./SelectEx";
|
|
|
77
78
|
export * from "./ShowDataComparison";
|
|
78
79
|
export * from "./Switch";
|
|
79
80
|
export * from "./SwitchAnt";
|
|
81
|
+
export * from "./SwitchField";
|
|
80
82
|
export * from "./TabBox";
|
|
81
83
|
export * from "./TableEx";
|
|
82
84
|
export * from "./TextFieldEx";
|
package/lib/pages/ViewPage.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { GridColumnRenderProps, GridDataType } from
|
|
2
|
-
import { DataTypes } from
|
|
3
|
-
import { GridProps } from
|
|
4
|
-
import React from
|
|
5
|
-
import { CommonPageProps } from
|
|
1
|
+
import { GridColumnRenderProps, GridDataType } from "@etsoo/react";
|
|
2
|
+
import { DataTypes } from "@etsoo/shared";
|
|
3
|
+
import { GridProps } from "@mui/material";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { CommonPageProps } from "./CommonPageProps";
|
|
6
6
|
/**
|
|
7
7
|
* View page row width type
|
|
8
8
|
*/
|
|
9
|
-
export type ViewPageRowType = boolean |
|
|
9
|
+
export type ViewPageRowType = boolean | "default" | "small" | object;
|
|
10
10
|
/**
|
|
11
11
|
* View page display field
|
|
12
12
|
*/
|
|
@@ -40,7 +40,7 @@ export type ViewPageFieldType<T extends object> = ViewPageFieldTypeNarrow<T> | (
|
|
|
40
40
|
/**
|
|
41
41
|
* View page props
|
|
42
42
|
*/
|
|
43
|
-
export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<CommonPageProps,
|
|
43
|
+
export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<CommonPageProps, "children"> {
|
|
44
44
|
/**
|
|
45
45
|
* Actions
|
|
46
46
|
*/
|
package/lib/pages/ViewPage.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { Utils } from
|
|
2
|
-
import { Grid, LinearProgress, Stack, Typography } from
|
|
3
|
-
import React from
|
|
4
|
-
import { Labels } from
|
|
5
|
-
import { globalApp } from
|
|
6
|
-
import { GridDataFormat } from
|
|
7
|
-
import { MUGlobal } from
|
|
8
|
-
import { PullToRefreshUI } from
|
|
9
|
-
import { CommonPage } from
|
|
1
|
+
import { DateUtils, Utils } from "@etsoo/shared";
|
|
2
|
+
import { Grid, LinearProgress, Stack, Typography } from "@mui/material";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Labels } from "../app/Labels";
|
|
5
|
+
import { globalApp } from "../app/ReactApp";
|
|
6
|
+
import { GridDataFormat } from "../GridDataFormat";
|
|
7
|
+
import { MUGlobal } from "../MUGlobal";
|
|
8
|
+
import { PullToRefreshUI } from "../PullToRefreshUI";
|
|
9
|
+
import { CommonPage } from "./CommonPage";
|
|
10
10
|
function formatItemData(fieldData) {
|
|
11
11
|
if (fieldData == null)
|
|
12
12
|
return undefined;
|
|
13
|
-
if (typeof fieldData ===
|
|
13
|
+
if (typeof fieldData === "string")
|
|
14
14
|
return fieldData;
|
|
15
15
|
if (fieldData instanceof Date)
|
|
16
|
-
return globalApp
|
|
16
|
+
return globalApp
|
|
17
|
+
? globalApp.formatDate(fieldData, "d")
|
|
18
|
+
: DateUtils.format(fieldData, "d");
|
|
17
19
|
return `${fieldData}`;
|
|
18
20
|
}
|
|
19
21
|
function getResp(singleRow) {
|
|
20
|
-
return typeof singleRow ===
|
|
22
|
+
return typeof singleRow === "object"
|
|
21
23
|
? singleRow
|
|
22
|
-
: singleRow ===
|
|
24
|
+
: singleRow === "default"
|
|
23
25
|
? { xs: 12, sm: 12, md: 12, lg: 6, xl: 6 }
|
|
24
26
|
: singleRow === true
|
|
25
27
|
? { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }
|
|
@@ -36,20 +38,20 @@ function getItemField(field, data) {
|
|
|
36
38
|
// Item data and label
|
|
37
39
|
let itemData, itemLabel, gridProps = {};
|
|
38
40
|
if (Array.isArray(field)) {
|
|
39
|
-
const [fieldData, fieldType, renderProps, singleRow =
|
|
41
|
+
const [fieldData, fieldType, renderProps, singleRow = "small"] = field;
|
|
40
42
|
itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
|
|
41
|
-
itemLabel = (_a = globalApp.get(fieldData)) !== null && _a !== void 0 ? _a : fieldData;
|
|
43
|
+
itemLabel = (_a = globalApp === null || globalApp === void 0 ? void 0 : globalApp.get(fieldData)) !== null && _a !== void 0 ? _a : fieldData;
|
|
42
44
|
gridProps = { ...getResp(singleRow) };
|
|
43
45
|
}
|
|
44
|
-
else if (typeof field ===
|
|
46
|
+
else if (typeof field === "object") {
|
|
45
47
|
// Destruct
|
|
46
|
-
const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow =
|
|
48
|
+
const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow = "default", ...rest } = field;
|
|
47
49
|
gridProps = {
|
|
48
50
|
...rest,
|
|
49
51
|
...getResp(singleRow)
|
|
50
52
|
};
|
|
51
53
|
// Field data
|
|
52
|
-
if (typeof fieldData ===
|
|
54
|
+
if (typeof fieldData === "function")
|
|
53
55
|
itemData = fieldData(data);
|
|
54
56
|
else if (dataType == null)
|
|
55
57
|
itemData = formatItemData(data[fieldData]);
|
|
@@ -57,15 +59,15 @@ function getItemField(field, data) {
|
|
|
57
59
|
itemData = GridDataFormat(data[fieldData], dataType, renderProps);
|
|
58
60
|
// Field label
|
|
59
61
|
itemLabel =
|
|
60
|
-
typeof fieldLabel ===
|
|
62
|
+
typeof fieldLabel === "function"
|
|
61
63
|
? fieldLabel()
|
|
62
64
|
: fieldLabel != null
|
|
63
|
-
? (_b = globalApp.get(fieldLabel)) !== null && _b !== void 0 ? _b : fieldLabel
|
|
65
|
+
? (_b = globalApp === null || globalApp === void 0 ? void 0 : globalApp.get(fieldLabel)) !== null && _b !== void 0 ? _b : fieldLabel
|
|
64
66
|
: fieldLabel;
|
|
65
67
|
}
|
|
66
68
|
else {
|
|
67
69
|
itemData = formatItemData(data[field]);
|
|
68
|
-
itemLabel = (_c = globalApp.get(field)) !== null && _c !== void 0 ? _c : field;
|
|
70
|
+
itemLabel = (_c = globalApp === null || globalApp === void 0 ? void 0 : globalApp.get(field)) !== null && _c !== void 0 ? _c : field;
|
|
69
71
|
}
|
|
70
72
|
return [itemData, itemLabel, gridProps];
|
|
71
73
|
}
|
|
@@ -81,7 +83,7 @@ export function ViewPage(props) {
|
|
|
81
83
|
// Labels
|
|
82
84
|
const labels = Labels.CommonPage;
|
|
83
85
|
// Container
|
|
84
|
-
const pullContainer =
|
|
86
|
+
const pullContainer = "#page-container";
|
|
85
87
|
// Load data
|
|
86
88
|
const refresh = async () => {
|
|
87
89
|
const result = await loadData();
|
|
@@ -91,28 +93,27 @@ export function ViewPage(props) {
|
|
|
91
93
|
};
|
|
92
94
|
return (React.createElement(CommonPage, { paddings: paddings, onRefresh: supportRefresh ? refresh : undefined, onUpdate: supportRefresh ? undefined : refresh, ...rest, scrollContainer: globalThis, fabColumnDirection: fabColumnDirection, supportBack: supportBack }, data == null ? (React.createElement(LinearProgress, null)) : (React.createElement(React.Fragment, null,
|
|
93
95
|
React.createElement(Grid, { container: true, justifyContent: "left", spacing: paddings, className: "ET-ViewPage", ref: gridRef, sx: {
|
|
94
|
-
|
|
95
|
-
fontWeight:
|
|
96
|
+
".MuiTypography-subtitle2": {
|
|
97
|
+
fontWeight: "bold"
|
|
96
98
|
}
|
|
97
99
|
} }, fields.map((field, index) => {
|
|
98
100
|
// Get data
|
|
99
|
-
if (typeof field ===
|
|
101
|
+
if (typeof field === "function") {
|
|
100
102
|
// Most flexible way, do whatever you want
|
|
101
103
|
return field(data);
|
|
102
104
|
}
|
|
103
105
|
const [itemData, itemLabel, gridProps] = getItemField(field, data);
|
|
104
106
|
// Some callback function may return '' instead of undefined
|
|
105
|
-
if (itemData == null || itemData ===
|
|
107
|
+
if (itemData == null || itemData === "")
|
|
106
108
|
return undefined;
|
|
107
109
|
// Layout
|
|
108
110
|
return (React.createElement(Grid, { item: true, ...gridProps, key: index },
|
|
109
111
|
itemLabel != null && (React.createElement(Typography, { variant: "caption", component: "div" },
|
|
110
112
|
itemLabel,
|
|
111
113
|
":")),
|
|
112
|
-
typeof itemData ===
|
|
114
|
+
typeof itemData === "object" ? (itemData) : (React.createElement(Typography, { variant: "subtitle2" }, itemData))));
|
|
113
115
|
})),
|
|
114
|
-
React.createElement(Stack, { className: "ET-ViewPage-Actions", direction: "row", width: "100%", flexWrap: "wrap", justifyContent: "flex-end", paddingTop: actions == null ? undefined : paddings, paddingBottom: paddings, gap: paddings }, actions != null &&
|
|
115
|
-
Utils.getResult(actions, data, refresh)),
|
|
116
|
+
React.createElement(Stack, { className: "ET-ViewPage-Actions", direction: "row", width: "100%", flexWrap: "wrap", justifyContent: "flex-end", paddingTop: actions == null ? undefined : paddings, paddingBottom: paddings, gap: paddings }, actions != null && Utils.getResult(actions, data, refresh)),
|
|
116
117
|
Utils.getResult(children, data, refresh),
|
|
117
118
|
pullToRefresh && (React.createElement(PullToRefreshUI, { mainElement: pullContainer, triggerElement: pullContainer, instructionsPullToRefresh: labels.pullToRefresh, instructionsReleaseToRefresh: labels.releaseToRefresh, instructionsRefreshing: labels.refreshing, onRefresh: refresh, shouldPullToRefresh: () => {
|
|
118
119
|
const container = document.querySelector(pullContainer);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.42",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,12 +50,13 @@
|
|
|
50
50
|
"@emotion/css": "^11.10.6",
|
|
51
51
|
"@emotion/react": "^11.10.6",
|
|
52
52
|
"@emotion/styled": "^11.10.6",
|
|
53
|
-
"@etsoo/appscript": "^1.3.
|
|
53
|
+
"@etsoo/appscript": "^1.3.68",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.24",
|
|
55
55
|
"@etsoo/react": "^1.6.49",
|
|
56
56
|
"@etsoo/shared": "^1.1.89",
|
|
57
57
|
"@mui/icons-material": "^5.11.9",
|
|
58
58
|
"@mui/material": "^5.11.10",
|
|
59
|
+
"@mui/x-data-grid": "^6.0.0-beta.5",
|
|
59
60
|
"@types/pica": "^9.0.1",
|
|
60
61
|
"@types/pulltorefreshjs": "^0.1.5",
|
|
61
62
|
"@types/react": "^18.0.28",
|
package/src/AuditDisplay.tsx
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { AuditLineDto } from
|
|
2
|
-
import { Utils } from
|
|
3
|
-
import { Button, Divider, Theme, Typography, useTheme } from
|
|
4
|
-
import React, { CSSProperties } from
|
|
5
|
-
import { globalApp } from
|
|
6
|
-
import { ListMoreDisplay, ListMoreDisplayProps } from
|
|
7
|
-
import { ShowDataComparison } from
|
|
1
|
+
import { AuditLineDto } from "@etsoo/appscript";
|
|
2
|
+
import { Utils } from "@etsoo/shared";
|
|
3
|
+
import { Button, Divider, Theme, Typography, useTheme } from "@mui/material";
|
|
4
|
+
import React, { CSSProperties } from "react";
|
|
5
|
+
import { globalApp } from "./app/ReactApp";
|
|
6
|
+
import { ListMoreDisplay, ListMoreDisplayProps } from "./ListMoreDisplay";
|
|
7
|
+
import { ShowDataComparison } from "./ShowDataComparison";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Audit display props
|
|
11
11
|
*/
|
|
12
12
|
export interface AuditDisplayProps
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
extends Omit<ListMoreDisplayProps<AuditLineDto>, "children"> {
|
|
14
|
+
/**
|
|
15
|
+
* Get list item style callback
|
|
16
|
+
*/
|
|
17
|
+
getItemStyle?: (index: number, theme: Theme) => CSSProperties;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Get column label
|
|
21
|
+
*/
|
|
22
|
+
getColumnLabel?: (field: string) => string;
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Equal check
|
|
26
|
+
*/
|
|
27
|
+
equalCheck?: boolean;
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Item/line renderer
|
|
31
|
+
*/
|
|
32
|
+
itemRenderer?: (data: AuditLineDto, index: number) => React.ReactNode;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// Get label
|
|
36
36
|
const getLabel = (key: string) => {
|
|
37
|
-
|
|
37
|
+
return globalApp?.get(Utils.formatInitial(key)) ?? key;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
// Format date
|
|
41
41
|
const formatDate = (date: Date) => {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
if (globalApp) return globalApp.formatDate(date, "ds");
|
|
43
|
+
return date.toUTCString();
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -49,79 +49,72 @@ const formatDate = (date: Date) => {
|
|
|
49
49
|
* @returns Component
|
|
50
50
|
*/
|
|
51
51
|
export function AuditDisplay(props: AuditDisplayProps) {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
// Theme
|
|
53
|
+
const theme = useTheme();
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
// Title
|
|
56
|
+
var title = getLabel("dataComparison");
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
<React.Fragment>
|
|
110
|
-
<Typography>{getLabel('audits')}</Typography>
|
|
111
|
-
<Divider />
|
|
112
|
-
</React.Fragment>
|
|
113
|
-
),
|
|
114
|
-
...rest
|
|
115
|
-
} = props;
|
|
58
|
+
// Destruct
|
|
59
|
+
const {
|
|
60
|
+
getItemStyle = (index, theme) => ({
|
|
61
|
+
padding: [theme.spacing(1.5), theme.spacing(1)].join(" "),
|
|
62
|
+
background:
|
|
63
|
+
index % 2 === 0 ? theme.palette.grey[100] : theme.palette.grey[50]
|
|
64
|
+
}),
|
|
65
|
+
getColumnLabel,
|
|
66
|
+
equalCheck,
|
|
67
|
+
itemRenderer = (data) => {
|
|
68
|
+
const {
|
|
69
|
+
newData,
|
|
70
|
+
oldData,
|
|
71
|
+
changes = { newData: newData ?? {}, oldData: oldData ?? {} }
|
|
72
|
+
} = data;
|
|
73
|
+
return (
|
|
74
|
+
<React.Fragment>
|
|
75
|
+
{changes != null && (
|
|
76
|
+
<Button
|
|
77
|
+
variant="outlined"
|
|
78
|
+
size="small"
|
|
79
|
+
onClick={() =>
|
|
80
|
+
ShowDataComparison(changes, title, getColumnLabel, equalCheck)
|
|
81
|
+
}
|
|
82
|
+
sx={{
|
|
83
|
+
marginLeft: theme.spacing(1),
|
|
84
|
+
marginTop: theme.spacing(-0.5),
|
|
85
|
+
float: "right"
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
{title}
|
|
89
|
+
</Button>
|
|
90
|
+
)}
|
|
91
|
+
<Typography>
|
|
92
|
+
{formatDate(data.creation) +
|
|
93
|
+
", [" +
|
|
94
|
+
getLabel(data.action) +
|
|
95
|
+
"], " +
|
|
96
|
+
data.user}
|
|
97
|
+
</Typography>
|
|
98
|
+
</React.Fragment>
|
|
99
|
+
);
|
|
100
|
+
},
|
|
101
|
+
headerTitle = (
|
|
102
|
+
<React.Fragment>
|
|
103
|
+
<Typography>{getLabel("audits")}</Typography>
|
|
104
|
+
<Divider />
|
|
105
|
+
</React.Fragment>
|
|
106
|
+
),
|
|
107
|
+
...rest
|
|
108
|
+
} = props;
|
|
116
109
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
110
|
+
// Layout
|
|
111
|
+
return (
|
|
112
|
+
<ListMoreDisplay<AuditLineDto> headerTitle={headerTitle} {...rest}>
|
|
113
|
+
{(data, index) => (
|
|
114
|
+
<div key={data.id} style={getItemStyle(index, theme)}>
|
|
115
|
+
{itemRenderer(data, index)}
|
|
116
|
+
</div>
|
|
117
|
+
)}
|
|
118
|
+
</ListMoreDisplay>
|
|
119
|
+
);
|
|
127
120
|
}
|