@etsoo/materialui 1.4.43 → 1.4.45
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/ResponsibleContainer.d.ts +4 -4
- package/lib/ResponsibleContainer.js +18 -24
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +8 -8
- package/src/ResponsibleContainer.tsx +25 -29
- package/src/index.ts +1 -0
|
@@ -30,10 +30,6 @@ export type ResponsibleContainerProps<T extends object, F extends DataTypes.Basi
|
|
|
30
30
|
* Container box SX (dataGrid determines the case)
|
|
31
31
|
*/
|
|
32
32
|
containerBoxSx?: (paddings: number | Record<string, string | number>, hasFields: boolean, dataGrid?: boolean) => SxProps<Theme>;
|
|
33
|
-
/**
|
|
34
|
-
* Min width to show Datagrid
|
|
35
|
-
*/
|
|
36
|
-
dataGridMinWidth?: number;
|
|
37
33
|
/**
|
|
38
34
|
* Search fields
|
|
39
35
|
*/
|
|
@@ -90,6 +86,10 @@ export type ResponsibleContainerProps<T extends object, F extends DataTypes.Basi
|
|
|
90
86
|
* SearchBar height
|
|
91
87
|
*/
|
|
92
88
|
searchBarHeight?: number;
|
|
89
|
+
/**
|
|
90
|
+
* SearchBar bottom padding
|
|
91
|
+
*/
|
|
92
|
+
searchBarBottom?: number;
|
|
93
93
|
};
|
|
94
94
|
/**
|
|
95
95
|
* Responsible container
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Stack } from "@mui/material";
|
|
2
|
+
import { Box, Stack, useMediaQuery } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { ReactUtils, useCombinedRefs, useDimensions } from "@etsoo/react";
|
|
5
|
-
import { DataGridEx
|
|
5
|
+
import { DataGridEx } from "./DataGridEx";
|
|
6
6
|
import { MUGlobal } from "./MUGlobal";
|
|
7
7
|
import { PullToRefreshUI } from "./PullToRefreshUI";
|
|
8
8
|
import { ScrollerListEx } from "./ScrollerListEx";
|
|
@@ -24,7 +24,7 @@ function defaultContainerBoxSx(paddings, hasField, _dataGrid) {
|
|
|
24
24
|
*/
|
|
25
25
|
export function ResponsibleContainer(props) {
|
|
26
26
|
// Destruct
|
|
27
|
-
const { adjustHeight, adjustFabHeight, cacheKey, cacheMinutes = 15, columns, containerBoxSx = defaultContainerBoxSx,
|
|
27
|
+
const { adjustHeight, adjustFabHeight, cacheKey, cacheMinutes = 15, columns, containerBoxSx = defaultContainerBoxSx, elementReady, fields, fieldTemplate, height, loadData, mRef, paddings = MUGlobal.pagePaddings, pullToRefresh = true, quickAction, sizeReadyMiliseconds = 0, searchBarHeight = 45.6, searchBarBottom = 8, ...rest } = props;
|
|
28
28
|
// Labels
|
|
29
29
|
const labels = Labels.CommonPage;
|
|
30
30
|
// Refs
|
|
@@ -35,6 +35,8 @@ export function ResponsibleContainer(props) {
|
|
|
35
35
|
return;
|
|
36
36
|
state.ref = ref;
|
|
37
37
|
});
|
|
38
|
+
// Screen size detection
|
|
39
|
+
const showDataGrid = useMediaQuery("(min-width:600px)");
|
|
38
40
|
// Update mounted state
|
|
39
41
|
React.useEffect(() => {
|
|
40
42
|
return () => {
|
|
@@ -114,14 +116,10 @@ export function ResponsibleContainer(props) {
|
|
|
114
116
|
// Rect
|
|
115
117
|
const rect = dimensions[0][2];
|
|
116
118
|
// Create list
|
|
117
|
-
const
|
|
119
|
+
const list = (() => {
|
|
118
120
|
// No layout
|
|
119
121
|
if (rect == null)
|
|
120
122
|
return [null, undefined];
|
|
121
|
-
// Width
|
|
122
|
-
const width = rect.width;
|
|
123
|
-
// Show DataGrid or List dependng on width
|
|
124
|
-
const showDataGrid = width >= dataGridMinWidth;
|
|
125
123
|
// Height
|
|
126
124
|
let heightLocal;
|
|
127
125
|
if (height != null) {
|
|
@@ -134,7 +132,7 @@ export function ResponsibleContainer(props) {
|
|
|
134
132
|
const style = window.getComputedStyle(dimensions[0][1]);
|
|
135
133
|
const boxMargin = parseFloat(style.marginBottom);
|
|
136
134
|
if (!isNaN(boxMargin))
|
|
137
|
-
heightLocal -=
|
|
135
|
+
heightLocal -= boxMargin;
|
|
138
136
|
if (adjustHeight != null)
|
|
139
137
|
heightLocal -=
|
|
140
138
|
typeof adjustHeight === "number"
|
|
@@ -146,13 +144,10 @@ export function ResponsibleContainer(props) {
|
|
|
146
144
|
if (showDataGrid) {
|
|
147
145
|
// Delete
|
|
148
146
|
delete rest.itemRenderer;
|
|
149
|
-
return
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}, onScroll: onGridScroll, columns: columns, onUpdateRows: GridUtils.getUpdateRowsHandler(cacheKey), onInitLoad: onInitLoad, ...rest }) }),
|
|
154
|
-
true
|
|
155
|
-
];
|
|
147
|
+
return (_jsx(Box, { className: "DataGridBox", children: _jsx(DataGridEx, { autoLoad: !hasFields, height: heightLocal, width: rect.width, loadData: localLoadData, mRef: mRefs, onDoubleClick: (_, data) => quickAction && quickAction(data), outerRef: (element) => {
|
|
148
|
+
if (element != null && elementReady)
|
|
149
|
+
elementReady(element, true);
|
|
150
|
+
}, onScroll: onGridScroll, columns: columns, onUpdateRows: GridUtils.getUpdateRowsHandler(cacheKey), onInitLoad: onInitLoad, ...rest }) }));
|
|
156
151
|
}
|
|
157
152
|
// Delete
|
|
158
153
|
delete rest.checkable;
|
|
@@ -163,13 +158,10 @@ export function ResponsibleContainer(props) {
|
|
|
163
158
|
delete rest.hideFooter;
|
|
164
159
|
delete rest.hoverColor;
|
|
165
160
|
delete rest.selectable;
|
|
166
|
-
return
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}, onScroll: onListScroll, ...rest }) }),
|
|
171
|
-
false
|
|
172
|
-
];
|
|
161
|
+
return (_jsx(Box, { className: "ListBox", sx: { height: heightLocal }, children: _jsx(ScrollerListEx, { autoLoad: !hasFields, height: heightLocal, loadData: localLoadData, onUpdateRows: GridUtils.getUpdateRowsHandler(cacheKey), onInitLoad: onInitLoad, mRef: mRefs, onClick: (event, data) => quickAction && ReactUtils.isSafeClick(event) && quickAction(data), oRef: (element) => {
|
|
162
|
+
if (element != null && elementReady)
|
|
163
|
+
elementReady(element, false);
|
|
164
|
+
}, onScroll: onListScroll, ...rest }) }));
|
|
173
165
|
})();
|
|
174
166
|
const searchBar = React.useMemo(() => {
|
|
175
167
|
if (!hasFields ||
|
|
@@ -189,7 +181,9 @@ export function ResponsibleContainer(props) {
|
|
|
189
181
|
// Layout
|
|
190
182
|
return (_jsxs(Box, { sx: containerBoxSx == null
|
|
191
183
|
? undefined
|
|
192
|
-
: containerBoxSx(paddings, hasFields, showDataGrid), children: [_jsxs(Stack, { children: [_jsx(Box, { ref: dimensions[0][0], className: "SearchBox", sx: {
|
|
184
|
+
: containerBoxSx(paddings, hasFields, showDataGrid), children: [_jsxs(Stack, { children: [_jsx(Box, { ref: dimensions[0][0], className: "SearchBox", sx: {
|
|
185
|
+
height: hasFields ? searchBarHeight : 0
|
|
186
|
+
}, marginBottom: hasFields ? `${searchBarBottom}px!important` : undefined, children: searchBar }), list] }), pullToRefresh && pullContainer && (_jsx(PullToRefreshUI, { mainElement: pullContainer, triggerElement: pullContainer, instructionsPullToRefresh: labels.pullToRefresh, instructionsReleaseToRefresh: labels.releaseToRefresh, instructionsRefreshing: labels.refreshing, onRefresh: () => state.ref?.reset(), shouldPullToRefresh: () => {
|
|
193
187
|
const container = document.querySelector(pullContainer);
|
|
194
188
|
return !container?.scrollTop;
|
|
195
189
|
} }))] }));
|
package/lib/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export * from "./FieldSetEx";
|
|
|
58
58
|
export * from "./FileUploadButton";
|
|
59
59
|
export * from "./FlexBox";
|
|
60
60
|
export * from "./GridDataFormat";
|
|
61
|
+
export * from "./GridUtils";
|
|
61
62
|
export * from "./HiSelector";
|
|
62
63
|
export * from "./HiSelectorTL";
|
|
63
64
|
export * from "./IconButtonLink";
|
package/lib/index.js
CHANGED
|
@@ -58,6 +58,7 @@ export * from "./FieldSetEx";
|
|
|
58
58
|
export * from "./FileUploadButton";
|
|
59
59
|
export * from "./FlexBox";
|
|
60
60
|
export * from "./GridDataFormat";
|
|
61
|
+
export * from "./GridUtils";
|
|
61
62
|
export * from "./HiSelector";
|
|
62
63
|
export * from "./HiSelectorTL";
|
|
63
64
|
export * from "./IconButtonLink";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.45",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/ETSOO/ReactMU#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@dnd-kit/core": "^6.
|
|
34
|
-
"@dnd-kit/sortable": "^
|
|
33
|
+
"@dnd-kit/core": "^6.3.0",
|
|
34
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
35
35
|
"@emotion/css": "^11.13.5",
|
|
36
36
|
"@emotion/react": "^11.13.5",
|
|
37
37
|
"@emotion/styled": "^11.13.5",
|
|
38
38
|
"@etsoo/appscript": "^1.5.78",
|
|
39
39
|
"@etsoo/notificationbase": "^1.1.54",
|
|
40
|
-
"@etsoo/react": "^1.8.
|
|
40
|
+
"@etsoo/react": "^1.8.9",
|
|
41
41
|
"@etsoo/shared": "^1.2.55",
|
|
42
|
-
"@mui/icons-material": "^6.1.
|
|
43
|
-
"@mui/material": "^6.1.
|
|
42
|
+
"@mui/icons-material": "^6.1.10",
|
|
43
|
+
"@mui/material": "^6.1.10",
|
|
44
44
|
"@mui/x-data-grid": "^7.23.0",
|
|
45
45
|
"chart.js": "^4.4.7",
|
|
46
46
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
"@babel/core": "^7.26.0",
|
|
60
60
|
"@babel/plugin-transform-runtime": "^7.25.9",
|
|
61
61
|
"@babel/preset-env": "^7.26.0",
|
|
62
|
-
"@babel/preset-react": "^7.
|
|
62
|
+
"@babel/preset-react": "^7.26.3",
|
|
63
63
|
"@babel/preset-typescript": "^7.26.0",
|
|
64
64
|
"@babel/runtime-corejs3": "^7.26.0",
|
|
65
65
|
"@testing-library/react": "^16.0.1",
|
|
66
66
|
"@types/pica": "^9.0.4",
|
|
67
67
|
"@types/pulltorefreshjs": "^0.1.7",
|
|
68
|
-
"@types/react": "^18.3.
|
|
68
|
+
"@types/react": "^18.3.13",
|
|
69
69
|
"@types/react-avatar-editor": "^13.0.3",
|
|
70
70
|
"@types/react-dom": "^18.3.1",
|
|
71
71
|
"@types/react-input-mask": "^3.0.6",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataTypes } from "@etsoo/shared";
|
|
2
|
-
import { Box, Stack, SxProps, Theme } from "@mui/material";
|
|
2
|
+
import { Box, Stack, SxProps, Theme, useMediaQuery } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import {
|
|
5
5
|
GridOnScrollProps,
|
|
@@ -18,11 +18,7 @@ import {
|
|
|
18
18
|
useCombinedRefs,
|
|
19
19
|
useDimensions
|
|
20
20
|
} from "@etsoo/react";
|
|
21
|
-
import {
|
|
22
|
-
DataGridEx,
|
|
23
|
-
DataGridExCalColumns,
|
|
24
|
-
DataGridExProps
|
|
25
|
-
} from "./DataGridEx";
|
|
21
|
+
import { DataGridEx, DataGridExProps } from "./DataGridEx";
|
|
26
22
|
import { MUGlobal } from "./MUGlobal";
|
|
27
23
|
import { PullToRefreshUI } from "./PullToRefreshUI";
|
|
28
24
|
import {
|
|
@@ -80,11 +76,6 @@ export type ResponsibleContainerProps<
|
|
|
80
76
|
dataGrid?: boolean
|
|
81
77
|
) => SxProps<Theme>;
|
|
82
78
|
|
|
83
|
-
/**
|
|
84
|
-
* Min width to show Datagrid
|
|
85
|
-
*/
|
|
86
|
-
dataGridMinWidth?: number;
|
|
87
|
-
|
|
88
79
|
/**
|
|
89
80
|
* Search fields
|
|
90
81
|
*/
|
|
@@ -161,6 +152,11 @@ export type ResponsibleContainerProps<
|
|
|
161
152
|
* SearchBar height
|
|
162
153
|
*/
|
|
163
154
|
searchBarHeight?: number;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* SearchBar bottom padding
|
|
158
|
+
*/
|
|
159
|
+
searchBarBottom?: number;
|
|
164
160
|
};
|
|
165
161
|
|
|
166
162
|
interface LocalRefs<T> {
|
|
@@ -201,7 +197,6 @@ export function ResponsibleContainer<
|
|
|
201
197
|
cacheMinutes = 15,
|
|
202
198
|
columns,
|
|
203
199
|
containerBoxSx = defaultContainerBoxSx,
|
|
204
|
-
dataGridMinWidth = Math.max(576, DataGridExCalColumns(columns).total),
|
|
205
200
|
elementReady,
|
|
206
201
|
fields,
|
|
207
202
|
fieldTemplate,
|
|
@@ -213,6 +208,7 @@ export function ResponsibleContainer<
|
|
|
213
208
|
quickAction,
|
|
214
209
|
sizeReadyMiliseconds = 0,
|
|
215
210
|
searchBarHeight = 45.6,
|
|
211
|
+
searchBarBottom = 8,
|
|
216
212
|
...rest
|
|
217
213
|
} = props;
|
|
218
214
|
|
|
@@ -228,6 +224,9 @@ export function ResponsibleContainer<
|
|
|
228
224
|
state.ref = ref;
|
|
229
225
|
});
|
|
230
226
|
|
|
227
|
+
// Screen size detection
|
|
228
|
+
const showDataGrid = useMediaQuery("(min-width:600px)");
|
|
229
|
+
|
|
231
230
|
// Update mounted state
|
|
232
231
|
React.useEffect(() => {
|
|
233
232
|
return () => {
|
|
@@ -339,16 +338,10 @@ export function ResponsibleContainer<
|
|
|
339
338
|
const rect = dimensions[0][2];
|
|
340
339
|
|
|
341
340
|
// Create list
|
|
342
|
-
const
|
|
341
|
+
const list = (() => {
|
|
343
342
|
// No layout
|
|
344
343
|
if (rect == null) return [null, undefined];
|
|
345
344
|
|
|
346
|
-
// Width
|
|
347
|
-
const width = rect.width;
|
|
348
|
-
|
|
349
|
-
// Show DataGrid or List dependng on width
|
|
350
|
-
const showDataGrid = width >= dataGridMinWidth;
|
|
351
|
-
|
|
352
345
|
// Height
|
|
353
346
|
let heightLocal: number;
|
|
354
347
|
if (height != null) {
|
|
@@ -360,7 +353,7 @@ export function ResponsibleContainer<
|
|
|
360
353
|
|
|
361
354
|
const style = window.getComputedStyle(dimensions[0][1]!);
|
|
362
355
|
const boxMargin = parseFloat(style.marginBottom);
|
|
363
|
-
if (!isNaN(boxMargin)) heightLocal -=
|
|
356
|
+
if (!isNaN(boxMargin)) heightLocal -= boxMargin;
|
|
364
357
|
|
|
365
358
|
if (adjustHeight != null)
|
|
366
359
|
heightLocal -=
|
|
@@ -376,7 +369,7 @@ export function ResponsibleContainer<
|
|
|
376
369
|
// Delete
|
|
377
370
|
delete rest.itemRenderer;
|
|
378
371
|
|
|
379
|
-
return
|
|
372
|
+
return (
|
|
380
373
|
<Box className="DataGridBox">
|
|
381
374
|
<DataGridEx<T>
|
|
382
375
|
autoLoad={!hasFields}
|
|
@@ -394,9 +387,8 @@ export function ResponsibleContainer<
|
|
|
394
387
|
onInitLoad={onInitLoad}
|
|
395
388
|
{...rest}
|
|
396
389
|
/>
|
|
397
|
-
</Box
|
|
398
|
-
|
|
399
|
-
];
|
|
390
|
+
</Box>
|
|
391
|
+
);
|
|
400
392
|
}
|
|
401
393
|
|
|
402
394
|
// Delete
|
|
@@ -409,7 +401,7 @@ export function ResponsibleContainer<
|
|
|
409
401
|
delete rest.hoverColor;
|
|
410
402
|
delete rest.selectable;
|
|
411
403
|
|
|
412
|
-
return
|
|
404
|
+
return (
|
|
413
405
|
<Box className="ListBox" sx={{ height: heightLocal }}>
|
|
414
406
|
<ScrollerListEx<T>
|
|
415
407
|
autoLoad={!hasFields}
|
|
@@ -427,9 +419,8 @@ export function ResponsibleContainer<
|
|
|
427
419
|
onScroll={onListScroll}
|
|
428
420
|
{...rest}
|
|
429
421
|
/>
|
|
430
|
-
</Box
|
|
431
|
-
|
|
432
|
-
];
|
|
422
|
+
</Box>
|
|
423
|
+
);
|
|
433
424
|
})();
|
|
434
425
|
|
|
435
426
|
const searchBar = React.useMemo(() => {
|
|
@@ -473,7 +464,12 @@ export function ResponsibleContainer<
|
|
|
473
464
|
<Box
|
|
474
465
|
ref={dimensions[0][0]}
|
|
475
466
|
className="SearchBox"
|
|
476
|
-
sx={{
|
|
467
|
+
sx={{
|
|
468
|
+
height: hasFields ? searchBarHeight : 0
|
|
469
|
+
}}
|
|
470
|
+
marginBottom={
|
|
471
|
+
hasFields ? `${searchBarBottom}px!important` : undefined
|
|
472
|
+
}
|
|
477
473
|
>
|
|
478
474
|
{searchBar}
|
|
479
475
|
</Box>
|
package/src/index.ts
CHANGED
|
@@ -63,6 +63,7 @@ export * from "./FieldSetEx";
|
|
|
63
63
|
export * from "./FileUploadButton";
|
|
64
64
|
export * from "./FlexBox";
|
|
65
65
|
export * from "./GridDataFormat";
|
|
66
|
+
export * from "./GridUtils";
|
|
66
67
|
export * from "./HiSelector";
|
|
67
68
|
export * from "./HiSelectorTL";
|
|
68
69
|
export * from "./IconButtonLink";
|