@etsoo/materialui 1.2.69 → 1.2.71
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/pages/ViewPage.d.ts +25 -0
- package/lib/pages/ViewPage.js +28 -7
- package/package.json +1 -1
- package/src/pages/ViewPage.tsx +53 -14
package/lib/pages/ViewPage.d.ts
CHANGED
|
@@ -3,6 +3,19 @@ import { DataTypes } from "@etsoo/shared";
|
|
|
3
3
|
import { GridProps } from "@mui/material";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { CommonPageProps } from "./CommonPageProps";
|
|
6
|
+
/**
|
|
7
|
+
* View page grid item properties
|
|
8
|
+
*/
|
|
9
|
+
export type ViewPageGridItemProps = GridProps & {
|
|
10
|
+
data: React.ReactNode;
|
|
11
|
+
label?: React.ReactNode;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* View page grid item
|
|
15
|
+
* @param props Props
|
|
16
|
+
* @returns Result
|
|
17
|
+
*/
|
|
18
|
+
export declare function ViewPageGridItem(props: ViewPageGridItemProps): React.JSX.Element;
|
|
6
19
|
/**
|
|
7
20
|
* View page row width type
|
|
8
21
|
*/
|
|
@@ -78,6 +91,18 @@ export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<Co
|
|
|
78
91
|
*/
|
|
79
92
|
refreshSeed?: number;
|
|
80
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* View page format item data
|
|
96
|
+
* @param fieldData Field data
|
|
97
|
+
* @returns Result
|
|
98
|
+
*/
|
|
99
|
+
export declare function formatItemData(fieldData: unknown): string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* View page get row options
|
|
102
|
+
* @param singleRow Row option
|
|
103
|
+
* @returns Result
|
|
104
|
+
*/
|
|
105
|
+
export declare function getResp(singleRow: ViewPageRowType): object;
|
|
81
106
|
/**
|
|
82
107
|
* View page
|
|
83
108
|
* @param props Props
|
package/lib/pages/ViewPage.js
CHANGED
|
@@ -8,7 +8,27 @@ import { GridDataFormat } from "../GridDataFormat";
|
|
|
8
8
|
import { MUGlobal } from "../MUGlobal";
|
|
9
9
|
import { PullToRefreshUI } from "../PullToRefreshUI";
|
|
10
10
|
import { CommonPage } from "./CommonPage";
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* View page grid item
|
|
13
|
+
* @param props Props
|
|
14
|
+
* @returns Result
|
|
15
|
+
*/
|
|
16
|
+
export function ViewPageGridItem(props) {
|
|
17
|
+
// Destruct
|
|
18
|
+
const { data, label, ...gridProps } = props;
|
|
19
|
+
// Layout
|
|
20
|
+
return (React.createElement(Grid, { item: true, ...gridProps },
|
|
21
|
+
label != null && (React.createElement(Typography, { variant: "caption", component: "div" },
|
|
22
|
+
label,
|
|
23
|
+
":")),
|
|
24
|
+
typeof data === "object" ? (data) : (React.createElement(Typography, { variant: "subtitle2" }, data))));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* View page format item data
|
|
28
|
+
* @param fieldData Field data
|
|
29
|
+
* @returns Result
|
|
30
|
+
*/
|
|
31
|
+
export function formatItemData(fieldData) {
|
|
12
32
|
if (fieldData == null)
|
|
13
33
|
return undefined;
|
|
14
34
|
if (typeof fieldData === "string")
|
|
@@ -19,7 +39,12 @@ function formatItemData(fieldData) {
|
|
|
19
39
|
: DateUtils.format(fieldData, "d");
|
|
20
40
|
return `${fieldData}`;
|
|
21
41
|
}
|
|
22
|
-
|
|
42
|
+
/**
|
|
43
|
+
* View page get row options
|
|
44
|
+
* @param singleRow Row option
|
|
45
|
+
* @returns Result
|
|
46
|
+
*/
|
|
47
|
+
export function getResp(singleRow) {
|
|
23
48
|
return typeof singleRow === "object"
|
|
24
49
|
? singleRow
|
|
25
50
|
: singleRow === "medium"
|
|
@@ -114,11 +139,7 @@ export function ViewPage(props) {
|
|
|
114
139
|
if (itemData == null || itemData === "")
|
|
115
140
|
return undefined;
|
|
116
141
|
// Layout
|
|
117
|
-
return (React.createElement(
|
|
118
|
-
itemLabel != null && (React.createElement(Typography, { variant: "caption", component: "div" },
|
|
119
|
-
itemLabel,
|
|
120
|
-
":")),
|
|
121
|
-
typeof itemData === "object" ? (itemData) : (React.createElement(Typography, { variant: "subtitle2" }, itemData))));
|
|
142
|
+
return (React.createElement(ViewPageGridItem, { item: true, ...gridProps, key: index, data: itemData, label: itemLabel }));
|
|
122
143
|
})),
|
|
123
144
|
actions !== null && (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))),
|
|
124
145
|
Utils.getResult(children, data, refresh),
|
package/package.json
CHANGED
package/src/pages/ViewPage.tsx
CHANGED
|
@@ -20,6 +20,40 @@ import { PullToRefreshUI } from "../PullToRefreshUI";
|
|
|
20
20
|
import { CommonPage } from "./CommonPage";
|
|
21
21
|
import { CommonPageProps } from "./CommonPageProps";
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* View page grid item properties
|
|
25
|
+
*/
|
|
26
|
+
export type ViewPageGridItemProps = GridProps & {
|
|
27
|
+
data: React.ReactNode;
|
|
28
|
+
label?: React.ReactNode;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* View page grid item
|
|
33
|
+
* @param props Props
|
|
34
|
+
* @returns Result
|
|
35
|
+
*/
|
|
36
|
+
export function ViewPageGridItem(props: ViewPageGridItemProps) {
|
|
37
|
+
// Destruct
|
|
38
|
+
const { data, label, ...gridProps } = props;
|
|
39
|
+
|
|
40
|
+
// Layout
|
|
41
|
+
return (
|
|
42
|
+
<Grid item {...gridProps}>
|
|
43
|
+
{label != null && (
|
|
44
|
+
<Typography variant="caption" component="div">
|
|
45
|
+
{label}:
|
|
46
|
+
</Typography>
|
|
47
|
+
)}
|
|
48
|
+
{typeof data === "object" ? (
|
|
49
|
+
data
|
|
50
|
+
) : (
|
|
51
|
+
<Typography variant="subtitle2">{data}</Typography>
|
|
52
|
+
)}
|
|
53
|
+
</Grid>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
23
57
|
/**
|
|
24
58
|
* View page row width type
|
|
25
59
|
*/
|
|
@@ -122,7 +156,12 @@ export interface ViewPageProps<T extends DataTypes.StringRecord>
|
|
|
122
156
|
refreshSeed?: number;
|
|
123
157
|
}
|
|
124
158
|
|
|
125
|
-
|
|
159
|
+
/**
|
|
160
|
+
* View page format item data
|
|
161
|
+
* @param fieldData Field data
|
|
162
|
+
* @returns Result
|
|
163
|
+
*/
|
|
164
|
+
export function formatItemData(fieldData: unknown): string | undefined {
|
|
126
165
|
if (fieldData == null) return undefined;
|
|
127
166
|
if (typeof fieldData === "string") return fieldData;
|
|
128
167
|
if (fieldData instanceof Date)
|
|
@@ -132,7 +171,12 @@ function formatItemData(fieldData: unknown): string | undefined {
|
|
|
132
171
|
return `${fieldData}`;
|
|
133
172
|
}
|
|
134
173
|
|
|
135
|
-
|
|
174
|
+
/**
|
|
175
|
+
* View page get row options
|
|
176
|
+
* @param singleRow Row option
|
|
177
|
+
* @returns Result
|
|
178
|
+
*/
|
|
179
|
+
export function getResp(singleRow: ViewPageRowType) {
|
|
136
180
|
return typeof singleRow === "object"
|
|
137
181
|
? singleRow
|
|
138
182
|
: singleRow === "medium"
|
|
@@ -289,18 +333,13 @@ export function ViewPage<T extends DataTypes.StringRecord>(
|
|
|
289
333
|
|
|
290
334
|
// Layout
|
|
291
335
|
return (
|
|
292
|
-
<
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
itemData
|
|
300
|
-
) : (
|
|
301
|
-
<Typography variant="subtitle2">{itemData}</Typography>
|
|
302
|
-
)}
|
|
303
|
-
</Grid>
|
|
336
|
+
<ViewPageGridItem
|
|
337
|
+
item
|
|
338
|
+
{...gridProps}
|
|
339
|
+
key={index}
|
|
340
|
+
data={itemData}
|
|
341
|
+
label={itemLabel}
|
|
342
|
+
/>
|
|
304
343
|
);
|
|
305
344
|
})}
|
|
306
345
|
</Grid>
|