@etsoo/materialui 1.1.64 → 1.1.66

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.
@@ -1,13 +1,17 @@
1
1
  /// <reference types="react" />
2
- import { IconButtonProps } from '@mui/material';
2
+ import { IconButtonProps } from "@mui/material";
3
3
  /**
4
4
  * IconButtonLink props
5
5
  */
6
- export type IconButtonLinkProps = Omit<IconButtonProps, 'href' | 'onClick'> & {
6
+ export type IconButtonLinkProps = Omit<IconButtonProps, "href" | "onClick"> & {
7
7
  /**
8
8
  * To href
9
9
  */
10
10
  href: string;
11
+ /**
12
+ * Link state
13
+ */
14
+ state?: any;
11
15
  };
12
16
  /**
13
17
  * IconButtonLink
@@ -1,6 +1,6 @@
1
- import { IconButton } from '@mui/material';
2
- import React from 'react';
3
- import { useNavigate } from 'react-router-dom';
1
+ import { IconButton } from "@mui/material";
2
+ import React from "react";
3
+ import { useNavigate } from "react-router-dom";
4
4
  /**
5
5
  * IconButtonLink
6
6
  * @param props Props
@@ -8,9 +8,9 @@ import { useNavigate } from 'react-router-dom';
8
8
  */
9
9
  export function IconButtonLink(props) {
10
10
  // Destruct
11
- const { href, ...rest } = props;
11
+ const { href, state, ...rest } = props;
12
12
  // Navigate
13
13
  const navigate = useNavigate();
14
14
  // Layout
15
- return React.createElement(IconButton, { ...rest, onClick: () => navigate(href) });
15
+ return React.createElement(IconButton, { ...rest, onClick: () => navigate(href, { state }) });
16
16
  }
package/lib/MoreFab.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { CustomFabProps } from './CustomFabProps';
2
- import React from 'react';
3
- import { PaperProps, PopoverOrigin } from '@mui/material';
4
- import { ListItemReact } from '@etsoo/react';
1
+ import { CustomFabProps } from "./CustomFabProps";
2
+ import React from "react";
3
+ import { PaperProps, PopoverOrigin } from "@mui/material";
4
+ import { ListItemReact } from "@etsoo/react";
5
5
  /**
6
6
  * More fab props
7
7
  */
package/lib/MoreFab.js CHANGED
@@ -1,12 +1,12 @@
1
- import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
2
- import React from 'react';
3
- import { Divider, Fab, IconButton, ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material';
4
- import { Link } from 'react-router-dom';
1
+ import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
2
+ import React from "react";
3
+ import { Divider, Fab, IconButton, ListItemIcon, ListItemText, Menu, MenuItem } from "@mui/material";
4
+ import { Link } from "react-router-dom";
5
5
  function getActions(input) {
6
6
  // Actions
7
7
  const actions = [];
8
8
  input.forEach((action) => {
9
- if (typeof action === 'boolean')
9
+ if (typeof action === "boolean")
10
10
  return;
11
11
  actions.push(action);
12
12
  });
@@ -19,38 +19,38 @@ function getActions(input) {
19
19
  export function MoreFab(props) {
20
20
  // Destruct
21
21
  const { actions, drawArrow = true, anchorOrigin = {
22
- vertical: 'top',
23
- horizontal: 'right'
24
- }, color = 'primary', icon = React.createElement(MoreHorizIcon, null), iconButton = false, PaperProps = drawArrow
22
+ vertical: "top",
23
+ horizontal: "right"
24
+ }, color = "primary", icon = React.createElement(MoreHorizIcon, null), iconButton = false, PaperProps = drawArrow
25
25
  ? {
26
26
  elevation: 0,
27
27
  sx: {
28
- overflow: 'visible',
29
- filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',
28
+ overflow: "visible",
29
+ filter: "drop-shadow(0px 2px 8px rgba(0,0,0,0.32))",
30
30
  mt: -0.4,
31
- '& .MuiAvatar-root': {
31
+ "& .MuiAvatar-root": {
32
32
  width: 32,
33
33
  height: 32,
34
34
  ml: -0.5,
35
35
  mr: 1
36
36
  },
37
- '&:before': {
37
+ "&:before": {
38
38
  content: '""',
39
- display: 'block',
40
- position: 'absolute',
39
+ display: "block",
40
+ position: "absolute",
41
41
  top: 0,
42
42
  right: 14,
43
43
  width: 10,
44
44
  height: 10,
45
- bgcolor: 'background.paper',
46
- transform: 'translateY(-50%) rotate(45deg)',
45
+ bgcolor: "background.paper",
46
+ transform: "translateY(-50%) rotate(45deg)",
47
47
  zIndex: 0
48
48
  }
49
49
  }
50
50
  }
51
51
  : undefined, size, title, transformOrigin = {
52
- vertical: 'bottom',
53
- horizontal: 'right'
52
+ vertical: "bottom",
53
+ horizontal: "right"
54
54
  } } = props;
55
55
  // State
56
56
  const [anchorEl, setAnchorEl] = React.useState();
@@ -75,21 +75,23 @@ export function MoreFab(props) {
75
75
  const main = iconButton ? (React.createElement(IconButton, { color: color, size: size, title: title, onClick: handleClick }, icon)) : (React.createElement(Fab, { color: color, size: size, title: title, onClick: handleClick }, icon));
76
76
  return (React.createElement(React.Fragment, null,
77
77
  main,
78
- React.createElement(Menu, { disableScrollLock: true, anchorEl: anchorEl, anchorOrigin: anchorOrigin, keepMounted: true, transformOrigin: transformOrigin, open: open, onClose: handleClose, PaperProps: PaperProps }, actionsLocal.map(({ label, icon, action }, index) => label === '-' ? (React.createElement(Divider, { key: index })) : (React.createElement(MenuItem, { key: label, ...(typeof action === 'string'
79
- ? action.includes('://')
78
+ React.createElement(Menu, { disableScrollLock: true, anchorEl: anchorEl, anchorOrigin: anchorOrigin, keepMounted: true, transformOrigin: transformOrigin, open: open, onClose: handleClose, PaperProps: PaperProps }, actionsLocal.map(({ label, icon, action }, index) => label === "-" ? (React.createElement(Divider, { key: index })) : (React.createElement(MenuItem, { key: label, ...(typeof action === "string"
79
+ ? action.includes("://")
80
80
  ? {
81
- component: 'a',
81
+ component: "a",
82
82
  href: action,
83
- target: '_blank'
83
+ target: "_blank"
84
84
  }
85
85
  : { component: Link, to: action }
86
- : {
87
- onClick: () => {
88
- handleClose();
89
- if (typeof action === 'function')
90
- action();
91
- }
92
- }) },
93
- icon != null && (React.createElement(ListItemIcon, null, icon)),
86
+ : Array.isArray(action)
87
+ ? { component: Link, to: action[0], state: action[1] }
88
+ : {
89
+ onClick: () => {
90
+ handleClose();
91
+ if (typeof action === "function")
92
+ action();
93
+ }
94
+ }) },
95
+ icon != null && React.createElement(ListItemIcon, null, icon),
94
96
  React.createElement(ListItemText, { inset: icon == null && hasIcon }, label)))))));
95
97
  }
package/lib/SearchBar.js CHANGED
@@ -224,11 +224,11 @@ export function SearchBar(props) {
224
224
  state.form = form;
225
225
  } },
226
226
  React.createElement(Stack, { ref: dimensions[0][0], justifyContent: "center", alignItems: "center", direction: "row", spacing: 1, width: "100%", sx: {
227
- overflowX: "hidden",
228
227
  "& > :not(style)": {
229
- flexBasis: `${itemWidth}px`,
228
+ flexBasis: "auto",
230
229
  flexGrow: 0,
231
230
  flexShrink: 0,
231
+ maxWidth: `${itemWidth}px`,
232
232
  visibility: "hidden"
233
233
  },
234
234
  "& > .hiddenChild": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.1.64",
3
+ "version": "1.1.66",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,9 +50,9 @@
50
50
  "@emotion/css": "^11.10.6",
51
51
  "@emotion/react": "^11.10.6",
52
52
  "@emotion/styled": "^11.10.6",
53
- "@etsoo/appscript": "^1.3.81",
53
+ "@etsoo/appscript": "^1.3.82",
54
54
  "@etsoo/notificationbase": "^1.1.24",
55
- "@etsoo/react": "^1.6.52",
55
+ "@etsoo/react": "^1.6.53",
56
56
  "@etsoo/shared": "^1.1.92",
57
57
  "@mui/icons-material": "^5.11.11",
58
58
  "@mui/material": "^5.11.14",
@@ -1,15 +1,20 @@
1
- import { IconButton, IconButtonProps } from '@mui/material';
2
- import React from 'react';
3
- import { useNavigate } from 'react-router-dom';
1
+ import { IconButton, IconButtonProps } from "@mui/material";
2
+ import React from "react";
3
+ import { useNavigate } from "react-router-dom";
4
4
 
5
5
  /**
6
6
  * IconButtonLink props
7
7
  */
8
- export type IconButtonLinkProps = Omit<IconButtonProps, 'href' | 'onClick'> & {
9
- /**
10
- * To href
11
- */
12
- href: string;
8
+ export type IconButtonLinkProps = Omit<IconButtonProps, "href" | "onClick"> & {
9
+ /**
10
+ * To href
11
+ */
12
+ href: string;
13
+
14
+ /**
15
+ * Link state
16
+ */
17
+ state?: any;
13
18
  };
14
19
 
15
20
  /**
@@ -18,12 +23,12 @@ export type IconButtonLinkProps = Omit<IconButtonProps, 'href' | 'onClick'> & {
18
23
  * @returns Component
19
24
  */
20
25
  export function IconButtonLink(props: IconButtonLinkProps) {
21
- // Destruct
22
- const { href, ...rest } = props;
26
+ // Destruct
27
+ const { href, state, ...rest } = props;
23
28
 
24
- // Navigate
25
- const navigate = useNavigate();
29
+ // Navigate
30
+ const navigate = useNavigate();
26
31
 
27
- // Layout
28
- return <IconButton {...rest} onClick={() => navigate(href)} />;
32
+ // Layout
33
+ return <IconButton {...rest} onClick={() => navigate(href, { state })} />;
29
34
  }
package/src/MoreFab.tsx CHANGED
@@ -1,71 +1,71 @@
1
- import { CustomFabProps } from './CustomFabProps';
2
- import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
3
- import React from 'react';
1
+ import { CustomFabProps } from "./CustomFabProps";
2
+ import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
3
+ import React from "react";
4
4
  import {
5
- Divider,
6
- Fab,
7
- IconButton,
8
- ListItemIcon,
9
- ListItemText,
10
- Menu,
11
- MenuItem,
12
- PaperProps,
13
- PopoverOrigin
14
- } from '@mui/material';
15
- import { Link } from 'react-router-dom';
16
- import { ListItemReact } from '@etsoo/react';
5
+ Divider,
6
+ Fab,
7
+ IconButton,
8
+ ListItemIcon,
9
+ ListItemText,
10
+ Menu,
11
+ MenuItem,
12
+ PaperProps,
13
+ PopoverOrigin
14
+ } from "@mui/material";
15
+ import { Link } from "react-router-dom";
16
+ import { ListItemReact } from "@etsoo/react";
17
17
 
18
18
  /**
19
19
  * More fab props
20
20
  */
21
21
  export interface MoreFabProps extends CustomFabProps {
22
- /**
23
- * Actions
24
- */
25
- actions?: (ListItemReact | boolean)[];
26
-
27
- /**
28
- * Dray arrow
29
- */
30
- drawArrow?: boolean;
31
-
32
- /**
33
- * Main icon
34
- */
35
- icon?: React.ReactNode;
36
-
37
- /**
38
- * Show as icon button
39
- */
40
- iconButton?: boolean;
41
-
42
- /**
43
- * This is the point on the anchor where the popover's
44
- * `anchorEl` will attach to
45
- */
46
- anchorOrigin?: PopoverOrigin;
47
-
48
- /**
49
- * Props applied to the [`Paper`](/api/paper/) element.
50
- * @default {}
51
- */
52
- PaperProps?: Partial<PaperProps>;
53
-
54
- /**
55
- * This is the point on the popover which
56
- * will attach to the anchor's origin
57
- */
58
- transformOrigin?: PopoverOrigin;
22
+ /**
23
+ * Actions
24
+ */
25
+ actions?: (ListItemReact | boolean)[];
26
+
27
+ /**
28
+ * Dray arrow
29
+ */
30
+ drawArrow?: boolean;
31
+
32
+ /**
33
+ * Main icon
34
+ */
35
+ icon?: React.ReactNode;
36
+
37
+ /**
38
+ * Show as icon button
39
+ */
40
+ iconButton?: boolean;
41
+
42
+ /**
43
+ * This is the point on the anchor where the popover's
44
+ * `anchorEl` will attach to
45
+ */
46
+ anchorOrigin?: PopoverOrigin;
47
+
48
+ /**
49
+ * Props applied to the [`Paper`](/api/paper/) element.
50
+ * @default {}
51
+ */
52
+ PaperProps?: Partial<PaperProps>;
53
+
54
+ /**
55
+ * This is the point on the popover which
56
+ * will attach to the anchor's origin
57
+ */
58
+ transformOrigin?: PopoverOrigin;
59
59
  }
60
60
 
61
61
  function getActions(input: (ListItemReact | boolean)[]): ListItemReact[] {
62
- // Actions
63
- const actions: ListItemReact[] = [];
64
- input.forEach((action) => {
65
- if (typeof action === 'boolean') return;
66
- actions.push(action);
67
- });
68
- return actions;
62
+ // Actions
63
+ const actions: ListItemReact[] = [];
64
+ input.forEach((action) => {
65
+ if (typeof action === "boolean") return;
66
+ actions.push(action);
67
+ });
68
+ return actions;
69
69
  }
70
70
 
71
71
  /**
@@ -73,139 +73,133 @@ function getActions(input: (ListItemReact | boolean)[]): ListItemReact[] {
73
73
  * @returns Component
74
74
  */
75
75
  export function MoreFab(props: MoreFabProps) {
76
- // Destruct
77
- const {
78
- actions,
79
- drawArrow = true,
80
- anchorOrigin = {
81
- vertical: 'top',
82
- horizontal: 'right'
83
- },
84
- color = 'primary',
85
- icon = <MoreHorizIcon />,
86
- iconButton = false,
87
- PaperProps = drawArrow
88
- ? {
89
- elevation: 0,
90
- sx: {
91
- overflow: 'visible',
92
- filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',
93
- mt: -0.4,
94
- '& .MuiAvatar-root': {
95
- width: 32,
96
- height: 32,
97
- ml: -0.5,
98
- mr: 1
99
- },
100
- '&:before': {
101
- content: '""',
102
- display: 'block',
103
- position: 'absolute',
104
- top: 0,
105
- right: 14,
106
- width: 10,
107
- height: 10,
108
- bgcolor: 'background.paper',
109
- transform: 'translateY(-50%) rotate(45deg)',
110
- zIndex: 0
111
- }
112
- }
113
- }
114
- : undefined,
115
- size,
116
- title,
117
- transformOrigin = {
118
- vertical: 'bottom',
119
- horizontal: 'right'
76
+ // Destruct
77
+ const {
78
+ actions,
79
+ drawArrow = true,
80
+ anchorOrigin = {
81
+ vertical: "top",
82
+ horizontal: "right"
83
+ },
84
+ color = "primary",
85
+ icon = <MoreHorizIcon />,
86
+ iconButton = false,
87
+ PaperProps = drawArrow
88
+ ? {
89
+ elevation: 0,
90
+ sx: {
91
+ overflow: "visible",
92
+ filter: "drop-shadow(0px 2px 8px rgba(0,0,0,0.32))",
93
+ mt: -0.4,
94
+ "& .MuiAvatar-root": {
95
+ width: 32,
96
+ height: 32,
97
+ ml: -0.5,
98
+ mr: 1
99
+ },
100
+ "&:before": {
101
+ content: '""',
102
+ display: "block",
103
+ position: "absolute",
104
+ top: 0,
105
+ right: 14,
106
+ width: 10,
107
+ height: 10,
108
+ bgcolor: "background.paper",
109
+ transform: "translateY(-50%) rotate(45deg)",
110
+ zIndex: 0
111
+ }
112
+ }
120
113
  }
121
- } = props;
122
-
123
- // State
124
- const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement>();
125
-
126
- // Open state
127
- const open = Boolean(anchorEl);
128
-
129
- // Handle click
130
- const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
131
- setAnchorEl(event.currentTarget);
132
- };
133
-
134
- // Handle close
135
- const handleClose = () => {
136
- setAnchorEl(undefined);
137
- };
138
-
139
- // No actions
140
- if (actions == null || actions.length == 0) return <React.Fragment />;
141
-
142
- // Actions
143
- const actionsLocal = getActions(actions);
144
-
145
- // Has any icon
146
- const hasIcon = actionsLocal.some((action) => action.icon != null);
147
-
148
- // Main
149
- const main = iconButton ? (
150
- <IconButton
151
- color={color}
152
- size={size}
153
- title={title}
154
- onClick={handleClick}
155
- >
156
- {icon}
157
- </IconButton>
158
- ) : (
159
- <Fab color={color} size={size} title={title} onClick={handleClick}>
160
- {icon}
161
- </Fab>
162
- );
163
-
164
- return (
165
- <React.Fragment>
166
- {main}
167
- <Menu
168
- disableScrollLock={true}
169
- anchorEl={anchorEl}
170
- anchorOrigin={anchorOrigin}
171
- keepMounted
172
- transformOrigin={transformOrigin}
173
- open={open}
174
- onClose={handleClose}
175
- PaperProps={PaperProps}
114
+ : undefined,
115
+ size,
116
+ title,
117
+ transformOrigin = {
118
+ vertical: "bottom",
119
+ horizontal: "right"
120
+ }
121
+ } = props;
122
+
123
+ // State
124
+ const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement>();
125
+
126
+ // Open state
127
+ const open = Boolean(anchorEl);
128
+
129
+ // Handle click
130
+ const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
131
+ setAnchorEl(event.currentTarget);
132
+ };
133
+
134
+ // Handle close
135
+ const handleClose = () => {
136
+ setAnchorEl(undefined);
137
+ };
138
+
139
+ // No actions
140
+ if (actions == null || actions.length == 0) return <React.Fragment />;
141
+
142
+ // Actions
143
+ const actionsLocal = getActions(actions);
144
+
145
+ // Has any icon
146
+ const hasIcon = actionsLocal.some((action) => action.icon != null);
147
+
148
+ // Main
149
+ const main = iconButton ? (
150
+ <IconButton color={color} size={size} title={title} onClick={handleClick}>
151
+ {icon}
152
+ </IconButton>
153
+ ) : (
154
+ <Fab color={color} size={size} title={title} onClick={handleClick}>
155
+ {icon}
156
+ </Fab>
157
+ );
158
+
159
+ return (
160
+ <React.Fragment>
161
+ {main}
162
+ <Menu
163
+ disableScrollLock={true}
164
+ anchorEl={anchorEl}
165
+ anchorOrigin={anchorOrigin}
166
+ keepMounted
167
+ transformOrigin={transformOrigin}
168
+ open={open}
169
+ onClose={handleClose}
170
+ PaperProps={PaperProps}
171
+ >
172
+ {actionsLocal.map(({ label, icon, action }, index) =>
173
+ label === "-" ? (
174
+ <Divider key={index} />
175
+ ) : (
176
+ <MenuItem
177
+ key={label}
178
+ {...(typeof action === "string"
179
+ ? action.includes("://")
180
+ ? {
181
+ component: "a",
182
+ href: action,
183
+ target: "_blank"
184
+ }
185
+ : { component: Link, to: action }
186
+ : Array.isArray(action)
187
+ ? { component: Link, to: action[0], state: action[1] }
188
+ : {
189
+ onClick: () => {
190
+ handleClose();
191
+ if (typeof action === "function") action();
192
+ }
193
+ })}
176
194
  >
177
- {actionsLocal.map(({ label, icon, action }, index) =>
178
- label === '-' ? (
179
- <Divider key={index} />
180
- ) : (
181
- <MenuItem
182
- key={label}
183
- {...(typeof action === 'string'
184
- ? action.includes('://')
185
- ? {
186
- component: 'a',
187
- href: action,
188
- target: '_blank'
189
- }
190
- : { component: Link, to: action }
191
- : {
192
- onClick: () => {
193
- handleClose();
194
- if (typeof action === 'function')
195
- action();
196
- }
197
- })}
198
- >
199
- {icon != null && (
200
- <ListItemIcon>{icon}</ListItemIcon>
201
- )}
202
- <ListItemText inset={icon == null && hasIcon}>
203
- {label}
204
- </ListItemText>
205
- </MenuItem>
206
- )
207
- )}
208
- </Menu>
209
- </React.Fragment>
210
- );
195
+ {icon != null && <ListItemIcon>{icon}</ListItemIcon>}
196
+ <ListItemText inset={icon == null && hasIcon}>
197
+ {label}
198
+ </ListItemText>
199
+ </MenuItem>
200
+ )
201
+ )}
202
+ </Menu>
203
+ </React.Fragment>
204
+ );
211
205
  }
package/src/SearchBar.tsx CHANGED
@@ -312,11 +312,11 @@ export function SearchBar(props: SearchBarProps) {
312
312
  spacing={1}
313
313
  width="100%"
314
314
  sx={{
315
- overflowX: "hidden",
316
315
  "& > :not(style)": {
317
- flexBasis: `${itemWidth}px`,
316
+ flexBasis: "auto",
318
317
  flexGrow: 0,
319
318
  flexShrink: 0,
319
+ maxWidth: `${itemWidth}px`,
320
320
  visibility: "hidden"
321
321
  },
322
322
  "& > .hiddenChild": {