@etsoo/materialui 1.4.33 → 1.4.35

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.
@@ -14,7 +14,7 @@ export type ResponsibleContainerProps<T extends object, F extends DataTypes.Basi
14
14
  * @param height Current calcuated height
15
15
  * @param rect Current rect data
16
16
  */
17
- adjustHeight?: (height: number, rect: DOMRect) => number;
17
+ adjustHeight?: number | ((height: number, rect: DOMRect) => number);
18
18
  /**
19
19
  *
20
20
  * @param height Current height
@@ -29,7 +29,7 @@ export type ResponsibleContainerProps<T extends object, F extends DataTypes.Basi
29
29
  /**
30
30
  * Container box SX (dataGrid determines the case)
31
31
  */
32
- containerBoxSx?: (paddings: Record<string, string | number>, hasFields: boolean, dataGrid?: boolean) => SxProps<Theme>;
32
+ containerBoxSx?: (paddings: number | Record<string, string | number>, hasFields: boolean, dataGrid?: boolean) => SxProps<Theme>;
33
33
  /**
34
34
  * Min width to show Datagrid
35
35
  */
@@ -73,7 +73,7 @@ export type ResponsibleContainerProps<T extends object, F extends DataTypes.Basi
73
73
  /**
74
74
  * Paddings
75
75
  */
76
- paddings?: Record<string, string | number>;
76
+ paddings?: number | Record<string, string | number>;
77
77
  /**
78
78
  * Pull to refresh data
79
79
  */
@@ -10,7 +10,7 @@ import { SearchBar } from "./SearchBar";
10
10
  import { Labels } from "./app/Labels";
11
11
  import { GridUtils } from "./GridUtils";
12
12
  function defaultContainerBoxSx(paddings, hasField, _dataGrid) {
13
- const half = MUGlobal.half(paddings);
13
+ const half = typeof paddings == "number" ? paddings / 2 : MUGlobal.half(paddings);
14
14
  return {
15
15
  "& .SearchBox": {
16
16
  marginBottom: hasField ? half : 0
@@ -136,7 +136,10 @@ export function ResponsibleContainer(props) {
136
136
  if (!isNaN(boxMargin))
137
137
  heightLocal -= 3 * boxMargin; // 1 - Box, 2 - Page bottom
138
138
  if (adjustHeight != null)
139
- heightLocal -= adjustHeight(heightLocal, rect);
139
+ heightLocal -=
140
+ typeof adjustHeight === "number"
141
+ ? adjustHeight
142
+ : adjustHeight(heightLocal, rect);
140
143
  }
141
144
  if (adjustFabHeight)
142
145
  heightLocal = adjustFabHeight(heightLocal, showDataGrid);
@@ -169,11 +172,14 @@ export function ResponsibleContainer(props) {
169
172
  ];
170
173
  })();
171
174
  const searchBar = React.useMemo(() => {
172
- if (!hasFields || showDataGrid == null)
175
+ if (!hasFields ||
176
+ showDataGrid == null ||
177
+ rect?.width == null ||
178
+ rect.width < 20)
173
179
  return;
174
180
  const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
175
181
  return (_jsx(SearchBar, { fields: f, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}` }));
176
- }, [showDataGrid, hasFields, searchBarHeight]);
182
+ }, [showDataGrid, hasFields, searchBarHeight, rect?.width]);
177
183
  // Pull container
178
184
  const pullContainer = showDataGrid == null
179
185
  ? undefined
@@ -51,7 +51,7 @@ export interface CommonPageProps extends Omit<ContainerProps, "id"> {
51
51
  /**
52
52
  * Paddings
53
53
  */
54
- paddings?: Record<string, string | number>;
54
+ paddings?: number | Record<string, string | number>;
55
55
  /**
56
56
  * Scroll container
57
57
  */
@@ -77,7 +77,10 @@ export function DataGridPage(props) {
77
77
  if (!isNaN(paddingBottom))
78
78
  gridHeight -= paddingBottom;
79
79
  if (adjustHeight != null)
80
- gridHeight -= adjustHeight(gridHeight, rect);
80
+ gridHeight -=
81
+ typeof adjustHeight === "number"
82
+ ? adjustHeight
83
+ : adjustHeight(gridHeight, rect);
81
84
  if (gridHeight !== states.height)
82
85
  setStates({ height: gridHeight });
83
86
  }
@@ -10,7 +10,7 @@ export type DataGridPageProps<T extends object, F extends DataTypes.BasicTemplat
10
10
  * @param height Current calcuated height
11
11
  * @param rect Current rect data
12
12
  */
13
- adjustHeight?: (height: number, rect: DOMRect) => number;
13
+ adjustHeight?: number | ((height: number, rect: DOMRect) => number);
14
14
  /**
15
15
  * Grid height
16
16
  */
@@ -11,5 +11,5 @@ export declare function FixedListPage<T extends object, F extends DataTypes.Basi
11
11
  * @param height Current calcuated height
12
12
  * @param rect Current rect data
13
13
  */
14
- adjustHeight?: (height: number, rect: DOMRect) => number;
14
+ adjustHeight?: number | ((height: number, rect: DOMRect) => number);
15
15
  }): import("react/jsx-runtime").JSX.Element;
@@ -79,7 +79,10 @@ export function FixedListPage(props) {
79
79
  let height = document.documentElement.clientHeight -
80
80
  Math.round(rect.top + rect.height + 1);
81
81
  if (adjustHeight != null)
82
- height -= adjustHeight(height, rect);
82
+ height -=
83
+ typeof adjustHeight === "number"
84
+ ? adjustHeight
85
+ : adjustHeight(height, rect);
83
86
  return (_jsx(Box, { id: "list-container", sx: {
84
87
  height: height + "px"
85
88
  }, children: _jsx(ScrollerListEx, { autoLoad: false, height: height, loadData: localLoadData, mRef: refs, onUpdateRows: GridUtils.getUpdateRowsHandler(cacheKey), onInitLoad: onInitLoad, onScroll: onListScroll, oRef: (element) => {
@@ -20,7 +20,9 @@ export function ResponsivePage(props) {
20
20
  // Layout
21
21
  return (_jsxs(CommonPage, { ...pageRest, paddings: {}, scrollContainer: scrollContainer, fabColumnDirection: direction, children: [operationMessageHandler && (_jsx(OperationMessageContainer, { handler: operationMessageHandler })), _jsx(ResponsibleContainer, { paddings: paddings, containerBoxSx: (paddings, hasField, _dataGrid) => {
22
22
  // Half
23
- const half = MUGlobal.half(paddings);
23
+ const half = typeof paddings == "number"
24
+ ? paddings / 2
25
+ : MUGlobal.half(paddings);
24
26
  // .SearchBox keep the same to avoid flick when switching between DataGrid and List
25
27
  return {
26
28
  paddingTop: paddings,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.4.33",
3
+ "version": "1.4.35",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -35,14 +35,14 @@
35
35
  "@emotion/css": "^11.13.5",
36
36
  "@emotion/react": "^11.13.5",
37
37
  "@emotion/styled": "^11.13.5",
38
- "@etsoo/appscript": "^1.5.72",
38
+ "@etsoo/appscript": "^1.5.76",
39
39
  "@etsoo/notificationbase": "^1.1.54",
40
40
  "@etsoo/react": "^1.8.3",
41
41
  "@etsoo/shared": "^1.2.55",
42
42
  "@mui/icons-material": "^6.1.9",
43
43
  "@mui/material": "^6.1.9",
44
- "@mui/x-data-grid": "^7.22.3",
45
- "chart.js": "^4.4.6",
44
+ "@mui/x-data-grid": "^7.23.0",
45
+ "chart.js": "^4.4.7",
46
46
  "chartjs-plugin-datalabels": "^2.2.0",
47
47
  "eventemitter3": "^5.0.1",
48
48
  "pica": "^9.0.1",
@@ -56,7 +56,7 @@ export type ResponsibleContainerProps<
56
56
  * @param height Current calcuated height
57
57
  * @param rect Current rect data
58
58
  */
59
- adjustHeight?: (height: number, rect: DOMRect) => number;
59
+ adjustHeight?: number | ((height: number, rect: DOMRect) => number);
60
60
 
61
61
  /**
62
62
  *
@@ -75,7 +75,7 @@ export type ResponsibleContainerProps<
75
75
  * Container box SX (dataGrid determines the case)
76
76
  */
77
77
  containerBoxSx?: (
78
- paddings: Record<string, string | number>,
78
+ paddings: number | Record<string, string | number>,
79
79
  hasFields: boolean,
80
80
  dataGrid?: boolean
81
81
  ) => SxProps<Theme>;
@@ -139,7 +139,7 @@ export type ResponsibleContainerProps<
139
139
  /**
140
140
  * Paddings
141
141
  */
142
- paddings?: Record<string, string | number>;
142
+ paddings?: number | Record<string, string | number>;
143
143
 
144
144
  /**
145
145
  * Pull to refresh data
@@ -170,11 +170,12 @@ interface LocalRefs<T> {
170
170
  }
171
171
 
172
172
  function defaultContainerBoxSx(
173
- paddings: object,
173
+ paddings: object | number,
174
174
  hasField: boolean,
175
175
  _dataGrid?: boolean
176
176
  ): SxProps<Theme> {
177
- const half = MUGlobal.half(paddings);
177
+ const half =
178
+ typeof paddings == "number" ? paddings / 2 : MUGlobal.half(paddings);
178
179
  return {
179
180
  "& .SearchBox": {
180
181
  marginBottom: hasField ? half : 0
@@ -357,7 +358,11 @@ export function ResponsibleContainer<
357
358
  const boxMargin = parseFloat(style.marginBottom);
358
359
  if (!isNaN(boxMargin)) heightLocal -= 3 * boxMargin; // 1 - Box, 2 - Page bottom
359
360
 
360
- if (adjustHeight != null) heightLocal -= adjustHeight(heightLocal, rect);
361
+ if (adjustHeight != null)
362
+ heightLocal -=
363
+ typeof adjustHeight === "number"
364
+ ? adjustHeight
365
+ : adjustHeight(heightLocal, rect);
361
366
  }
362
367
 
363
368
  if (adjustFabHeight)
@@ -424,7 +429,13 @@ export function ResponsibleContainer<
424
429
  })();
425
430
 
426
431
  const searchBar = React.useMemo(() => {
427
- if (!hasFields || showDataGrid == null) return;
432
+ if (
433
+ !hasFields ||
434
+ showDataGrid == null ||
435
+ rect?.width == null ||
436
+ rect.width < 20
437
+ )
438
+ return;
428
439
 
429
440
  const f = typeof fields == "function" ? fields(searchData ?? {}) : fields;
430
441
 
@@ -435,7 +446,7 @@ export function ResponsibleContainer<
435
446
  className={`searchBar${showDataGrid ? "Grid" : "List"}`}
436
447
  />
437
448
  );
438
- }, [showDataGrid, hasFields, searchBarHeight]);
449
+ }, [showDataGrid, hasFields, searchBarHeight, rect?.width]);
439
450
 
440
451
  // Pull container
441
452
  const pullContainer =
@@ -70,7 +70,7 @@ export interface CommonPageProps extends Omit<ContainerProps, "id"> {
70
70
  /**
71
71
  * Paddings
72
72
  */
73
- paddings?: Record<string, string | number>;
73
+ paddings?: number | Record<string, string | number>;
74
74
 
75
75
  /**
76
76
  * Scroll container
@@ -135,7 +135,11 @@ export function DataGridPage<
135
135
  const paddingBottom = parseFloat(style.paddingBottom);
136
136
  if (!isNaN(paddingBottom)) gridHeight -= paddingBottom;
137
137
 
138
- if (adjustHeight != null) gridHeight -= adjustHeight(gridHeight, rect);
138
+ if (adjustHeight != null)
139
+ gridHeight -=
140
+ typeof adjustHeight === "number"
141
+ ? adjustHeight
142
+ : adjustHeight(gridHeight, rect);
139
143
 
140
144
  if (gridHeight !== states.height) setStates({ height: gridHeight });
141
145
  }
@@ -15,7 +15,7 @@ export type DataGridPageProps<
15
15
  * @param height Current calcuated height
16
16
  * @param rect Current rect data
17
17
  */
18
- adjustHeight?: (height: number, rect: DOMRect) => number;
18
+ adjustHeight?: number | ((height: number, rect: DOMRect) => number);
19
19
 
20
20
  /**
21
21
  * Grid height
@@ -32,7 +32,7 @@ export function FixedListPage<
32
32
  * @param height Current calcuated height
33
33
  * @param rect Current rect data
34
34
  */
35
- adjustHeight?: (height: number, rect: DOMRect) => number;
35
+ adjustHeight?: number | ((height: number, rect: DOMRect) => number);
36
36
  }
37
37
  ) {
38
38
  // Destruct
@@ -139,7 +139,11 @@ export function FixedListPage<
139
139
  document.documentElement.clientHeight -
140
140
  Math.round(rect.top + rect.height + 1);
141
141
 
142
- if (adjustHeight != null) height -= adjustHeight(height, rect);
142
+ if (adjustHeight != null)
143
+ height -=
144
+ typeof adjustHeight === "number"
145
+ ? adjustHeight
146
+ : adjustHeight(height, rect);
143
147
 
144
148
  return (
145
149
  <Box
@@ -105,7 +105,10 @@ export function ResponsivePage<
105
105
  paddings={paddings}
106
106
  containerBoxSx={(paddings, hasField, _dataGrid) => {
107
107
  // Half
108
- const half = MUGlobal.half(paddings);
108
+ const half =
109
+ typeof paddings == "number"
110
+ ? paddings / 2
111
+ : MUGlobal.half(paddings);
109
112
 
110
113
  // .SearchBox keep the same to avoid flick when switching between DataGrid and List
111
114
  return {