@etsoo/materialui 1.2.6 → 1.2.8

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/FabBox.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Box, Paper, useTheme } from "@mui/material";
2
2
  import React from "react";
3
- const initOpactiy = 0.1;
3
+ const initOpactiy = 0.15;
4
4
  /**
5
5
  * Fabs container box
6
6
  * @param props Props
@@ -3,7 +3,7 @@ import { FabBox } from "../FabBox";
3
3
  import { ScrollTopFab } from "../ScrollTopFab";
4
4
  import { MUGlobal } from "../MUGlobal";
5
5
  import { MoreFab } from "../MoreFab";
6
- import { Container, Fab } from "@mui/material";
6
+ import { Container, Fab, useTheme } from "@mui/material";
7
7
  import RefreshIcon from "@mui/icons-material/Refresh";
8
8
  import { BackButton } from "../BackButton";
9
9
  import { Labels } from "../app/Labels";
@@ -18,7 +18,7 @@ export const CommonPageScrollContainer = global;
18
18
  */
19
19
  export function CommonPage(props) {
20
20
  // Destruct
21
- const { children, disableGutters = true, fabButtons, fabColumnDirection, fabPanel, fabPaddingAdjust = 1.5, fabSize = "small", maxWidth = false, moreActions, onRefresh, onUpdate, onUpdateAll, paddings = MUGlobal.pagePaddings, scrollContainer, supportBack = false, targetFields, sx = {}, ...rest } = props;
21
+ const { children, disableGutters = true, fabTop, fabButtons, fabColumnDirection, fabPanel, fabPaddingAdjust = 1.5, fabSize = "small", maxWidth = false, moreActions, onRefresh, onUpdate, onUpdateAll, paddings = MUGlobal.pagePaddings, scrollContainer, supportBack = false, targetFields, sx = {}, ...rest } = props;
22
22
  // Fab padding
23
23
  const fabPadding = MUGlobal.increase(MUGlobal.pagePaddings, fabPaddingAdjust);
24
24
  if (typeof sx === "object" && sx != null && !Reflect.has(sx, "padding")) {
@@ -41,14 +41,25 @@ export function CommonPage(props) {
41
41
  onRefresh();
42
42
  }
43
43
  : undefined;
44
+ const theme = useTheme();
45
+ const distance = React.useMemo(() => MUGlobal.updateWithTheme(fabPadding, theme.spacing), [fabPadding, theme.spacing]);
44
46
  // Return the UI
45
47
  return (React.createElement(React.Fragment, null,
46
48
  update && (React.createElement(ReactAppStateDetector, { targetFields: targetFields, update: update })),
47
49
  React.createElement(Container, { disableGutters: disableGutters, maxWidth: maxWidth, sx: sx, id: "page-container", ...rest },
48
50
  React.createElement(FabBox, { sx: {
49
51
  zIndex: 1,
50
- bottom: (theme) => MUGlobal.updateWithTheme(fabPadding, theme.spacing),
51
- right: (theme) => MUGlobal.updateWithTheme(fabPadding, theme.spacing)
52
+ ...(typeof fabTop === "function"
53
+ ? fabTop(theme, fabPadding)
54
+ : fabTop
55
+ ? {
56
+ top: MUGlobal.updateWithTheme(MUGlobal.increase(fabPadding, 7), theme.spacing),
57
+ right: distance
58
+ }
59
+ : {
60
+ bottom: distance,
61
+ right: distance
62
+ })
52
63
  }, columnDirection: fabColumnDirection, fabPanel: fabPanel },
53
64
  scrollContainer && (React.createElement(ScrollTopFab, { size: fabSize, target: scrollContainer, title: labels.scrollTop })),
54
65
  fabButtons,
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { UserKey } from "@etsoo/appscript";
3
3
  import { IStateUpdate, ListItemReact } from "@etsoo/react";
4
- import { ContainerProps } from "@mui/material";
4
+ import { ContainerProps, Theme } from "@mui/material";
5
5
  import { CustomFabSize } from "../CustomFabProps";
6
6
  /**
7
7
  * Common page props
@@ -28,6 +28,10 @@ export interface CommonPageProps extends Omit<ContainerProps, "id"> {
28
28
  * Add panel to the Fab
29
29
  */
30
30
  fabPanel?: boolean;
31
+ /**
32
+ * Fab lays in the top
33
+ */
34
+ fabTop?: ((theme: Theme, padding: {}) => object) | boolean;
31
35
  /**
32
36
  * More actions
33
37
  */
@@ -77,7 +77,7 @@ function getItemField(field, data) {
77
77
  */
78
78
  export function ViewPage(props) {
79
79
  // Destruct
80
- const { actions, children, fields, loadData, paddings = MUGlobal.pagePaddings, supportRefresh = true, fabColumnDirection = true, supportBack = true, pullToRefresh = true, gridRef, ...rest } = props;
80
+ const { actions, children, fields, loadData, paddings = MUGlobal.pagePaddings, supportRefresh = true, fabColumnDirection = true, fabTop = true, supportBack = true, pullToRefresh = true, gridRef, ...rest } = props;
81
81
  // Data
82
82
  const [data, setData] = React.useState();
83
83
  // Labels
@@ -91,7 +91,7 @@ export function ViewPage(props) {
91
91
  return;
92
92
  setData(result);
93
93
  };
94
- return (React.createElement(CommonPage, { paddings: paddings, onRefresh: supportRefresh ? refresh : undefined, onUpdate: supportRefresh ? undefined : refresh, ...rest, scrollContainer: globalThis, fabColumnDirection: fabColumnDirection, supportBack: supportBack }, data == null ? (React.createElement(LinearProgress, null)) : (React.createElement(React.Fragment, null,
94
+ return (React.createElement(CommonPage, { paddings: paddings, onRefresh: supportRefresh ? refresh : undefined, onUpdate: supportRefresh ? undefined : refresh, ...rest, scrollContainer: globalThis, fabColumnDirection: fabColumnDirection, fabTop: fabTop, supportBack: supportBack }, data == null ? (React.createElement(LinearProgress, null)) : (React.createElement(React.Fragment, null,
95
95
  React.createElement(Grid, { container: true, justifyContent: "left", spacing: paddings, className: "ET-ViewPage", ref: gridRef, sx: {
96
96
  ".MuiTypography-subtitle2": {
97
97
  fontWeight: "bold"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/FabBox.tsx CHANGED
@@ -2,7 +2,7 @@ import { Box, BoxProps, Paper, PaperProps, useTheme } from "@mui/material";
2
2
  import React from "react";
3
3
 
4
4
  type SharedProps = keyof BoxProps & keyof PaperProps;
5
- const initOpactiy = 0.1;
5
+ const initOpactiy = 0.15;
6
6
 
7
7
  /**
8
8
  * Fabs container box props
@@ -4,7 +4,7 @@ import { ScrollTopFab } from "../ScrollTopFab";
4
4
  import { MUGlobal } from "../MUGlobal";
5
5
  import { CommonPageProps } from "./CommonPageProps";
6
6
  import { MoreFab } from "../MoreFab";
7
- import { Container, Fab } from "@mui/material";
7
+ import { Container, Fab, useTheme } from "@mui/material";
8
8
  import RefreshIcon from "@mui/icons-material/Refresh";
9
9
  import { BackButton } from "../BackButton";
10
10
  import { Labels } from "../app/Labels";
@@ -24,6 +24,7 @@ export function CommonPage(props: CommonPageProps) {
24
24
  const {
25
25
  children,
26
26
  disableGutters = true,
27
+ fabTop,
27
28
  fabButtons,
28
29
  fabColumnDirection,
29
30
  fabPanel,
@@ -66,6 +67,12 @@ export function CommonPage(props: CommonPageProps) {
66
67
  }
67
68
  : undefined;
68
69
 
70
+ const theme = useTheme();
71
+ const distance = React.useMemo(
72
+ () => MUGlobal.updateWithTheme(fabPadding, theme.spacing),
73
+ [fabPadding, theme.spacing]
74
+ );
75
+
69
76
  // Return the UI
70
77
  return (
71
78
  <React.Fragment>
@@ -82,10 +89,20 @@ export function CommonPage(props: CommonPageProps) {
82
89
  <FabBox
83
90
  sx={{
84
91
  zIndex: 1,
85
- bottom: (theme) =>
86
- MUGlobal.updateWithTheme(fabPadding, theme.spacing),
87
- right: (theme) =>
88
- MUGlobal.updateWithTheme(fabPadding, theme.spacing)
92
+ ...(typeof fabTop === "function"
93
+ ? fabTop(theme, fabPadding)
94
+ : fabTop
95
+ ? {
96
+ top: MUGlobal.updateWithTheme(
97
+ MUGlobal.increase(fabPadding, 7),
98
+ theme.spacing
99
+ ),
100
+ right: distance
101
+ }
102
+ : {
103
+ bottom: distance,
104
+ right: distance
105
+ })
89
106
  }}
90
107
  columnDirection={fabColumnDirection}
91
108
  fabPanel={fabPanel}
@@ -1,6 +1,6 @@
1
1
  import { UserKey } from "@etsoo/appscript";
2
2
  import { IStateUpdate, ListItemReact } from "@etsoo/react";
3
- import { ContainerProps } from "@mui/material";
3
+ import { ContainerProps, Theme } from "@mui/material";
4
4
  import { CustomFabSize } from "../CustomFabProps";
5
5
 
6
6
  /**
@@ -33,6 +33,11 @@ export interface CommonPageProps extends Omit<ContainerProps, "id"> {
33
33
  */
34
34
  fabPanel?: boolean;
35
35
 
36
+ /**
37
+ * Fab lays in the top
38
+ */
39
+ fabTop?: ((theme: Theme, padding: {}) => object) | boolean;
40
+
36
41
  /**
37
42
  * More actions
38
43
  */
@@ -200,6 +200,7 @@ export function ViewPage<T extends DataTypes.StringRecord>(
200
200
  paddings = MUGlobal.pagePaddings,
201
201
  supportRefresh = true,
202
202
  fabColumnDirection = true,
203
+ fabTop = true,
203
204
  supportBack = true,
204
205
  pullToRefresh = true,
205
206
  gridRef,
@@ -230,6 +231,7 @@ export function ViewPage<T extends DataTypes.StringRecord>(
230
231
  {...rest}
231
232
  scrollContainer={globalThis}
232
233
  fabColumnDirection={fabColumnDirection}
234
+ fabTop={fabTop}
233
235
  supportBack={supportBack}
234
236
  >
235
237
  {data == null ? (