@etsoo/materialui 1.0.12 → 1.0.16
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 +3 -2
- package/lib/pages/ViewPage.js +16 -13
- package/package.json +7 -7
- package/src/pages/ViewPage.tsx +21 -17
package/lib/pages/ViewPage.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ 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
|
+
declare type RowType = boolean | 'default' | 'small';
|
|
6
7
|
/**
|
|
7
8
|
* View page display field
|
|
8
9
|
*/
|
|
@@ -22,13 +23,13 @@ export interface ViewPageField<T extends object> extends GridProps {
|
|
|
22
23
|
/**
|
|
23
24
|
* Display as single row
|
|
24
25
|
*/
|
|
25
|
-
singleRow?:
|
|
26
|
+
singleRow?: RowType;
|
|
26
27
|
/**
|
|
27
28
|
* Render props
|
|
28
29
|
*/
|
|
29
30
|
renderProps?: GridColumnRenderProps;
|
|
30
31
|
}
|
|
31
|
-
declare type ViewPageFieldType<T extends object> = (string & keyof T) | [string & keyof T, GridDataType, GridColumnRenderProps?] | ViewPageField<T>;
|
|
32
|
+
declare type ViewPageFieldType<T extends object> = (string & keyof T) | [string & keyof T, GridDataType, GridColumnRenderProps?, RowType?] | ViewPageField<T>;
|
|
32
33
|
/**
|
|
33
34
|
* View page props
|
|
34
35
|
*/
|
package/lib/pages/ViewPage.js
CHANGED
|
@@ -16,32 +16,35 @@ function formatItemData(fieldData) {
|
|
|
16
16
|
return globalApp.formatDate(fieldData, 'd');
|
|
17
17
|
return `${fieldData}`;
|
|
18
18
|
}
|
|
19
|
+
function getResp(singleRow) {
|
|
20
|
+
return singleRow === 'default'
|
|
21
|
+
? { xs: 12, sm: 12, md: 12, lg: 6, xl: 6 }
|
|
22
|
+
: singleRow === true
|
|
23
|
+
? { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }
|
|
24
|
+
: {
|
|
25
|
+
xs: singleRow === false ? 12 : 6,
|
|
26
|
+
sm: 6,
|
|
27
|
+
md: 6,
|
|
28
|
+
lg: 4,
|
|
29
|
+
xl: 3
|
|
30
|
+
};
|
|
31
|
+
}
|
|
19
32
|
function getItemField(field, data) {
|
|
20
33
|
var _a, _b, _c;
|
|
21
34
|
// Item data and label
|
|
22
35
|
let itemData, itemLabel, gridProps = {};
|
|
23
36
|
if (Array.isArray(field)) {
|
|
24
|
-
const [fieldData, fieldType, renderProps] = field;
|
|
37
|
+
const [fieldData, fieldType, renderProps, singleRow = 'small'] = field;
|
|
25
38
|
itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
|
|
26
39
|
itemLabel = (_a = globalApp.get(fieldData)) !== null && _a !== void 0 ? _a : fieldData;
|
|
40
|
+
gridProps = { ...getResp(singleRow) };
|
|
27
41
|
}
|
|
28
42
|
else if (typeof field === 'object') {
|
|
29
43
|
// Destruct
|
|
30
44
|
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
|
-
};
|
|
42
45
|
gridProps = {
|
|
43
46
|
...rest,
|
|
44
|
-
...
|
|
47
|
+
...getResp(singleRow)
|
|
45
48
|
};
|
|
46
49
|
// Field data
|
|
47
50
|
if (typeof fieldData === 'function')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -51,12 +51,12 @@
|
|
|
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.91",
|
|
55
55
|
"@etsoo/notificationbase": "^1.1.7",
|
|
56
|
-
"@etsoo/react": "^1.5.
|
|
57
|
-
"@etsoo/shared": "^1.1.
|
|
56
|
+
"@etsoo/react": "^1.5.90",
|
|
57
|
+
"@etsoo/shared": "^1.1.55",
|
|
58
58
|
"@mui/icons-material": "^5.10.3",
|
|
59
|
-
"@mui/material": "^5.10.
|
|
59
|
+
"@mui/material": "^5.10.5",
|
|
60
60
|
"@types/pica": "^9.0.1",
|
|
61
61
|
"@types/pulltorefreshjs": "^0.1.5",
|
|
62
62
|
"@types/react": "^18.0.19",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"@testing-library/jest-dom": "^5.16.5",
|
|
84
84
|
"@testing-library/react": "^13.4.0",
|
|
85
85
|
"@types/jest": "^29.0.1",
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
87
|
-
"@typescript-eslint/parser": "^5.
|
|
86
|
+
"@typescript-eslint/eslint-plugin": "^5.37.0",
|
|
87
|
+
"@typescript-eslint/parser": "^5.37.0",
|
|
88
88
|
"eslint": "^8.23.1",
|
|
89
89
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
90
90
|
"eslint-plugin-import": "^2.26.0",
|
package/src/pages/ViewPage.tsx
CHANGED
|
@@ -16,6 +16,8 @@ import { PullToRefreshUI } from '../PullToRefreshUI';
|
|
|
16
16
|
import { CommonPage } from './CommonPage';
|
|
17
17
|
import { CommonPageProps } from './CommonPageProps';
|
|
18
18
|
|
|
19
|
+
type RowType = boolean | 'default' | 'small';
|
|
20
|
+
|
|
19
21
|
/**
|
|
20
22
|
* View page display field
|
|
21
23
|
*/
|
|
@@ -38,7 +40,7 @@ export interface ViewPageField<T extends object> extends GridProps {
|
|
|
38
40
|
/**
|
|
39
41
|
* Display as single row
|
|
40
42
|
*/
|
|
41
|
-
singleRow?:
|
|
43
|
+
singleRow?: RowType;
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
46
|
* Render props
|
|
@@ -48,7 +50,7 @@ export interface ViewPageField<T extends object> extends GridProps {
|
|
|
48
50
|
|
|
49
51
|
type ViewPageFieldType<T extends object> =
|
|
50
52
|
| (string & keyof T)
|
|
51
|
-
| [string & keyof T, GridDataType, GridColumnRenderProps?]
|
|
53
|
+
| [string & keyof T, GridDataType, GridColumnRenderProps?, RowType?]
|
|
52
54
|
| ViewPageField<T>;
|
|
53
55
|
|
|
54
56
|
/**
|
|
@@ -98,6 +100,20 @@ function formatItemData(fieldData: unknown): string | undefined {
|
|
|
98
100
|
return `${fieldData}`;
|
|
99
101
|
}
|
|
100
102
|
|
|
103
|
+
function getResp(singleRow: RowType) {
|
|
104
|
+
return singleRow === 'default'
|
|
105
|
+
? { xs: 12, sm: 12, md: 12, lg: 6, xl: 6 }
|
|
106
|
+
: singleRow === true
|
|
107
|
+
? { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }
|
|
108
|
+
: {
|
|
109
|
+
xs: singleRow === false ? 12 : 6,
|
|
110
|
+
sm: 6,
|
|
111
|
+
md: 6,
|
|
112
|
+
lg: 4,
|
|
113
|
+
xl: 3
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
101
117
|
function getItemField<T extends object>(
|
|
102
118
|
field: ViewPageFieldType<T>,
|
|
103
119
|
data: T
|
|
@@ -108,9 +124,10 @@ function getItemField<T extends object>(
|
|
|
108
124
|
gridProps: GridProps = {};
|
|
109
125
|
|
|
110
126
|
if (Array.isArray(field)) {
|
|
111
|
-
const [fieldData, fieldType, renderProps] = field;
|
|
127
|
+
const [fieldData, fieldType, renderProps, singleRow = 'small'] = field;
|
|
112
128
|
itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
|
|
113
129
|
itemLabel = globalApp.get<string>(fieldData) ?? fieldData;
|
|
130
|
+
gridProps = { ...getResp(singleRow) };
|
|
114
131
|
} else if (typeof field === 'object') {
|
|
115
132
|
// Destruct
|
|
116
133
|
const {
|
|
@@ -122,22 +139,9 @@ function getItemField<T extends object>(
|
|
|
122
139
|
...rest
|
|
123
140
|
} = field;
|
|
124
141
|
|
|
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
|
-
|
|
138
142
|
gridProps = {
|
|
139
143
|
...rest,
|
|
140
|
-
...
|
|
144
|
+
...getResp(singleRow)
|
|
141
145
|
};
|
|
142
146
|
|
|
143
147
|
// Field data
|