@etsoo/react 1.4.64 → 1.4.65

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.
@@ -32,6 +32,10 @@ declare type ViewPageFieldType<T> = (string & keyof T) | [string & keyof T, Grid
32
32
  * View page props
33
33
  */
34
34
  export interface ViewPageProps<T extends {}> extends CommonPageProps {
35
+ /**
36
+ * Actions
37
+ */
38
+ actions?: React.ReactNode;
35
39
  /**
36
40
  * Fields to display
37
41
  */
@@ -1,6 +1,7 @@
1
1
  import { Grid, LinearProgress, Typography } from '@mui/material';
2
2
  import React from 'react';
3
3
  import { globalApp } from '../../app/ReactApp';
4
+ import { HBox } from '../FlexBox';
4
5
  import { GridDataFormat } from '../GridDataFormat';
5
6
  import { MUGlobal } from '../MUGlobal';
6
7
  import { CommonPage } from './CommonPage';
@@ -58,7 +59,7 @@ function getItemField(field, data) {
58
59
  */
59
60
  export function ViewPage(props) {
60
61
  // Destruct
61
- const { children, fields, loadData, paddings = MUGlobal.pagePaddings, supportRefresh = true, ...rest } = props;
62
+ const { actions, children, fields, loadData, paddings = MUGlobal.pagePaddings, supportRefresh = true, ...rest } = props;
62
63
  // Data
63
64
  const [data, setData] = React.useState();
64
65
  // Load data
@@ -70,7 +71,9 @@ export function ViewPage(props) {
70
71
  };
71
72
  return (React.createElement(CommonPage, { paddings: paddings, onRefresh: supportRefresh ? onRefresh : undefined, onUpdate: supportRefresh ? undefined : onRefresh, ...rest, scrollContainer: global }, data == null ? (React.createElement(LinearProgress, null)) : (React.createElement(React.Fragment, null,
72
73
  React.createElement(Grid, { container: true, justifyContent: "left", spacing: paddings, sx: {
73
- '.MuiTypography-subtitle2': { fontWeight: 'bold' }
74
+ '.MuiTypography-subtitle2': {
75
+ fontWeight: 'bold'
76
+ }
74
77
  } }, fields.map((field, index) => {
75
78
  // Get data
76
79
  const [itemData, itemLabel, gridProps] = getItemField(field, data);
@@ -83,5 +86,6 @@ export function ViewPage(props) {
83
86
  ":"),
84
87
  React.createElement(Typography, { variant: "subtitle2" }, itemData)));
85
88
  })),
89
+ actions != null && (React.createElement(HBox, { paddingTop: paddings, paddingBottom: paddings }, actions)),
86
90
  children))));
87
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.4.64",
3
+ "version": "1.4.65",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -5,6 +5,7 @@ import {
5
5
  GridColumnRenderProps,
6
6
  GridDataType
7
7
  } from '../../components/GridColumn';
8
+ import { HBox } from '../FlexBox';
8
9
  import { GridDataFormat } from '../GridDataFormat';
9
10
  import { MUGlobal } from '../MUGlobal';
10
11
  import { CommonPage } from './CommonPage';
@@ -49,6 +50,11 @@ type ViewPageFieldType<T> =
49
50
  * View page props
50
51
  */
51
52
  export interface ViewPageProps<T extends {}> extends CommonPageProps {
53
+ /**
54
+ * Actions
55
+ */
56
+ actions?: React.ReactNode;
57
+
52
58
  /**
53
59
  * Fields to display
54
60
  */
@@ -133,6 +139,7 @@ function getItemField<T>(
133
139
  export function ViewPage<T extends {}>(props: ViewPageProps<T>) {
134
140
  // Destruct
135
141
  const {
142
+ actions,
136
143
  children,
137
144
  fields,
138
145
  loadData,
@@ -168,7 +175,9 @@ export function ViewPage<T extends {}>(props: ViewPageProps<T>) {
168
175
  justifyContent="left"
169
176
  spacing={paddings}
170
177
  sx={{
171
- '.MuiTypography-subtitle2': { fontWeight: 'bold' }
178
+ '.MuiTypography-subtitle2': {
179
+ fontWeight: 'bold'
180
+ }
172
181
  }}
173
182
  >
174
183
  {fields.map((field, index) => {
@@ -194,6 +203,11 @@ export function ViewPage<T extends {}>(props: ViewPageProps<T>) {
194
203
  );
195
204
  })}
196
205
  </Grid>
206
+ {actions != null && (
207
+ <HBox paddingTop={paddings} paddingBottom={paddings}>
208
+ {actions}
209
+ </HBox>
210
+ )}
197
211
  {children}
198
212
  </React.Fragment>
199
213
  )}