@etsoo/materialui 1.1.39 → 1.1.41
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/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 +1 -1
- package/lib/SwitchAnt.js +11 -8
- 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/pages/ViewPage.d.ts +7 -7
- package/lib/pages/ViewPage.js +30 -29
- package/package.json +2 -2
- package/src/AuditDisplay.tsx +92 -99
- package/src/BridgeCloseButton.tsx +48 -50
- package/src/DataSteps.tsx +188 -185
- 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/Tiplist.tsx +5 -4
- package/src/UserAvatar.tsx +43 -45
- package/src/app/ReactApp.ts +485 -489
- package/src/pages/ViewPage.tsx +272 -277
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.41",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
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",
|
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
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { BridgeUtils, IBridgeHost } from
|
|
2
|
-
import CloseIcon from
|
|
3
|
-
import { Box, BoxProps, IconButton, IconButtonProps } from
|
|
4
|
-
import React from
|
|
5
|
-
import { globalApp } from
|
|
1
|
+
import { BridgeUtils, IBridgeHost } from "@etsoo/appscript";
|
|
2
|
+
import CloseIcon from "@mui/icons-material/Close";
|
|
3
|
+
import { Box, BoxProps, IconButton, IconButtonProps } from "@mui/material";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { globalApp } from "./app/ReactApp";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Bridge close button props
|
|
9
9
|
*/
|
|
10
10
|
export interface BridgeCloseButtonProps extends IconButtonProps {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Box props
|
|
13
|
+
*/
|
|
14
|
+
boxProps?: BoxProps;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Validate the host
|
|
18
|
+
* @param host Host
|
|
19
|
+
*/
|
|
20
|
+
validate?(host: IBridgeHost): boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -26,44 +26,42 @@ export interface BridgeCloseButtonProps extends IconButtonProps {
|
|
|
26
26
|
* @returns Component
|
|
27
27
|
*/
|
|
28
28
|
export function BridgeCloseButton(props: BridgeCloseButtonProps) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
...rest
|
|
38
|
-
} = props;
|
|
29
|
+
// Destruct
|
|
30
|
+
const {
|
|
31
|
+
boxProps,
|
|
32
|
+
onClick,
|
|
33
|
+
title = globalApp?.get("close") ?? "Close",
|
|
34
|
+
validate,
|
|
35
|
+
...rest
|
|
36
|
+
} = props;
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
// Host
|
|
39
|
+
const host = BridgeUtils.host;
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
if (
|
|
42
|
+
host == null ||
|
|
43
|
+
!host.closable() ||
|
|
44
|
+
(validate && validate(host) === false)
|
|
45
|
+
) {
|
|
46
|
+
return <React.Fragment />;
|
|
47
|
+
}
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
// Click handler
|
|
50
|
+
const onClickLocal = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
51
|
+
if (onClick) onClick(event);
|
|
52
|
+
host.exit();
|
|
53
|
+
};
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
return (
|
|
56
|
+
<Box {...boxProps}>
|
|
57
|
+
<IconButton
|
|
58
|
+
aria-label="close"
|
|
59
|
+
onClick={onClickLocal}
|
|
60
|
+
title={title}
|
|
61
|
+
{...rest}
|
|
62
|
+
>
|
|
63
|
+
<CloseIcon />
|
|
64
|
+
</IconButton>
|
|
65
|
+
</Box>
|
|
66
|
+
);
|
|
69
67
|
}
|