@etsoo/materialui 1.4.86 → 1.4.88

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.
@@ -37,6 +37,11 @@ var DataGridRenderers;
37
37
  const value = formattedValue ?? data[field];
38
38
  if (value == null)
39
39
  return undefined;
40
+ // For unknow and string type, keep the simple format
41
+ if (type === react_1.GridDataType.Unkwown)
42
+ return value;
43
+ else if (type === react_1.GridDataType.String)
44
+ return new String(value);
40
45
  // For date time
41
46
  // Conversion if necessary
42
47
  if (type === react_1.GridDataType.Date || type === react_1.GridDataType.DateTime) {
@@ -176,7 +176,7 @@ function ResponsibleContainer(props) {
176
176
  rect.width < 20)
177
177
  return;
178
178
  const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
179
- return ((0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}`, top: searchBarTop }));
179
+ return ((0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}`, width: rect.width, top: searchBarTop }));
180
180
  }, [showDataGrid, hasFields, searchBarHeight, rect?.width]);
181
181
  // Pull container
182
182
  const pullContainer = showDataGrid == null
@@ -27,6 +27,10 @@ export interface SearchBarProps {
27
27
  * Top position, true means Toolbar's height
28
28
  */
29
29
  top?: number | true;
30
+ /**
31
+ * Width
32
+ */
33
+ width: number;
30
34
  }
31
35
  /**
32
36
  * Search bar
@@ -76,7 +76,7 @@ function checkFormEvent(event) {
76
76
  */
77
77
  function SearchBar(props) {
78
78
  // Destruct
79
- const { className, fields, onSubmit, itemGap = 6, itemWidth = 160, top } = props;
79
+ const { className, fields, onSubmit, itemGap = 6, itemWidth = 160, top, width } = props;
80
80
  // Labels
81
81
  const labels = Labels_1.Labels.CommonPage;
82
82
  // Menu index
@@ -240,10 +240,10 @@ function SearchBar(props) {
240
240
  };
241
241
  }, [className]);
242
242
  // Layout
243
- return ((0, jsx_runtime_1.jsxs)(material_1.Container, { fixed: true, ref: dimensions[0][0], children: [(0, jsx_runtime_1.jsx)("form", { id: "SearchBarForm", className: className, onChange: handleForm, ref: (form) => {
243
+ return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)("form", { id: "SearchBarForm", className: className, onChange: handleForm, ref: (form) => {
244
244
  if (form)
245
245
  state.form = form;
246
- }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "SearchBarContainer", justifyContent: "center", alignItems: "center", direction: "row", spacing: `${itemGap}px`, width: "100%", overflow: "hidden", paddingTop: "6px", sx: {
246
+ }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { ref: dimensions[0][0], className: "SearchBarContainer", justifyContent: "center", alignItems: "center", direction: "row", spacing: `${itemGap}px`, width: width, overflow: "hidden", paddingTop: "6px", sx: {
247
247
  "& > :not(style)": {
248
248
  flexBasis: "auto",
249
249
  flexGrow: 0,
@@ -1,4 +1,4 @@
1
- import { IUser } from "@etsoo/appscript";
1
+ import { IUser, LoginInputAuthResult } from "@etsoo/appscript";
2
2
  import { IActionResult } from "@etsoo/shared";
3
3
  /**
4
4
  * SmartERP user interface
@@ -18,4 +18,4 @@ export interface ISmartERPUser extends IUser {
18
18
  /**
19
19
  * SmartERP user login result
20
20
  */
21
- export type SmartERPLoginResult = IActionResult<ISmartERPUser>;
21
+ export type SmartERPLoginResult = IActionResult<ISmartERPUser | LoginInputAuthResult>;
@@ -110,5 +110,5 @@ function DataGridPage(props) {
110
110
  // Layout
111
111
  return ((0, jsx_runtime_1.jsx)(CommonPage_1.CommonPage, { ...pageProps, scrollContainer: states.element, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { ref: dimensions[0][0], sx: {
112
112
  paddingBottom: pageProps.paddings
113
- }, children: (0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop }) }), list] }) }));
113
+ }, children: rect && rect.width > 100 && ((0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop, width: rect.width })) }), list] }) }));
114
114
  }
@@ -100,5 +100,5 @@ function FixedListPage(props) {
100
100
  const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
101
101
  const { paddings, ...pageRest } = pageProps;
102
102
  // Layout
103
- return ((0, jsx_runtime_1.jsx)(CommonPage_1.CommonPage, { ...pageRest, paddings: {}, scrollContainer: scrollContainer, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { ref: dimensions[0][0], sx: { padding: paddings }, children: (0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop }) }), list] }) }));
103
+ return ((0, jsx_runtime_1.jsx)(CommonPage_1.CommonPage, { ...pageRest, paddings: {}, scrollContainer: scrollContainer, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { ref: dimensions[0][0], sx: { padding: paddings }, children: rect && rect.width > 100 && ((0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop, width: rect.width })) }), list] }) }));
104
104
  }
@@ -20,7 +20,7 @@ const GridUtils_1 = require("../GridUtils");
20
20
  */
21
21
  function ListPage(props) {
22
22
  // Destruct
23
- const { fields, fieldTemplate, loadData, mRef, pageProps = {}, cacheKey, cacheMinutes = 15, searchBarTop, ...rest } = props;
23
+ const { fields, fieldTemplate, loadData, mRef, pageProps = {}, cacheKey, cacheMinutes = 15, sizeReadyMiliseconds = 0, searchBarTop, ...rest } = props;
24
24
  pageProps.paddings ??= MUGlobal_1.MUGlobal.pagePaddings;
25
25
  // States
26
26
  const [states] = react_2.default.useState({});
@@ -46,6 +46,9 @@ function ListPage(props) {
46
46
  const localLoadData = (props, lastItem) => {
47
47
  return loadData(GridUtils_1.GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
48
48
  };
49
+ // Watch container
50
+ const { dimensions } = (0, react_1.useDimensions)(1, undefined, sizeReadyMiliseconds);
51
+ const rect = dimensions[0][2];
49
52
  // Search data
50
53
  const searchData = GridUtils_1.GridUtils.getSearchData(cacheKey);
51
54
  const onInitLoad = (ref) => {
@@ -77,7 +80,7 @@ function ListPage(props) {
77
80
  };
78
81
  const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
79
82
  // Layout
80
- return ((0, jsx_runtime_1.jsx)(CommonPage_1.CommonPage, { ...pageProps, scrollContainer: globalThis, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
83
+ return ((0, jsx_runtime_1.jsx)(CommonPage_1.CommonPage, { ...pageProps, scrollContainer: globalThis, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { ref: dimensions[0][0], sx: {
81
84
  paddingBottom: pageProps.paddings
82
- }, children: (0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop }) }), (0, jsx_runtime_1.jsx)(ScrollerListEx_1.ScrollerListEx, { autoLoad: false, loadData: localLoadData, onUpdateRows: GridUtils_1.GridUtils.getUpdateRowsHandler(cacheKey), onInitLoad: onInitLoad, onScroll: onListScroll, mRef: refs, ...rest })] }) }));
85
+ }, children: rect && rect.width > 100 && ((0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop, width: rect.width })) }), (0, jsx_runtime_1.jsx)(ScrollerListEx_1.ScrollerListEx, { autoLoad: false, loadData: localLoadData, onUpdateRows: GridUtils_1.GridUtils.getUpdateRowsHandler(cacheKey), onInitLoad: onInitLoad, onScroll: onListScroll, mRef: refs, ...rest })] }) }));
83
86
  }
@@ -20,7 +20,7 @@ const GridUtils_1 = require("../GridUtils");
20
20
  */
21
21
  function TablePage(props) {
22
22
  // Destruct
23
- const { columns, fields, fieldTemplate, loadData, mRef, sizeReadyMiliseconds = 0, pageProps = {}, cacheKey, cacheMinutes = 15, ...rest } = props;
23
+ const { columns, fields, fieldTemplate, loadData, mRef, sizeReadyMiliseconds = 0, pageProps = {}, cacheKey, cacheMinutes = 15, searchBarTop, ...rest } = props;
24
24
  pageProps.paddings ??= MUGlobal_1.MUGlobal.pagePaddings;
25
25
  // States
26
26
  const [states] = react_2.default.useState({});
@@ -68,5 +68,5 @@ function TablePage(props) {
68
68
  // Layout
69
69
  return ((0, jsx_runtime_1.jsx)(CommonPage_1.CommonPage, { ...pageProps, scrollContainer: globalThis, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { ref: dimensions[0][0], sx: {
70
70
  paddingBottom: pageProps.paddings
71
- }, children: (0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit }) }), list] }) }));
71
+ }, children: rect && rect.width > 100 && ((0, jsx_runtime_1.jsx)(SearchBar_1.SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop, width: rect.width })) }), list] }) }));
72
72
  }
@@ -31,6 +31,11 @@ export var DataGridRenderers;
31
31
  const value = formattedValue ?? data[field];
32
32
  if (value == null)
33
33
  return undefined;
34
+ // For unknow and string type, keep the simple format
35
+ if (type === GridDataType.Unkwown)
36
+ return value;
37
+ else if (type === GridDataType.String)
38
+ return new String(value);
34
39
  // For date time
35
40
  // Conversion if necessary
36
41
  if (type === GridDataType.Date || type === GridDataType.DateTime) {
@@ -170,7 +170,7 @@ export function ResponsibleContainer(props) {
170
170
  rect.width < 20)
171
171
  return;
172
172
  const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
173
- return (_jsx(SearchBar, { fields: f, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}`, top: searchBarTop }));
173
+ return (_jsx(SearchBar, { fields: f, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}`, width: rect.width, top: searchBarTop }));
174
174
  }, [showDataGrid, hasFields, searchBarHeight, rect?.width]);
175
175
  // Pull container
176
176
  const pullContainer = showDataGrid == null
@@ -27,6 +27,10 @@ export interface SearchBarProps {
27
27
  * Top position, true means Toolbar's height
28
28
  */
29
29
  top?: number | true;
30
+ /**
31
+ * Width
32
+ */
33
+ width: number;
30
34
  }
31
35
  /**
32
36
  * Search bar
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button, Container, Drawer, IconButton, Stack, Toolbar } from "@mui/material";
2
+ import { Button, Drawer, IconButton, Stack, Toolbar } from "@mui/material";
3
3
  import React from "react";
4
4
  import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
5
5
  import { DomUtils, NumberUtils } from "@etsoo/shared";
@@ -70,7 +70,7 @@ function checkFormEvent(event) {
70
70
  */
71
71
  export function SearchBar(props) {
72
72
  // Destruct
73
- const { className, fields, onSubmit, itemGap = 6, itemWidth = 160, top } = props;
73
+ const { className, fields, onSubmit, itemGap = 6, itemWidth = 160, top, width } = props;
74
74
  // Labels
75
75
  const labels = Labels.CommonPage;
76
76
  // Menu index
@@ -234,10 +234,10 @@ export function SearchBar(props) {
234
234
  };
235
235
  }, [className]);
236
236
  // Layout
237
- return (_jsxs(Container, { fixed: true, ref: dimensions[0][0], children: [_jsx("form", { id: "SearchBarForm", className: className, onChange: handleForm, ref: (form) => {
237
+ return (_jsxs(React.Fragment, { children: [_jsx("form", { id: "SearchBarForm", className: className, onChange: handleForm, ref: (form) => {
238
238
  if (form)
239
239
  state.form = form;
240
- }, children: _jsxs(Stack, { className: "SearchBarContainer", justifyContent: "center", alignItems: "center", direction: "row", spacing: `${itemGap}px`, width: "100%", overflow: "hidden", paddingTop: "6px", sx: {
240
+ }, children: _jsxs(Stack, { ref: dimensions[0][0], className: "SearchBarContainer", justifyContent: "center", alignItems: "center", direction: "row", spacing: `${itemGap}px`, width: width, overflow: "hidden", paddingTop: "6px", sx: {
241
241
  "& > :not(style)": {
242
242
  flexBasis: "auto",
243
243
  flexGrow: 0,
@@ -1,4 +1,4 @@
1
- import { IUser } from "@etsoo/appscript";
1
+ import { IUser, LoginInputAuthResult } from "@etsoo/appscript";
2
2
  import { IActionResult } from "@etsoo/shared";
3
3
  /**
4
4
  * SmartERP user interface
@@ -18,4 +18,4 @@ export interface ISmartERPUser extends IUser {
18
18
  /**
19
19
  * SmartERP user login result
20
20
  */
21
- export type SmartERPLoginResult = IActionResult<ISmartERPUser>;
21
+ export type SmartERPLoginResult = IActionResult<ISmartERPUser | LoginInputAuthResult>;
@@ -104,5 +104,5 @@ export function DataGridPage(props) {
104
104
  // Layout
105
105
  return (_jsx(CommonPage, { ...pageProps, scrollContainer: states.element, children: _jsxs(Stack, { children: [_jsx(Box, { ref: dimensions[0][0], sx: {
106
106
  paddingBottom: pageProps.paddings
107
- }, children: _jsx(SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop }) }), list] }) }));
107
+ }, children: rect && rect.width > 100 && (_jsx(SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop, width: rect.width })) }), list] }) }));
108
108
  }
@@ -94,5 +94,5 @@ export function FixedListPage(props) {
94
94
  const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
95
95
  const { paddings, ...pageRest } = pageProps;
96
96
  // Layout
97
- return (_jsx(CommonPage, { ...pageRest, paddings: {}, scrollContainer: scrollContainer, children: _jsxs(Stack, { children: [_jsx(Box, { ref: dimensions[0][0], sx: { padding: paddings }, children: _jsx(SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop }) }), list] }) }));
97
+ return (_jsx(CommonPage, { ...pageRest, paddings: {}, scrollContainer: scrollContainer, children: _jsxs(Stack, { children: [_jsx(Box, { ref: dimensions[0][0], sx: { padding: paddings }, children: rect && rect.width > 100 && (_jsx(SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop, width: rect.width })) }), list] }) }));
98
98
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCombinedRefs } from "@etsoo/react";
2
+ import { useCombinedRefs, useDimensions } from "@etsoo/react";
3
3
  import { Box, Stack } from "@mui/material";
4
4
  import React from "react";
5
5
  import { MUGlobal } from "../MUGlobal";
@@ -14,7 +14,7 @@ import { GridUtils } from "../GridUtils";
14
14
  */
15
15
  export function ListPage(props) {
16
16
  // Destruct
17
- const { fields, fieldTemplate, loadData, mRef, pageProps = {}, cacheKey, cacheMinutes = 15, searchBarTop, ...rest } = props;
17
+ const { fields, fieldTemplate, loadData, mRef, pageProps = {}, cacheKey, cacheMinutes = 15, sizeReadyMiliseconds = 0, searchBarTop, ...rest } = props;
18
18
  pageProps.paddings ??= MUGlobal.pagePaddings;
19
19
  // States
20
20
  const [states] = React.useState({});
@@ -40,6 +40,9 @@ export function ListPage(props) {
40
40
  const localLoadData = (props, lastItem) => {
41
41
  return loadData(GridUtils.createLoader(props, fieldTemplate, cacheKey, false), lastItem);
42
42
  };
43
+ // Watch container
44
+ const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
45
+ const rect = dimensions[0][2];
43
46
  // Search data
44
47
  const searchData = GridUtils.getSearchData(cacheKey);
45
48
  const onInitLoad = (ref) => {
@@ -71,7 +74,7 @@ export function ListPage(props) {
71
74
  };
72
75
  const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
73
76
  // Layout
74
- return (_jsx(CommonPage, { ...pageProps, scrollContainer: globalThis, children: _jsxs(Stack, { children: [_jsx(Box, { sx: {
77
+ return (_jsx(CommonPage, { ...pageProps, scrollContainer: globalThis, children: _jsxs(Stack, { children: [_jsx(Box, { ref: dimensions[0][0], sx: {
75
78
  paddingBottom: pageProps.paddings
76
- }, children: _jsx(SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop }) }), _jsx(ScrollerListEx, { autoLoad: false, loadData: localLoadData, onUpdateRows: GridUtils.getUpdateRowsHandler(cacheKey), onInitLoad: onInitLoad, onScroll: onListScroll, mRef: refs, ...rest })] }) }));
79
+ }, children: rect && rect.width > 100 && (_jsx(SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop, width: rect.width })) }), _jsx(ScrollerListEx, { autoLoad: false, loadData: localLoadData, onUpdateRows: GridUtils.getUpdateRowsHandler(cacheKey), onInitLoad: onInitLoad, onScroll: onListScroll, mRef: refs, ...rest })] }) }));
77
80
  }
@@ -14,7 +14,7 @@ import { GridUtils } from "../GridUtils";
14
14
  */
15
15
  export function TablePage(props) {
16
16
  // Destruct
17
- const { columns, fields, fieldTemplate, loadData, mRef, sizeReadyMiliseconds = 0, pageProps = {}, cacheKey, cacheMinutes = 15, ...rest } = props;
17
+ const { columns, fields, fieldTemplate, loadData, mRef, sizeReadyMiliseconds = 0, pageProps = {}, cacheKey, cacheMinutes = 15, searchBarTop, ...rest } = props;
18
18
  pageProps.paddings ??= MUGlobal.pagePaddings;
19
19
  // States
20
20
  const [states] = React.useState({});
@@ -62,5 +62,5 @@ export function TablePage(props) {
62
62
  // Layout
63
63
  return (_jsx(CommonPage, { ...pageProps, scrollContainer: globalThis, children: _jsxs(Stack, { children: [_jsx(Box, { ref: dimensions[0][0], sx: {
64
64
  paddingBottom: pageProps.paddings
65
- }, children: _jsx(SearchBar, { fields: f, onSubmit: onSubmit }) }), list] }) }));
65
+ }, children: rect && rect.width > 100 && (_jsx(SearchBar, { fields: f, onSubmit: onSubmit, top: searchBarTop, width: rect.width })) }), list] }) }));
66
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.4.86",
3
+ "version": "1.4.88",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -40,7 +40,7 @@
40
40
  "@dnd-kit/sortable": "^10.0.0",
41
41
  "@emotion/react": "^11.14.0",
42
42
  "@emotion/styled": "^11.14.0",
43
- "@etsoo/appscript": "^1.6.9",
43
+ "@etsoo/appscript": "^1.6.12",
44
44
  "@etsoo/notificationbase": "^1.1.58",
45
45
  "@etsoo/react": "^1.8.31",
46
46
  "@etsoo/shared": "^1.2.61",
@@ -41,6 +41,10 @@ export namespace DataGridRenderers {
41
41
  const value = formattedValue ?? data[field!];
42
42
  if (value == null) return undefined;
43
43
 
44
+ // For unknow and string type, keep the simple format
45
+ if (type === GridDataType.Unkwown) return value;
46
+ else if (type === GridDataType.String) return new String(value);
47
+
44
48
  // For date time
45
49
  // Conversion if necessary
46
50
  if (type === GridDataType.Date || type === GridDataType.DateTime) {
@@ -441,6 +441,7 @@ export function ResponsibleContainer<T extends object, F>(
441
441
  fields={f}
442
442
  onSubmit={onSubmit}
443
443
  className={`searchBar${showDataGrid ? "Grid" : "List"}`}
444
+ width={rect.width}
444
445
  top={searchBarTop}
445
446
  />
446
447
  );
package/src/SearchBar.tsx CHANGED
@@ -45,6 +45,11 @@ export interface SearchBarProps {
45
45
  * Top position, true means Toolbar's height
46
46
  */
47
47
  top?: number | true;
48
+
49
+ /**
50
+ * Width
51
+ */
52
+ width: number;
48
53
  }
49
54
 
50
55
  // Cached width attribute name
@@ -126,7 +131,8 @@ export function SearchBar(props: SearchBarProps) {
126
131
  onSubmit,
127
132
  itemGap = 6,
128
133
  itemWidth = 160,
129
- top
134
+ top,
135
+ width
130
136
  } = props;
131
137
 
132
138
  // Labels
@@ -337,7 +343,7 @@ export function SearchBar(props: SearchBarProps) {
337
343
 
338
344
  // Layout
339
345
  return (
340
- <Container fixed ref={dimensions[0][0]}>
346
+ <React.Fragment>
341
347
  <form
342
348
  id="SearchBarForm"
343
349
  className={className}
@@ -347,12 +353,13 @@ export function SearchBar(props: SearchBarProps) {
347
353
  }}
348
354
  >
349
355
  <Stack
356
+ ref={dimensions[0][0]}
350
357
  className="SearchBarContainer"
351
358
  justifyContent="center"
352
359
  alignItems="center"
353
360
  direction="row"
354
361
  spacing={`${itemGap}px`}
355
- width="100%"
362
+ width={width}
356
363
  overflow="hidden"
357
364
  paddingTop="6px"
358
365
  sx={{
@@ -429,6 +436,6 @@ export function SearchBar(props: SearchBarProps) {
429
436
  </form>
430
437
  </Drawer>
431
438
  )}
432
- </Container>
439
+ </React.Fragment>
433
440
  );
434
441
  }
@@ -1,4 +1,4 @@
1
- import { IUser } from "@etsoo/appscript";
1
+ import { IUser, LoginInputAuthResult } from "@etsoo/appscript";
2
2
  import { IActionResult } from "@etsoo/shared";
3
3
 
4
4
  /**
@@ -21,4 +21,6 @@ export interface ISmartERPUser extends IUser {
21
21
  /**
22
22
  * SmartERP user login result
23
23
  */
24
- export type SmartERPLoginResult = IActionResult<ISmartERPUser>;
24
+ export type SmartERPLoginResult = IActionResult<
25
+ ISmartERPUser | LoginInputAuthResult
26
+ >;
@@ -186,7 +186,14 @@ export function DataGridPage<T extends object, F>(
186
186
  paddingBottom: pageProps.paddings
187
187
  }}
188
188
  >
189
- <SearchBar fields={f} onSubmit={onSubmit} top={searchBarTop} />
189
+ {rect && rect.width > 100 && (
190
+ <SearchBar
191
+ fields={f}
192
+ onSubmit={onSubmit}
193
+ top={searchBarTop}
194
+ width={rect.width}
195
+ />
196
+ )}
190
197
  </Box>
191
198
  {list}
192
199
  </Stack>
@@ -179,7 +179,14 @@ export function FixedListPage<T extends object, F>(
179
179
  <CommonPage {...pageRest} paddings={{}} scrollContainer={scrollContainer}>
180
180
  <Stack>
181
181
  <Box ref={dimensions[0][0]} sx={{ padding: paddings }}>
182
- <SearchBar fields={f} onSubmit={onSubmit} top={searchBarTop} />
182
+ {rect && rect.width > 100 && (
183
+ <SearchBar
184
+ fields={f}
185
+ onSubmit={onSubmit}
186
+ top={searchBarTop}
187
+ width={rect.width}
188
+ />
189
+ )}
183
190
  </Box>
184
191
  {list}
185
192
  </Stack>
@@ -4,7 +4,8 @@ import {
4
4
  ListOnScrollProps,
5
5
  ScrollerListForwardRef,
6
6
  ScrollerListRef,
7
- useCombinedRefs
7
+ useCombinedRefs,
8
+ useDimensions
8
9
  } from "@etsoo/react";
9
10
  import { Box, Stack } from "@mui/material";
10
11
  import React from "react";
@@ -36,6 +37,7 @@ export function ListPage<T extends object, F>(props: ListPageProps<T, F>) {
36
37
  pageProps = {},
37
38
  cacheKey,
38
39
  cacheMinutes = 15,
40
+ sizeReadyMiliseconds = 0,
39
41
  searchBarTop,
40
42
  ...rest
41
43
  } = props;
@@ -78,6 +80,10 @@ export function ListPage<T extends object, F>(props: ListPageProps<T, F>) {
78
80
  );
79
81
  };
80
82
 
83
+ // Watch container
84
+ const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds);
85
+ const rect = dimensions[0][2];
86
+
81
87
  // Search data
82
88
  const searchData = GridUtils.getSearchData(cacheKey);
83
89
 
@@ -123,11 +129,19 @@ export function ListPage<T extends object, F>(props: ListPageProps<T, F>) {
123
129
  <CommonPage {...pageProps} scrollContainer={globalThis}>
124
130
  <Stack>
125
131
  <Box
132
+ ref={dimensions[0][0]}
126
133
  sx={{
127
134
  paddingBottom: pageProps.paddings
128
135
  }}
129
136
  >
130
- <SearchBar fields={f} onSubmit={onSubmit} top={searchBarTop} />
137
+ {rect && rect.width > 100 && (
138
+ <SearchBar
139
+ fields={f}
140
+ onSubmit={onSubmit}
141
+ top={searchBarTop}
142
+ width={rect.width}
143
+ />
144
+ )}
131
145
  </Box>
132
146
  <ScrollerListEx<T>
133
147
  autoLoad={false}
@@ -48,6 +48,7 @@ export function TablePage<
48
48
  pageProps = {},
49
49
  cacheKey,
50
50
  cacheMinutes = 15,
51
+ searchBarTop,
51
52
  ...rest
52
53
  } = props;
53
54
 
@@ -139,7 +140,14 @@ export function TablePage<
139
140
  paddingBottom: pageProps.paddings
140
141
  }}
141
142
  >
142
- <SearchBar fields={f} onSubmit={onSubmit} />
143
+ {rect && rect.width > 100 && (
144
+ <SearchBar
145
+ fields={f}
146
+ onSubmit={onSubmit}
147
+ top={searchBarTop}
148
+ width={rect.width}
149
+ />
150
+ )}
143
151
  </Box>
144
152
  {list}
145
153
  </Stack>