@etsoo/materialui 1.2.5 → 1.2.7

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,5 +1,6 @@
1
1
  import { Box, Paper, useTheme } from "@mui/material";
2
2
  import React from "react";
3
+ const initOpactiy = 0.15;
3
4
  /**
4
5
  * Fabs container box
5
6
  * @param props Props
@@ -11,6 +12,7 @@ export function FabBox(props) {
11
12
  // Theme
12
13
  const theme = useTheme();
13
14
  const spaceGap = theme.spacing(itemGap);
15
+ const [opacity, setOpacity] = React.useState(initOpactiy);
14
16
  if (columnDirection == null)
15
17
  return React.createElement(React.Fragment, null);
16
18
  return fabPanel ? (React.createElement(Paper, { sx: {
@@ -20,8 +22,9 @@ export function FabBox(props) {
20
22
  padding: spaceGap,
21
23
  flexDirection: columnDirection ? "column" : "row",
22
24
  gap: spaceGap,
25
+ opacity: opacity,
23
26
  ...sx
24
- }, ...rest })) : (React.createElement(Box, { sx: {
27
+ }, onMouseEnter: () => setOpacity(1), onMouseLeave: () => setOpacity(initOpactiy), ...rest })) : (React.createElement(Box, { sx: {
25
28
  position: "fixed",
26
29
  display: "flex",
27
30
  alignItems: "center",
@@ -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,23 @@ 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
+ ...(fabTop
53
+ ? {
54
+ top: distance,
55
+ right: distance
56
+ }
57
+ : {
58
+ bottom: distance,
59
+ right: distance
60
+ })
52
61
  }, columnDirection: fabColumnDirection, fabPanel: fabPanel },
53
62
  scrollContainer && (React.createElement(ScrollTopFab, { size: fabSize, target: scrollContainer, title: labels.scrollTop })),
54
63
  fabButtons,
@@ -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?: 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.5",
3
+ "version": "1.2.7",
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,6 +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.15;
5
6
 
6
7
  /**
7
8
  * Fabs container box props
@@ -42,6 +43,7 @@ export function FabBox(props: FabBoxProps) {
42
43
  // Theme
43
44
  const theme = useTheme();
44
45
  const spaceGap = theme.spacing(itemGap);
46
+ const [opacity, setOpacity] = React.useState(initOpactiy);
45
47
 
46
48
  if (columnDirection == null) return <React.Fragment />;
47
49
 
@@ -54,8 +56,11 @@ export function FabBox(props: FabBoxProps) {
54
56
  padding: spaceGap,
55
57
  flexDirection: columnDirection ? "column" : "row",
56
58
  gap: spaceGap,
59
+ opacity: opacity,
57
60
  ...sx
58
61
  }}
62
+ onMouseEnter={() => setOpacity(1)}
63
+ onMouseLeave={() => setOpacity(initOpactiy)}
59
64
  {...rest}
60
65
  />
61
66
  ) : (
@@ -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,15 @@ 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
+ ...(fabTop
93
+ ? {
94
+ top: distance,
95
+ right: distance
96
+ }
97
+ : {
98
+ bottom: distance,
99
+ right: distance
100
+ })
89
101
  }}
90
102
  columnDirection={fabColumnDirection}
91
103
  fabPanel={fabPanel}
@@ -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?: 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 ? (