@etsoo/materialui 1.2.0 → 1.2.1

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.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { BoxProps } from "@mui/material";
2
+ import { BoxProps, PaperProps } from "@mui/material";
3
+ type SharedProps = keyof BoxProps & keyof PaperProps;
3
4
  /**
4
5
  * Fabs container box props
5
6
  */
6
- export type FabBoxProps = BoxProps & {
7
+ export type FabBoxProps = Pick<BoxProps, SharedProps> & Pick<PaperProps, SharedProps> & {
7
8
  /**
8
9
  * Item gap
9
10
  */
@@ -23,3 +24,4 @@ export type FabBoxProps = BoxProps & {
23
24
  * @returns Component
24
25
  */
25
26
  export declare function FabBox(props: FabBoxProps): JSX.Element;
27
+ export {};
package/lib/FabBox.js CHANGED
@@ -7,7 +7,7 @@ import React from "react";
7
7
  */
8
8
  export function FabBox(props) {
9
9
  // Destruct
10
- const { columnDirection, fabPanel = columnDirection === false ? true : false, itemGap = 1, sx, ...rest } = props;
10
+ const { columnDirection, fabPanel = columnDirection, itemGap = 1, sx, ...rest } = props;
11
11
  // Theme
12
12
  const theme = useTheme();
13
13
  const spaceGap = theme.spacing(itemGap);
@@ -17,7 +17,15 @@ export function FabBox(props) {
17
17
  const margin = columnDirection
18
18
  ? { marginTop: spaceGap }
19
19
  : { marginLeft: spaceGap };
20
- const box = (React.createElement(Box, { sx: {
20
+ return fabPanel ? (React.createElement(Paper, { sx: {
21
+ position: "fixed",
22
+ display: "flex",
23
+ alignItems: "center",
24
+ padding: spaceGap,
25
+ flexDirection: columnDirection ? "column" : "row",
26
+ "& > :not(style) + :not(style)": margin,
27
+ ...sx
28
+ }, ...rest })) : (React.createElement(Box, { sx: {
21
29
  position: "fixed",
22
30
  display: "flex",
23
31
  alignItems: "center",
@@ -25,5 +33,4 @@ export function FabBox(props) {
25
33
  "& > :not(style) + :not(style)": margin,
26
34
  ...sx
27
35
  }, ...rest }));
28
- return fabPanel ? React.createElement(Paper, { sx: { padding: spaceGap } }, box) : box;
29
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
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
@@ -1,25 +1,28 @@
1
- import { Box, BoxProps, Paper, useTheme } from "@mui/material";
1
+ import { Box, BoxProps, Paper, PaperProps, useTheme } from "@mui/material";
2
2
  import React from "react";
3
3
 
4
+ type SharedProps = keyof BoxProps & keyof PaperProps;
5
+
4
6
  /**
5
7
  * Fabs container box props
6
8
  */
7
- export type FabBoxProps = BoxProps & {
8
- /**
9
- * Item gap
10
- */
11
- itemGap?: number;
9
+ export type FabBoxProps = Pick<BoxProps, SharedProps> &
10
+ Pick<PaperProps, SharedProps> & {
11
+ /**
12
+ * Item gap
13
+ */
14
+ itemGap?: number;
12
15
 
13
- /**
14
- * Flex direction, row or column
15
- */
16
- columnDirection?: boolean;
16
+ /**
17
+ * Flex direction, row or column
18
+ */
19
+ columnDirection?: boolean;
17
20
 
18
- /**
19
- * Add panel to the Fab
20
- */
21
- fabPanel?: boolean;
22
- };
21
+ /**
22
+ * Add panel to the Fab
23
+ */
24
+ fabPanel?: boolean;
25
+ };
23
26
 
24
27
  /**
25
28
  * Fabs container box
@@ -30,7 +33,7 @@ export function FabBox(props: FabBoxProps) {
30
33
  // Destruct
31
34
  const {
32
35
  columnDirection,
33
- fabPanel = columnDirection === false ? true : false,
36
+ fabPanel = columnDirection,
34
37
  itemGap = 1,
35
38
  sx,
36
39
  ...rest
@@ -47,7 +50,20 @@ export function FabBox(props: FabBoxProps) {
47
50
  ? { marginTop: spaceGap }
48
51
  : { marginLeft: spaceGap };
49
52
 
50
- const box = (
53
+ return fabPanel ? (
54
+ <Paper
55
+ sx={{
56
+ position: "fixed",
57
+ display: "flex",
58
+ alignItems: "center",
59
+ padding: spaceGap,
60
+ flexDirection: columnDirection ? "column" : "row",
61
+ "& > :not(style) + :not(style)": margin,
62
+ ...sx
63
+ }}
64
+ {...rest}
65
+ />
66
+ ) : (
51
67
  <Box
52
68
  sx={{
53
69
  position: "fixed",
@@ -60,6 +76,4 @@ export function FabBox(props: FabBoxProps) {
60
76
  {...rest}
61
77
  />
62
78
  );
63
-
64
- return fabPanel ? <Paper sx={{ padding: spaceGap }}>{box}</Paper> : box;
65
79
  }