@etsoo/materialui 1.4.4 → 1.4.6

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.
Files changed (39) hide show
  1. package/lib/AddresSelector.d.ts +3 -2
  2. package/lib/AddresSelector.js +3 -3
  3. package/lib/HiSelector.d.ts +3 -3
  4. package/lib/HiSelector.js +2 -2
  5. package/lib/HiSelectorTL.d.ts +3 -3
  6. package/lib/HiSelectorTL.js +2 -2
  7. package/lib/ResponsiveStyleValue.d.ts +7 -0
  8. package/lib/ResponsiveStyleValue.js +1 -0
  9. package/lib/app/CommonApp.d.ts +2 -7
  10. package/lib/app/CommonApp.js +13 -70
  11. package/lib/app/ReactApp.d.ts +1 -2
  12. package/lib/app/ReactApp.js +2 -3
  13. package/lib/app/ServiceApp.d.ts +5 -7
  14. package/lib/app/ServiceApp.js +12 -9
  15. package/lib/custom/CustomFieldUtils.d.ts +8 -2
  16. package/lib/custom/CustomFieldUtils.js +5 -5
  17. package/lib/custom/CustomFieldViewer.d.ts +2 -2
  18. package/lib/custom/CustomFieldViewer.js +3 -3
  19. package/lib/custom/CustomFieldWindow.d.ts +2 -2
  20. package/lib/custom/CustomFieldWindow.js +2 -2
  21. package/lib/index.d.ts +1 -0
  22. package/lib/index.js +1 -0
  23. package/lib/pages/EditPage.js +2 -2
  24. package/lib/pages/ViewPage.d.ts +3 -3
  25. package/lib/pages/ViewPage.js +7 -6
  26. package/package.json +8 -8
  27. package/src/AddresSelector.tsx +13 -13
  28. package/src/HiSelector.tsx +13 -13
  29. package/src/HiSelectorTL.tsx +14 -13
  30. package/src/ResponsiveStyleValue.ts +11 -0
  31. package/src/app/CommonApp.ts +16 -99
  32. package/src/app/ReactApp.ts +2 -8
  33. package/src/app/ServiceApp.ts +14 -14
  34. package/src/custom/CustomFieldUtils.tsx +10 -11
  35. package/src/custom/CustomFieldViewer.tsx +7 -8
  36. package/src/custom/CustomFieldWindow.tsx +4 -4
  37. package/src/index.ts +1 -0
  38. package/src/pages/EditPage.tsx +10 -5
  39. package/src/pages/ViewPage.tsx +26 -25
@@ -5,7 +5,7 @@ import {
5
5
  } from "@etsoo/appscript";
6
6
  import { CustomFieldReactCollection, ICustomFieldReact } from "@etsoo/react";
7
7
  import { IdType, ListType2 } from "@etsoo/shared";
8
- import { Grid, GridProps, Typography } from "@mui/material";
8
+ import { Grid2, GridSize, Typography } from "@mui/material";
9
9
  import { TypographyProps } from "@mui/material/Typography";
10
10
  import React from "react";
11
11
  import { FieldCheckbox } from "./FieldCheckbox";
@@ -21,6 +21,7 @@ import { FieldJson } from "./FieldJson";
21
21
  import { FieldRadio } from "./FieldRadio";
22
22
  import { FieldSelect } from "./FieldSelect";
23
23
  import { FieldSwitch } from "./FieldSwitch";
24
+ import { ResponsiveStyleValue } from "../ResponsiveStyleValue";
24
25
 
25
26
  /**
26
27
  * Custom field utilities
@@ -82,14 +83,13 @@ export namespace CustomFieldUtils {
82
83
  const creator = customFieldCreators[field.type];
83
84
  if (creator == null) {
84
85
  return (
85
- <Grid
86
- item
86
+ <Grid2
87
87
  key={index}
88
+ size={transformSpace(field.space)}
88
89
  {...field.gridItemProps}
89
- {...transformSpace(field.space)}
90
90
  >
91
91
  {`Type ${field.type} is not supported currently`}
92
- </Grid>
92
+ </Grid2>
93
93
  );
94
94
  }
95
95
 
@@ -115,14 +115,13 @@ export namespace CustomFieldUtils {
115
115
  }
116
116
 
117
117
  return (
118
- <Grid
119
- item
118
+ <Grid2
120
119
  key={name ?? index}
120
+ size={transformSpace(field.space)}
121
121
  {...field.gridItemProps}
122
- {...transformSpace(field.space)}
123
122
  >
124
123
  {ui}
125
- </Grid>
124
+ </Grid2>
126
125
  );
127
126
  });
128
127
  }
@@ -150,7 +149,7 @@ export namespace CustomFieldUtils {
150
149
  * @returns Result
151
150
  */
152
151
  export function transformSpace(space?: CustomFieldSpace) {
153
- const props: GridProps =
152
+ const size: ResponsiveStyleValue<GridSize> =
154
153
  space === "full"
155
154
  ? { xs: 12 }
156
155
  : space === "quater"
@@ -162,7 +161,7 @@ export namespace CustomFieldUtils {
162
161
  : space === "half1"
163
162
  ? { xs: 12, sm: 6 }
164
163
  : { sm: 12, md: 6 };
165
- return props;
164
+ return size;
166
165
  }
167
166
 
168
167
  /**
@@ -1,5 +1,5 @@
1
1
  import { CustomFieldData } from "@etsoo/appscript";
2
- import { Grid, GridProps, Typography, TypographyProps } from "@mui/material";
2
+ import { Grid2, Grid2Props, Typography, TypographyProps } from "@mui/material";
3
3
  import { CustomFieldUtils } from "./CustomFieldUtils";
4
4
  import { MUGlobal } from "../MUGlobal";
5
5
  import { VBox } from "../FlexBox";
@@ -20,7 +20,7 @@ export type CustomFieldViewerProps = {
20
20
  * Grid props
21
21
  * 网格属性
22
22
  */
23
- gridProps?: GridProps;
23
+ gridProps?: Grid2Props;
24
24
 
25
25
  /**
26
26
  * JSON data
@@ -96,7 +96,7 @@ export function CustomFieldViewer(props: CustomFieldViewerProps) {
96
96
  }
97
97
 
98
98
  return (
99
- <Grid
99
+ <Grid2
100
100
  container
101
101
  justifyContent="left"
102
102
  spacing={spacing}
@@ -116,11 +116,10 @@ export function CustomFieldViewer(props: CustomFieldViewerProps) {
116
116
  const value = Utils.getNestedValue(data, name);
117
117
 
118
118
  return (
119
- <Grid
120
- item
119
+ <Grid2
121
120
  key={name ?? index}
121
+ size={CustomFieldUtils.transformSpace(field.space)}
122
122
  {...field.gridItemProps}
123
- {...CustomFieldUtils.transformSpace(field.space)}
124
123
  >
125
124
  <VBox gap={verticalGap}>
126
125
  <Typography fontWeight="bold" fontSize="small" {...titleProps}>
@@ -130,9 +129,9 @@ export function CustomFieldViewer(props: CustomFieldViewerProps) {
130
129
  {valueLabelFormatter(value, field)}
131
130
  </Typography>
132
131
  </VBox>
133
- </Grid>
132
+ </Grid2>
134
133
  );
135
134
  })}
136
- </Grid>
135
+ </Grid2>
137
136
  );
138
137
  }
@@ -1,7 +1,7 @@
1
1
  import { CustomFieldData } from "@etsoo/appscript";
2
2
  import { CustomFieldReactCollection } from "@etsoo/react";
3
3
  import { Utils } from "@etsoo/shared";
4
- import { Grid, GridProps, Stack } from "@mui/material";
4
+ import { Grid2, Grid2Props, Stack } from "@mui/material";
5
5
  import React from "react";
6
6
  import { globalApp } from "../app/ReactApp";
7
7
  import { MUGlobal } from "../MUGlobal";
@@ -64,7 +64,7 @@ export type CustomFieldWindowProps<D extends CustomFieldData> = {
64
64
  * Grid props
65
65
  * 网格属性
66
66
  */
67
- gridProps?: GridProps;
67
+ gridProps?: Grid2Props;
68
68
 
69
69
  /**
70
70
  * JSON data
@@ -156,7 +156,7 @@ export function CustomFieldWindow<D extends CustomFieldData = CustomFieldData>(
156
156
  fullScreen: app.smDown,
157
157
  inputs: (
158
158
  <Stack marginTop={1.5}>
159
- <Grid
159
+ <Grid2
160
160
  container
161
161
  justifyContent="left"
162
162
  spacing={spacing}
@@ -178,7 +178,7 @@ export function CustomFieldWindow<D extends CustomFieldData = CustomFieldData>(
178
178
  Utils.setNestedValue(data, name, value);
179
179
  }
180
180
  )}
181
- </Grid>
181
+ </Grid2>
182
182
  </Stack>
183
183
  )
184
184
  }
package/src/index.ts CHANGED
@@ -95,6 +95,7 @@ export * from "./ProgressCount";
95
95
  export * from "./PullToRefreshUI";
96
96
  export * from "./QuickList";
97
97
  export * from "./ResponsibleContainer";
98
+ export * from "./ResponsiveStyleValue";
98
99
  export * from "./ScrollerListEx";
99
100
  export * from "./ScrollTopFab";
100
101
  export * from "./SearchBar";
@@ -1,4 +1,4 @@
1
- import { Button, Grid } from "@mui/material";
1
+ import { Button, Grid2 } from "@mui/material";
2
2
  import React, { FormEventHandler } from "react";
3
3
  import { MUGlobal } from "../MUGlobal";
4
4
  import { CommonPage, CommonPageProps } from "./CommonPage";
@@ -86,10 +86,15 @@ export function EditPage(props: EditPageProps) {
86
86
  )}
87
87
  {topPart}
88
88
  <form onSubmit={onSubmit}>
89
- <Grid container justifyContent="left" spacing={paddings} paddingTop={1}>
89
+ <Grid2
90
+ container
91
+ justifyContent="left"
92
+ spacing={paddings}
93
+ paddingTop={1}
94
+ >
90
95
  {children}
91
- </Grid>
92
- <Grid
96
+ </Grid2>
97
+ <Grid2
93
98
  container
94
99
  position="sticky"
95
100
  display="flex"
@@ -121,7 +126,7 @@ export function EditPage(props: EditPageProps) {
121
126
  {labels.save}
122
127
  </Button>
123
128
  {supportBack && <BackButton title={labels.back} />}
124
- </Grid>
129
+ </Grid2>
125
130
  </form>
126
131
  {bottomPart}
127
132
  </CommonPage>
@@ -5,8 +5,8 @@ import {
5
5
  } from "@etsoo/react";
6
6
  import { DataTypes, DateUtils, Utils } from "@etsoo/shared";
7
7
  import {
8
- Grid,
9
- GridProps,
8
+ Grid2,
9
+ Grid2Props,
10
10
  LinearProgress,
11
11
  Stack,
12
12
  Typography
@@ -26,7 +26,7 @@ import { OperationMessageContainer } from "../messages/OperationMessageContainer
26
26
  /**
27
27
  * View page grid item properties
28
28
  */
29
- export type ViewPageGridItemProps = GridProps & {
29
+ export type ViewPageGridItemProps = Grid2Props & {
30
30
  data: React.ReactNode;
31
31
  label?: React.ReactNode;
32
32
  singleRow?: ViewPageRowType;
@@ -43,7 +43,7 @@ export function ViewPageGridItem(props: ViewPageGridItemProps) {
43
43
 
44
44
  // Default options
45
45
  let options = {};
46
- if (gridProps.xs == null && gridProps.md == null) {
46
+ if (gridProps.size == null) {
47
47
  options = getResp(singleRow ?? "small");
48
48
  } else if (singleRow != null) {
49
49
  options = getResp(singleRow ?? "small");
@@ -51,7 +51,7 @@ export function ViewPageGridItem(props: ViewPageGridItemProps) {
51
51
 
52
52
  // Layout
53
53
  return (
54
- <Grid item {...gridProps} {...options}>
54
+ <Grid2 {...gridProps} {...options}>
55
55
  {label != null && (
56
56
  <Typography variant="caption" component="div">
57
57
  {label}:
@@ -62,7 +62,7 @@ export function ViewPageGridItem(props: ViewPageGridItemProps) {
62
62
  ) : (
63
63
  <Typography variant="subtitle2">{data}</Typography>
64
64
  )}
65
- </Grid>
65
+ </Grid2>
66
66
  );
67
67
  }
68
68
 
@@ -74,7 +74,7 @@ export type ViewPageRowType = boolean | "default" | "small" | "medium" | object;
74
74
  /**
75
75
  * View page display field
76
76
  */
77
- export interface ViewPageField<T extends object> extends GridProps {
77
+ export interface ViewPageField<T extends object> extends Grid2Props {
78
78
  /**
79
79
  * Data field
80
80
  */
@@ -181,29 +181,31 @@ function formatItemData(fieldData: unknown): string | undefined {
181
181
  }
182
182
 
183
183
  function getResp(singleRow: ViewPageRowType) {
184
- return typeof singleRow === "object"
185
- ? singleRow
186
- : singleRow === "medium"
187
- ? { xs: 12, sm: 12, md: 6, lg: 4, xl: 3 }
188
- : singleRow === true
189
- ? { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }
190
- : {
191
- xs: singleRow === false ? 12 : 6,
192
- sm: 6,
193
- md: 4,
194
- lg: 3,
195
- xl: 2
196
- };
184
+ const size =
185
+ typeof singleRow === "object"
186
+ ? singleRow
187
+ : singleRow === "medium"
188
+ ? { xs: 12, sm: 12, md: 6, lg: 4, xl: 3 }
189
+ : singleRow === true
190
+ ? { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }
191
+ : {
192
+ xs: singleRow === false ? 12 : 6,
193
+ sm: 6,
194
+ md: 4,
195
+ lg: 3,
196
+ xl: 2
197
+ };
198
+ return { size };
197
199
  }
198
200
 
199
201
  function getItemField<T extends object>(
200
202
  field: ViewPageFieldTypeNarrow<T>,
201
203
  data: T
202
- ): [React.ReactNode, React.ReactNode, GridProps] {
204
+ ): [React.ReactNode, React.ReactNode, Grid2Props] {
203
205
  // Item data and label
204
206
  let itemData: React.ReactNode,
205
207
  itemLabel: React.ReactNode,
206
- gridProps: GridProps = {};
208
+ gridProps: Grid2Props = {};
207
209
 
208
210
  if (Array.isArray(field)) {
209
211
  const [fieldData, fieldType, renderProps, singleRow = "small"] = field;
@@ -326,7 +328,7 @@ export function ViewPage<T extends DataTypes.StringRecord>(
326
328
  }
327
329
  />
328
330
  )}
329
- <Grid
331
+ <Grid2
330
332
  container
331
333
  justifyContent="left"
332
334
  spacing={spacing}
@@ -356,7 +358,6 @@ export function ViewPage<T extends DataTypes.StringRecord>(
356
358
  // Layout
357
359
  return (
358
360
  <ViewPageGridItem
359
- item
360
361
  {...gridProps}
361
362
  key={index}
362
363
  data={itemData}
@@ -364,7 +365,7 @@ export function ViewPage<T extends DataTypes.StringRecord>(
364
365
  />
365
366
  );
366
367
  })}
367
- </Grid>
368
+ </Grid2>
368
369
  {actions !== null && (
369
370
  <Stack
370
371
  className="ET-ViewPage-Actions"