@etsoo/materialui 1.0.9 → 1.0.12
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 +1 -1
- package/lib/pages/ViewPage.js +15 -11
- package/package.json +12 -12
- package/src/pages/ViewPage.tsx +24 -15
package/lib/pages/ViewPage.d.ts
CHANGED
package/lib/pages/ViewPage.js
CHANGED
|
@@ -20,7 +20,6 @@ function getItemField(field, data) {
|
|
|
20
20
|
var _a, _b, _c;
|
|
21
21
|
// Item data and label
|
|
22
22
|
let itemData, itemLabel, gridProps = {};
|
|
23
|
-
let xs = 6;
|
|
24
23
|
if (Array.isArray(field)) {
|
|
25
24
|
const [fieldData, fieldType, renderProps] = field;
|
|
26
25
|
itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
|
|
@@ -28,13 +27,22 @@ function getItemField(field, data) {
|
|
|
28
27
|
}
|
|
29
28
|
else if (typeof field === 'object') {
|
|
30
29
|
// Destruct
|
|
31
|
-
const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow, ...rest } = field;
|
|
30
|
+
const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow = 'default', ...rest } = field;
|
|
31
|
+
const res = singleRow === 'default'
|
|
32
|
+
? { xs: 12, sm: 12, md: 6, lg: 6, xl: 4 }
|
|
33
|
+
: singleRow === true
|
|
34
|
+
? { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }
|
|
35
|
+
: {
|
|
36
|
+
xs: singleRow === false ? 12 : 6,
|
|
37
|
+
sm: 6,
|
|
38
|
+
md: 6,
|
|
39
|
+
lg: 4,
|
|
40
|
+
xl: 3
|
|
41
|
+
};
|
|
32
42
|
gridProps = {
|
|
33
43
|
...rest,
|
|
34
|
-
...
|
|
44
|
+
...res
|
|
35
45
|
};
|
|
36
|
-
if (singleRow === false)
|
|
37
|
-
xs = 12;
|
|
38
46
|
// Field data
|
|
39
47
|
if (typeof fieldData === 'function')
|
|
40
48
|
itemData = fieldData(data);
|
|
@@ -52,11 +60,7 @@ function getItemField(field, data) {
|
|
|
52
60
|
itemData = formatItemData(data[field]);
|
|
53
61
|
itemLabel = (_c = globalApp.get(field)) !== null && _c !== void 0 ? _c : field;
|
|
54
62
|
}
|
|
55
|
-
return [
|
|
56
|
-
itemData,
|
|
57
|
-
itemLabel,
|
|
58
|
-
{ xs, sm: 6, md: 6, lg: 4, xl: 3, ...gridProps }
|
|
59
|
-
];
|
|
63
|
+
return [itemData, itemLabel, gridProps];
|
|
60
64
|
}
|
|
61
65
|
/**
|
|
62
66
|
* View page
|
|
@@ -94,7 +98,7 @@ export function ViewPage(props) {
|
|
|
94
98
|
React.createElement(Typography, { variant: "caption", component: "div" },
|
|
95
99
|
itemLabel,
|
|
96
100
|
":"),
|
|
97
|
-
React.createElement(Typography, { variant: "subtitle2" }, itemData)));
|
|
101
|
+
typeof itemData === 'object' ? (itemData) : (React.createElement(Typography, { variant: "subtitle2" }, itemData))));
|
|
98
102
|
})),
|
|
99
103
|
actions != null && (React.createElement(Stack, { className: "ET-ViewPage-Actions", direction: "row", width: "100%", flexWrap: "wrap", justifyContent: "flex-end", paddingTop: paddings, paddingBottom: paddings, gap: paddings }, Utils.getResult(actions, data, refresh))),
|
|
100
104
|
Utils.getResult(children, data, refresh),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -51,15 +51,15 @@
|
|
|
51
51
|
"@emotion/css": "^11.10.0",
|
|
52
52
|
"@emotion/react": "^11.10.4",
|
|
53
53
|
"@emotion/styled": "^11.10.4",
|
|
54
|
-
"@etsoo/appscript": "^1.2.
|
|
54
|
+
"@etsoo/appscript": "^1.2.90",
|
|
55
55
|
"@etsoo/notificationbase": "^1.1.7",
|
|
56
|
-
"@etsoo/react": "^1.5.
|
|
57
|
-
"@etsoo/shared": "^1.1.
|
|
56
|
+
"@etsoo/react": "^1.5.89",
|
|
57
|
+
"@etsoo/shared": "^1.1.54",
|
|
58
58
|
"@mui/icons-material": "^5.10.3",
|
|
59
59
|
"@mui/material": "^5.10.4",
|
|
60
60
|
"@types/pica": "^9.0.1",
|
|
61
61
|
"@types/pulltorefreshjs": "^0.1.5",
|
|
62
|
-
"@types/react": "^18.0.
|
|
62
|
+
"@types/react": "^18.0.19",
|
|
63
63
|
"@types/react-avatar-editor": "^13.0.0",
|
|
64
64
|
"@types/react-dom": "^18.0.6",
|
|
65
65
|
"@types/react-input-mask": "^3.0.1",
|
|
@@ -82,16 +82,16 @@
|
|
|
82
82
|
"@babel/runtime-corejs3": "^7.19.0",
|
|
83
83
|
"@testing-library/jest-dom": "^5.16.5",
|
|
84
84
|
"@testing-library/react": "^13.4.0",
|
|
85
|
-
"@types/jest": "^29.0.
|
|
85
|
+
"@types/jest": "^29.0.1",
|
|
86
86
|
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
|
87
87
|
"@typescript-eslint/parser": "^5.36.2",
|
|
88
|
-
"eslint": "^8.23.
|
|
88
|
+
"eslint": "^8.23.1",
|
|
89
89
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
90
90
|
"eslint-plugin-import": "^2.26.0",
|
|
91
|
-
"eslint-plugin-react": "^7.31.
|
|
92
|
-
"jest": "^
|
|
93
|
-
"jest-environment-jsdom": "^
|
|
94
|
-
"ts-jest": "^
|
|
95
|
-
"typescript": "^4.8.
|
|
91
|
+
"eslint-plugin-react": "^7.31.8",
|
|
92
|
+
"jest": "^29.0.3",
|
|
93
|
+
"jest-environment-jsdom": "^29.0.3",
|
|
94
|
+
"ts-jest": "^29.0.0",
|
|
95
|
+
"typescript": "^4.8.3"
|
|
96
96
|
}
|
|
97
97
|
}
|
package/src/pages/ViewPage.tsx
CHANGED
|
@@ -38,7 +38,7 @@ export interface ViewPageField<T extends object> extends GridProps {
|
|
|
38
38
|
/**
|
|
39
39
|
* Display as single row
|
|
40
40
|
*/
|
|
41
|
-
singleRow?: boolean;
|
|
41
|
+
singleRow?: boolean | 'default' | 'small';
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Render props
|
|
@@ -107,8 +107,6 @@ function getItemField<T extends object>(
|
|
|
107
107
|
itemLabel: React.ReactNode,
|
|
108
108
|
gridProps: GridProps = {};
|
|
109
109
|
|
|
110
|
-
let xs = 6;
|
|
111
|
-
|
|
112
110
|
if (Array.isArray(field)) {
|
|
113
111
|
const [fieldData, fieldType, renderProps] = field;
|
|
114
112
|
itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
|
|
@@ -120,17 +118,28 @@ function getItemField<T extends object>(
|
|
|
120
118
|
dataType,
|
|
121
119
|
label: fieldLabel,
|
|
122
120
|
renderProps,
|
|
123
|
-
singleRow,
|
|
121
|
+
singleRow = 'default',
|
|
124
122
|
...rest
|
|
125
123
|
} = field;
|
|
126
124
|
|
|
125
|
+
const res =
|
|
126
|
+
singleRow === 'default'
|
|
127
|
+
? { xs: 12, sm: 12, md: 6, lg: 6, xl: 4 }
|
|
128
|
+
: singleRow === true
|
|
129
|
+
? { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }
|
|
130
|
+
: {
|
|
131
|
+
xs: singleRow === false ? 12 : 6,
|
|
132
|
+
sm: 6,
|
|
133
|
+
md: 6,
|
|
134
|
+
lg: 4,
|
|
135
|
+
xl: 3
|
|
136
|
+
};
|
|
137
|
+
|
|
127
138
|
gridProps = {
|
|
128
139
|
...rest,
|
|
129
|
-
...
|
|
140
|
+
...res
|
|
130
141
|
};
|
|
131
142
|
|
|
132
|
-
if (singleRow === false) xs = 12;
|
|
133
|
-
|
|
134
143
|
// Field data
|
|
135
144
|
if (typeof fieldData === 'function') itemData = fieldData(data);
|
|
136
145
|
else if (dataType == null) itemData = formatItemData(data[fieldData]);
|
|
@@ -149,11 +158,7 @@ function getItemField<T extends object>(
|
|
|
149
158
|
itemLabel = globalApp.get<string>(field) ?? field;
|
|
150
159
|
}
|
|
151
160
|
|
|
152
|
-
return [
|
|
153
|
-
itemData,
|
|
154
|
-
itemLabel,
|
|
155
|
-
{ xs, sm: 6, md: 6, lg: 4, xl: 3, ...gridProps }
|
|
156
|
-
];
|
|
161
|
+
return [itemData, itemLabel, gridProps];
|
|
157
162
|
}
|
|
158
163
|
|
|
159
164
|
/**
|
|
@@ -236,9 +241,13 @@ export function ViewPage<T extends DataTypes.StringRecord>(
|
|
|
236
241
|
>
|
|
237
242
|
{itemLabel}:
|
|
238
243
|
</Typography>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
244
|
+
{typeof itemData === 'object' ? (
|
|
245
|
+
itemData
|
|
246
|
+
) : (
|
|
247
|
+
<Typography variant="subtitle2">
|
|
248
|
+
{itemData}
|
|
249
|
+
</Typography>
|
|
250
|
+
)}
|
|
242
251
|
</Grid>
|
|
243
252
|
);
|
|
244
253
|
})}
|