@etsoo/materialui 1.4.98 → 1.5.0
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/cjs/ErrorAlert.d.ts +16 -0
- package/lib/cjs/ErrorAlert.js +19 -0
- package/lib/cjs/ViewContainer.d.ts +107 -0
- package/lib/cjs/ViewContainer.js +230 -0
- package/lib/cjs/index.d.ts +2 -0
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/pages/ViewPage.d.ts +2 -95
- package/lib/cjs/pages/ViewPage.js +10 -223
- package/lib/mjs/ErrorAlert.d.ts +16 -0
- package/lib/mjs/ErrorAlert.js +16 -0
- package/lib/mjs/ViewContainer.d.ts +107 -0
- package/lib/mjs/ViewContainer.js +222 -0
- package/lib/mjs/index.d.ts +2 -0
- package/lib/mjs/index.js +2 -0
- package/lib/mjs/pages/ViewPage.d.ts +2 -95
- package/lib/mjs/pages/ViewPage.js +5 -216
- package/package.json +9 -9
- package/src/ErrorAlert.tsx +32 -0
- package/src/ViewContainer.tsx +437 -0
- package/src/index.ts +2 -0
- package/src/pages/ViewPage.tsx +17 -415
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AlertProps } from "@mui/material";
|
|
2
|
+
/**
|
|
3
|
+
* Error alert props
|
|
4
|
+
*/
|
|
5
|
+
export type ErrorAlertProps = AlertProps & {
|
|
6
|
+
/**
|
|
7
|
+
* Message to display
|
|
8
|
+
*/
|
|
9
|
+
message?: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Error alert component
|
|
13
|
+
* @param props Props
|
|
14
|
+
* @returns Component
|
|
15
|
+
*/
|
|
16
|
+
export declare function ErrorAlert(props: ErrorAlertProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorAlert = ErrorAlert;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const ReactApp_1 = require("./app/ReactApp");
|
|
7
|
+
/**
|
|
8
|
+
* Error alert component
|
|
9
|
+
* @param props Props
|
|
10
|
+
* @returns Component
|
|
11
|
+
*/
|
|
12
|
+
function ErrorAlert(props) {
|
|
13
|
+
// Global app
|
|
14
|
+
const app = (0, ReactApp_1.useAppContext)();
|
|
15
|
+
// Destruct
|
|
16
|
+
const { message = app?.get("idError"), ...alertProps } = props;
|
|
17
|
+
// Layout
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", ...alertProps, children: message }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Breakpoint, Grid2Props } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { DataTypes } from "@etsoo/shared";
|
|
4
|
+
import { GridColumnRenderProps, GridDataType } from "@etsoo/react";
|
|
5
|
+
/**
|
|
6
|
+
* View page item size
|
|
7
|
+
*/
|
|
8
|
+
export type ViewPageItemSize = Record<Breakpoint, number | undefined>;
|
|
9
|
+
/**
|
|
10
|
+
* View page grid item size
|
|
11
|
+
*/
|
|
12
|
+
export declare namespace ViewPageSize {
|
|
13
|
+
const large: ViewPageItemSize;
|
|
14
|
+
const medium: ViewPageItemSize;
|
|
15
|
+
const line: ViewPageItemSize;
|
|
16
|
+
const small: ViewPageItemSize;
|
|
17
|
+
const smallLine: ViewPageItemSize;
|
|
18
|
+
function matchSize(size: ViewPageItemSize): {
|
|
19
|
+
[k: string]: number | undefined;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* View page row width type
|
|
24
|
+
*/
|
|
25
|
+
export type ViewPageRowType = boolean | "default" | "small" | "medium" | "large" | ViewPageItemSize;
|
|
26
|
+
/**
|
|
27
|
+
* View page grid item properties
|
|
28
|
+
*/
|
|
29
|
+
export type ViewPageGridItemProps = Grid2Props & {
|
|
30
|
+
data: React.ReactNode;
|
|
31
|
+
label?: React.ReactNode;
|
|
32
|
+
singleRow?: ViewPageRowType;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* View page grid item
|
|
36
|
+
* @param props Props
|
|
37
|
+
* @returns Result
|
|
38
|
+
*/
|
|
39
|
+
export declare function ViewPageGridItem(props: ViewPageGridItemProps): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
/**
|
|
41
|
+
* View page display field
|
|
42
|
+
*/
|
|
43
|
+
export interface ViewPageField<T extends object> extends Grid2Props {
|
|
44
|
+
/**
|
|
45
|
+
* Data field
|
|
46
|
+
*/
|
|
47
|
+
data: (string & keyof T) | ((item: T) => React.ReactNode);
|
|
48
|
+
/**
|
|
49
|
+
* Data type
|
|
50
|
+
*/
|
|
51
|
+
dataType?: GridDataType;
|
|
52
|
+
/**
|
|
53
|
+
* Label field
|
|
54
|
+
*/
|
|
55
|
+
label?: string | ((item: T) => React.ReactNode);
|
|
56
|
+
/**
|
|
57
|
+
* Display as single row
|
|
58
|
+
*/
|
|
59
|
+
singleRow?: ViewPageRowType;
|
|
60
|
+
/**
|
|
61
|
+
* Render props
|
|
62
|
+
*/
|
|
63
|
+
renderProps?: GridColumnRenderProps;
|
|
64
|
+
}
|
|
65
|
+
type ViewPageFieldTypeNarrow<T extends object> = (string & keyof T) | [string & keyof T, GridDataType, GridColumnRenderProps?, ViewPageRowType?] | ViewPageField<T>;
|
|
66
|
+
/**
|
|
67
|
+
* View page field type
|
|
68
|
+
*/
|
|
69
|
+
export type ViewPageFieldType<T extends object> = ViewPageFieldTypeNarrow<T> | ((data: T, refresh: () => Promise<void>) => React.ReactNode | [React.ReactNode, ViewPageItemSize]);
|
|
70
|
+
export type ViewContainerProps<T extends DataTypes.StringRecord> = {
|
|
71
|
+
/**
|
|
72
|
+
* Data
|
|
73
|
+
*/
|
|
74
|
+
data: T;
|
|
75
|
+
/**
|
|
76
|
+
* Fields to display
|
|
77
|
+
*/
|
|
78
|
+
fields: ViewPageFieldType<T>[];
|
|
79
|
+
/**
|
|
80
|
+
* Grid container reference
|
|
81
|
+
*/
|
|
82
|
+
gridRef?: React.Ref<HTMLDivElement>;
|
|
83
|
+
/**
|
|
84
|
+
* Left container
|
|
85
|
+
*/
|
|
86
|
+
leftContainer?: (data: T) => React.ReactNode;
|
|
87
|
+
/**
|
|
88
|
+
* Left container height in lines
|
|
89
|
+
*/
|
|
90
|
+
leftContainerLines?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Left container properties
|
|
93
|
+
*/
|
|
94
|
+
leftContainerProps?: Omit<Grid2Props, "size"> & {
|
|
95
|
+
size?: ViewPageItemSize;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Refresh function
|
|
99
|
+
*/
|
|
100
|
+
refresh: () => Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Grid spacing
|
|
103
|
+
*/
|
|
104
|
+
spacing?: Record<string, string | number>;
|
|
105
|
+
};
|
|
106
|
+
export declare function ViewContainer<T extends DataTypes.StringRecord>(props: ViewContainerProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
107
|
+
export {};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ViewPageSize = void 0;
|
|
7
|
+
exports.ViewPageGridItem = ViewPageGridItem;
|
|
8
|
+
exports.ViewContainer = ViewContainer;
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
11
|
+
const material_1 = require("@mui/material");
|
|
12
|
+
const react_2 = __importDefault(require("react"));
|
|
13
|
+
const MUGlobal_1 = require("./MUGlobal");
|
|
14
|
+
const useCurrentBreakpoint_1 = require("./useCurrentBreakpoint");
|
|
15
|
+
const GridDataFormat_1 = require("./GridDataFormat");
|
|
16
|
+
const ReactApp_1 = require("./app/ReactApp");
|
|
17
|
+
function formatItemData(app, fieldData) {
|
|
18
|
+
if (fieldData == null)
|
|
19
|
+
return undefined;
|
|
20
|
+
if (typeof fieldData === "string")
|
|
21
|
+
return fieldData;
|
|
22
|
+
if (fieldData instanceof Date)
|
|
23
|
+
return app.formatDate(fieldData, "d");
|
|
24
|
+
return `${fieldData}`;
|
|
25
|
+
}
|
|
26
|
+
function getResp(singleRow) {
|
|
27
|
+
const size = typeof singleRow === "object"
|
|
28
|
+
? singleRow
|
|
29
|
+
: singleRow === "medium"
|
|
30
|
+
? ViewPageSize.medium
|
|
31
|
+
: singleRow === "large"
|
|
32
|
+
? ViewPageSize.large
|
|
33
|
+
: singleRow === true
|
|
34
|
+
? ViewPageSize.line
|
|
35
|
+
: singleRow === false
|
|
36
|
+
? ViewPageSize.smallLine
|
|
37
|
+
: ViewPageSize.small;
|
|
38
|
+
return size;
|
|
39
|
+
}
|
|
40
|
+
function getItemField(app, field, data) {
|
|
41
|
+
// Item data and label
|
|
42
|
+
let itemData, itemLabel, gridProps = {}, size;
|
|
43
|
+
if (Array.isArray(field)) {
|
|
44
|
+
const [fieldData, fieldType, renderProps, singleRow = "small"] = field;
|
|
45
|
+
itemData = (0, GridDataFormat_1.GridDataFormat)(data[fieldData], fieldType, renderProps);
|
|
46
|
+
itemLabel = app.get(fieldData) ?? fieldData;
|
|
47
|
+
size = getResp(singleRow);
|
|
48
|
+
gridProps = { size };
|
|
49
|
+
}
|
|
50
|
+
else if (typeof field === "object") {
|
|
51
|
+
// Destruct
|
|
52
|
+
const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow = "default", ...rest } = field;
|
|
53
|
+
// Size
|
|
54
|
+
size = getResp(singleRow);
|
|
55
|
+
gridProps = {
|
|
56
|
+
...rest,
|
|
57
|
+
size
|
|
58
|
+
};
|
|
59
|
+
// Field data
|
|
60
|
+
if (typeof fieldData === "function")
|
|
61
|
+
itemData = fieldData(data);
|
|
62
|
+
else if (dataType == null)
|
|
63
|
+
itemData = formatItemData(app, data[fieldData]);
|
|
64
|
+
else
|
|
65
|
+
itemData = (0, GridDataFormat_1.GridDataFormat)(data[fieldData], dataType, renderProps);
|
|
66
|
+
// Field label
|
|
67
|
+
itemLabel =
|
|
68
|
+
fieldLabel === ""
|
|
69
|
+
? undefined
|
|
70
|
+
: fieldLabel == null && typeof fieldData === "string"
|
|
71
|
+
? app.get(fieldData) ?? fieldData
|
|
72
|
+
: typeof fieldLabel === "function"
|
|
73
|
+
? fieldLabel(data)
|
|
74
|
+
: fieldLabel != null
|
|
75
|
+
? app.get(fieldLabel) ?? fieldLabel
|
|
76
|
+
: undefined;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// Single field format
|
|
80
|
+
itemData = formatItemData(app, data[field]);
|
|
81
|
+
itemLabel = app.get(field) ?? field;
|
|
82
|
+
size = ViewPageSize.small;
|
|
83
|
+
gridProps = { size };
|
|
84
|
+
}
|
|
85
|
+
return [itemData, itemLabel, gridProps, size];
|
|
86
|
+
}
|
|
87
|
+
function getItemSize(bp, size) {
|
|
88
|
+
const v = size[bp];
|
|
89
|
+
if (v != null)
|
|
90
|
+
return v;
|
|
91
|
+
const index = breakpoints.indexOf(bp);
|
|
92
|
+
for (let i = index; i >= 0; i--) {
|
|
93
|
+
const v = size[breakpoints[i]];
|
|
94
|
+
if (v != null)
|
|
95
|
+
return v;
|
|
96
|
+
}
|
|
97
|
+
return 12;
|
|
98
|
+
}
|
|
99
|
+
const breakpoints = ["xs", "sm", "md", "lg", "xl"];
|
|
100
|
+
/**
|
|
101
|
+
* View page grid item size
|
|
102
|
+
*/
|
|
103
|
+
var ViewPageSize;
|
|
104
|
+
(function (ViewPageSize) {
|
|
105
|
+
ViewPageSize.large = {
|
|
106
|
+
xs: 12,
|
|
107
|
+
sm: 12,
|
|
108
|
+
md: 9,
|
|
109
|
+
lg: 6,
|
|
110
|
+
xl: 4
|
|
111
|
+
};
|
|
112
|
+
ViewPageSize.medium = {
|
|
113
|
+
xs: 12,
|
|
114
|
+
sm: 12,
|
|
115
|
+
md: 6,
|
|
116
|
+
lg: 4,
|
|
117
|
+
xl: 3
|
|
118
|
+
};
|
|
119
|
+
ViewPageSize.line = {
|
|
120
|
+
xs: 12,
|
|
121
|
+
sm: 12,
|
|
122
|
+
md: 12,
|
|
123
|
+
lg: 12,
|
|
124
|
+
xl: 12
|
|
125
|
+
};
|
|
126
|
+
ViewPageSize.small = { xs: 6, sm: 6, md: 4, lg: 3, xl: 2 };
|
|
127
|
+
ViewPageSize.smallLine = {
|
|
128
|
+
xs: 12,
|
|
129
|
+
sm: 6,
|
|
130
|
+
md: 4,
|
|
131
|
+
lg: 3,
|
|
132
|
+
xl: 2
|
|
133
|
+
};
|
|
134
|
+
function matchSize(size) {
|
|
135
|
+
return Object.fromEntries(Object.entries(size).map(([key, value]) => [
|
|
136
|
+
key,
|
|
137
|
+
value == null ? undefined : value === 12 ? 12 : 12 - value
|
|
138
|
+
]));
|
|
139
|
+
}
|
|
140
|
+
ViewPageSize.matchSize = matchSize;
|
|
141
|
+
})(ViewPageSize || (exports.ViewPageSize = ViewPageSize = {}));
|
|
142
|
+
/**
|
|
143
|
+
* View page grid item
|
|
144
|
+
* @param props Props
|
|
145
|
+
* @returns Result
|
|
146
|
+
*/
|
|
147
|
+
function ViewPageGridItem(props) {
|
|
148
|
+
// Destruct
|
|
149
|
+
const { data, label, singleRow, ...gridProps } = props;
|
|
150
|
+
// Default options
|
|
151
|
+
let options = {};
|
|
152
|
+
if (gridProps.size == null) {
|
|
153
|
+
options = getResp(singleRow ?? "small");
|
|
154
|
+
}
|
|
155
|
+
else if (singleRow != null) {
|
|
156
|
+
options = getResp(singleRow ?? "small");
|
|
157
|
+
}
|
|
158
|
+
// Layout
|
|
159
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Grid2, { ...gridProps, ...options, children: [label != null && ((0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", component: "div", children: [label, ":"] })), typeof data === "object" ? (data) : ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", children: data }))] }));
|
|
160
|
+
}
|
|
161
|
+
function ViewContainer(props) {
|
|
162
|
+
// Global app
|
|
163
|
+
const app = (0, ReactApp_1.useRequiredAppContext)();
|
|
164
|
+
// Destruct
|
|
165
|
+
const { data, fields, gridRef, leftContainer, leftContainerLines = 3, leftContainerProps = {}, refresh, spacing = MUGlobal_1.MUGlobal.half(MUGlobal_1.MUGlobal.pagePaddings), ...rest } = props;
|
|
166
|
+
// Left container
|
|
167
|
+
const { size = ViewPageSize.smallLine, ...leftContainerPropsRest } = leftContainerProps;
|
|
168
|
+
// Current breakpoint
|
|
169
|
+
const bp = (0, useCurrentBreakpoint_1.useCurrentBreakpoint)();
|
|
170
|
+
// Create fields
|
|
171
|
+
const fieldIndexRef = react_2.default.useRef(0);
|
|
172
|
+
const createFields = react_2.default.useCallback((data, maxItems = 0) => {
|
|
173
|
+
let validItems = 0;
|
|
174
|
+
const items = [];
|
|
175
|
+
let i = fieldIndexRef.current;
|
|
176
|
+
for (; i < fields.length; i++) {
|
|
177
|
+
const field = fields[i];
|
|
178
|
+
let oneSize;
|
|
179
|
+
let oneItem;
|
|
180
|
+
if (typeof field === "function") {
|
|
181
|
+
// Most flexible way, do whatever you want
|
|
182
|
+
const createdResult = field(data, refresh);
|
|
183
|
+
if (createdResult == null || createdResult === "")
|
|
184
|
+
continue;
|
|
185
|
+
if (Array.isArray(createdResult)) {
|
|
186
|
+
const [created, size] = createdResult;
|
|
187
|
+
oneSize = size;
|
|
188
|
+
oneItem = created;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
oneSize = ViewPageSize.line;
|
|
192
|
+
oneItem = createdResult;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const [itemData, itemLabel, gridProps, size] = getItemField(app, field, data);
|
|
197
|
+
// Some callback function may return '' instead of undefined
|
|
198
|
+
if (itemData == null || itemData === "")
|
|
199
|
+
continue;
|
|
200
|
+
oneSize = size;
|
|
201
|
+
oneItem = ((0, react_1.createElement)(ViewPageGridItem, { ...gridProps, key: i, data: itemData, label: itemLabel }));
|
|
202
|
+
}
|
|
203
|
+
// Max lines
|
|
204
|
+
if (maxItems > 0) {
|
|
205
|
+
const itemSize = getItemSize(bp, oneSize);
|
|
206
|
+
if (maxItems < validItems + itemSize) {
|
|
207
|
+
fieldIndexRef.current = i;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
items.push(oneItem);
|
|
212
|
+
validItems += itemSize;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
items.push(oneItem);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (maxItems === 0) {
|
|
220
|
+
fieldIndexRef.current = 0;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
fieldIndexRef.current = i;
|
|
224
|
+
}
|
|
225
|
+
return items;
|
|
226
|
+
}, [app, fields, data, bp]);
|
|
227
|
+
let leftResult;
|
|
228
|
+
// Layout
|
|
229
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Grid2, { container: true, justifyContent: "left", className: "ET-ViewPage", ref: gridRef, spacing: spacing, children: [leftContainer && (leftResult = leftContainer(data)) != null && ((0, jsx_runtime_1.jsxs)(react_2.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid2, { container: true, className: "ET-ViewPage-LeftContainer", spacing: spacing, size: size, ...leftContainerPropsRest, children: leftResult }), (0, jsx_runtime_1.jsx)(material_1.Grid2, { container: true, className: "ET-ViewPage-LeftOthers", spacing: spacing, size: ViewPageSize.matchSize(size), children: createFields(data, leftContainerLines * (12 - getItemSize(bp, size))) })] })), createFields(data)] }));
|
|
230
|
+
}
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export * from "./DialogButton";
|
|
|
53
53
|
export * from "./DnDList";
|
|
54
54
|
export * from "./DraggablePaperComponent";
|
|
55
55
|
export * from "./EmailInput";
|
|
56
|
+
export * from "./ErrorAlert";
|
|
56
57
|
export * from "./FabBox";
|
|
57
58
|
export * from "./FieldSetEx";
|
|
58
59
|
export * from "./FileUploadButton";
|
|
@@ -116,3 +117,4 @@ export * from "./useCurrentBreakpoint";
|
|
|
116
117
|
export * from "./TooltipClick";
|
|
117
118
|
export * from "./UserAvatar";
|
|
118
119
|
export * from "./UserAvatarEditor";
|
|
120
|
+
export * from "./ViewContainer";
|
package/lib/cjs/index.js
CHANGED
|
@@ -69,6 +69,7 @@ __exportStar(require("./DialogButton"), exports);
|
|
|
69
69
|
__exportStar(require("./DnDList"), exports);
|
|
70
70
|
__exportStar(require("./DraggablePaperComponent"), exports);
|
|
71
71
|
__exportStar(require("./EmailInput"), exports);
|
|
72
|
+
__exportStar(require("./ErrorAlert"), exports);
|
|
72
73
|
__exportStar(require("./FabBox"), exports);
|
|
73
74
|
__exportStar(require("./FieldSetEx"), exports);
|
|
74
75
|
__exportStar(require("./FileUploadButton"), exports);
|
|
@@ -132,3 +133,4 @@ __exportStar(require("./useCurrentBreakpoint"), exports);
|
|
|
132
133
|
__exportStar(require("./TooltipClick"), exports);
|
|
133
134
|
__exportStar(require("./UserAvatar"), exports);
|
|
134
135
|
__exportStar(require("./UserAvatarEditor"), exports);
|
|
136
|
+
__exportStar(require("./ViewContainer"), exports);
|
|
@@ -1,78 +1,12 @@
|
|
|
1
|
-
import { GridColumnRenderProps, GridDataType } from "@etsoo/react";
|
|
2
1
|
import { DataTypes } from "@etsoo/shared";
|
|
3
|
-
import { Breakpoint, Grid2Props } from "@mui/material";
|
|
4
2
|
import React from "react";
|
|
5
3
|
import { CommonPageProps } from "./CommonPage";
|
|
6
4
|
import type { OperationMessageHandlerAll } from "../messages/OperationMessageHandler";
|
|
7
|
-
|
|
8
|
-
* View page item size
|
|
9
|
-
*/
|
|
10
|
-
export type ViewPageItemSize = Record<Breakpoint, number | undefined>;
|
|
11
|
-
/**
|
|
12
|
-
* View page grid item size
|
|
13
|
-
*/
|
|
14
|
-
export declare namespace ViewPageSize {
|
|
15
|
-
const large: ViewPageItemSize;
|
|
16
|
-
const medium: ViewPageItemSize;
|
|
17
|
-
const line: ViewPageItemSize;
|
|
18
|
-
const small: ViewPageItemSize;
|
|
19
|
-
const smallLine: ViewPageItemSize;
|
|
20
|
-
function matchSize(size: ViewPageItemSize): {
|
|
21
|
-
[k: string]: number | undefined;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* View page grid item properties
|
|
26
|
-
*/
|
|
27
|
-
export type ViewPageGridItemProps = Grid2Props & {
|
|
28
|
-
data: React.ReactNode;
|
|
29
|
-
label?: React.ReactNode;
|
|
30
|
-
singleRow?: ViewPageRowType;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* View page grid item
|
|
34
|
-
* @param props Props
|
|
35
|
-
* @returns Result
|
|
36
|
-
*/
|
|
37
|
-
export declare function ViewPageGridItem(props: ViewPageGridItemProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
-
/**
|
|
39
|
-
* View page row width type
|
|
40
|
-
*/
|
|
41
|
-
export type ViewPageRowType = boolean | "default" | "small" | "medium" | "large" | ViewPageItemSize;
|
|
42
|
-
/**
|
|
43
|
-
* View page display field
|
|
44
|
-
*/
|
|
45
|
-
export interface ViewPageField<T extends object> extends Grid2Props {
|
|
46
|
-
/**
|
|
47
|
-
* Data field
|
|
48
|
-
*/
|
|
49
|
-
data: (string & keyof T) | ((item: T) => React.ReactNode);
|
|
50
|
-
/**
|
|
51
|
-
* Data type
|
|
52
|
-
*/
|
|
53
|
-
dataType?: GridDataType;
|
|
54
|
-
/**
|
|
55
|
-
* Label field
|
|
56
|
-
*/
|
|
57
|
-
label?: string | ((item: T) => React.ReactNode);
|
|
58
|
-
/**
|
|
59
|
-
* Display as single row
|
|
60
|
-
*/
|
|
61
|
-
singleRow?: ViewPageRowType;
|
|
62
|
-
/**
|
|
63
|
-
* Render props
|
|
64
|
-
*/
|
|
65
|
-
renderProps?: GridColumnRenderProps;
|
|
66
|
-
}
|
|
67
|
-
type ViewPageFieldTypeNarrow<T extends object> = (string & keyof T) | [string & keyof T, GridDataType, GridColumnRenderProps?, ViewPageRowType?] | ViewPageField<T>;
|
|
68
|
-
/**
|
|
69
|
-
* View page field type
|
|
70
|
-
*/
|
|
71
|
-
export type ViewPageFieldType<T extends object> = ViewPageFieldTypeNarrow<T> | ((data: T, refresh: () => Promise<void>) => React.ReactNode | [React.ReactNode, ViewPageItemSize]);
|
|
5
|
+
import { ViewContainerProps } from "../ViewContainer";
|
|
72
6
|
/**
|
|
73
7
|
* View page props
|
|
74
8
|
*/
|
|
75
|
-
export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<CommonPageProps, "children"> {
|
|
9
|
+
export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<CommonPageProps, "children">, Omit<ViewContainerProps<T>, "data"> {
|
|
76
10
|
/**
|
|
77
11
|
* Actions
|
|
78
12
|
*/
|
|
@@ -85,10 +19,6 @@ export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<Co
|
|
|
85
19
|
* Children
|
|
86
20
|
*/
|
|
87
21
|
children?: React.ReactNode | ((data: T, refresh: () => PromiseLike<void>) => React.ReactNode);
|
|
88
|
-
/**
|
|
89
|
-
* Fields to display
|
|
90
|
-
*/
|
|
91
|
-
fields: ViewPageFieldType<T>[];
|
|
92
22
|
/**
|
|
93
23
|
* Load data
|
|
94
24
|
*/
|
|
@@ -97,18 +27,10 @@ export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<Co
|
|
|
97
27
|
* Pull to refresh data
|
|
98
28
|
*/
|
|
99
29
|
pullToRefresh?: boolean;
|
|
100
|
-
/**
|
|
101
|
-
* Grid spacing
|
|
102
|
-
*/
|
|
103
|
-
spacing?: Record<string, string | number>;
|
|
104
30
|
/**
|
|
105
31
|
* Support refresh
|
|
106
32
|
*/
|
|
107
33
|
supportRefresh?: boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Grid container reference
|
|
110
|
-
*/
|
|
111
|
-
gridRef?: React.Ref<HTMLDivElement>;
|
|
112
34
|
/**
|
|
113
35
|
* Operation message handler
|
|
114
36
|
*/
|
|
@@ -122,24 +44,9 @@ export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<Co
|
|
|
122
44
|
* @returns
|
|
123
45
|
*/
|
|
124
46
|
titleBar?: (data: T) => React.ReactNode;
|
|
125
|
-
/**
|
|
126
|
-
* Left container
|
|
127
|
-
*/
|
|
128
|
-
leftContainer?: (data: T) => React.ReactNode;
|
|
129
|
-
/**
|
|
130
|
-
* Left container height in lines
|
|
131
|
-
*/
|
|
132
|
-
leftContainerLines?: number;
|
|
133
|
-
/**
|
|
134
|
-
* Left container properties
|
|
135
|
-
*/
|
|
136
|
-
leftContainerProps?: Omit<Grid2Props, "size"> & {
|
|
137
|
-
size?: ViewPageItemSize;
|
|
138
|
-
};
|
|
139
47
|
}
|
|
140
48
|
/**
|
|
141
49
|
* View page
|
|
142
50
|
* @param props Props
|
|
143
51
|
*/
|
|
144
52
|
export declare function ViewPage<T extends DataTypes.StringRecord>(props: ViewPageProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
145
|
-
export {};
|