@etsoo/react 1.4.21 → 1.4.25
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/components/ScrollerGrid.js +2 -0
- package/lib/components/ScrollerList.js +2 -0
- package/lib/mu/DataGridEx.js +2 -2
- package/lib/mu/DataGridRenderers.d.ts +4 -2
- package/lib/mu/DataGridRenderers.js +14 -10
- package/lib/mu/ResponsibleContainer.d.ts +5 -1
- package/lib/mu/ResponsibleContainer.js +42 -23
- package/lib/mu/SearchBar.js +29 -27
- package/lib/mu/pages/CommonPage.d.ts +1 -6
- package/lib/mu/pages/CommonPage.js +2 -11
- package/lib/mu/pages/CommonPageProps.d.ts +0 -4
- package/lib/mu/pages/DataGridPage.js +2 -6
- package/lib/mu/pages/FixedListPage.js +1 -5
- package/lib/mu/pages/ListPage.js +2 -2
- package/lib/mu/pages/ResponsivePage.js +19 -118
- package/lib/mu/pages/ResponsivePageProps.d.ts +4 -0
- package/lib/mu/pages/TablePage.js +2 -2
- package/package.json +9 -9
- package/src/components/ScrollerGrid.tsx +3 -0
- package/src/components/ScrollerList.tsx +3 -0
- package/src/mu/DataGridEx.tsx +2 -2
- package/src/mu/DataGridRenderers.tsx +14 -11
- package/src/mu/ResponsibleContainer.tsx +64 -25
- package/src/mu/SearchBar.tsx +26 -24
- package/src/mu/pages/CommonPage.tsx +0 -21
- package/src/mu/pages/CommonPageProps.ts +0 -5
- package/src/mu/pages/DataGridPage.tsx +1 -10
- package/src/mu/pages/FixedListPage.tsx +0 -6
- package/src/mu/pages/ListPage.tsx +2 -10
- package/src/mu/pages/ResponsivePage.tsx +21 -195
- package/src/mu/pages/ResponsivePageProps.ts +5 -0
- package/src/mu/pages/TablePage.tsx +2 -10
package/lib/mu/DataGridEx.js
CHANGED
|
@@ -86,7 +86,7 @@ export function DataGridEx(props) {
|
|
|
86
86
|
sortLabel = headerCellRenderer({
|
|
87
87
|
cellProps,
|
|
88
88
|
column,
|
|
89
|
-
columnIndex: index,
|
|
89
|
+
columnIndex: checkable ? index - 1 : index,
|
|
90
90
|
states
|
|
91
91
|
});
|
|
92
92
|
}
|
|
@@ -115,7 +115,7 @@ export function DataGridEx(props) {
|
|
|
115
115
|
const cell = footerItemRenderer
|
|
116
116
|
? footerItemRenderer(rows, {
|
|
117
117
|
column,
|
|
118
|
-
index,
|
|
118
|
+
index: checkable ? index - 1 : index,
|
|
119
119
|
states,
|
|
120
120
|
cellProps,
|
|
121
121
|
checkable
|
|
@@ -13,8 +13,10 @@ export declare namespace DataGridRenderers {
|
|
|
13
13
|
function defaultCellRenderer<T extends Record<string, any>>({ cellProps, data, field, formattedValue, columnIndex, type, renderProps }: GridCellRendererProps<T>): React.ReactNode;
|
|
14
14
|
/**
|
|
15
15
|
* Default footer item renderer
|
|
16
|
-
* @param
|
|
16
|
+
* @param rows Rows
|
|
17
|
+
* @param props Renderer props
|
|
18
|
+
* @param location Renderer location (column index)
|
|
17
19
|
* @returns Component
|
|
18
20
|
*/
|
|
19
|
-
function defaultFooterItemRenderer<T>(_rows: T[], { index, states, checkable }: DataGridExFooterItemRendererProps<T
|
|
21
|
+
function defaultFooterItemRenderer<T>(_rows: T[], { index, states, checkable }: DataGridExFooterItemRendererProps<T>, location?: number): string | undefined;
|
|
20
22
|
}
|
|
@@ -75,19 +75,23 @@ export var DataGridRenderers;
|
|
|
75
75
|
DataGridRenderers.defaultCellRenderer = defaultCellRenderer;
|
|
76
76
|
/**
|
|
77
77
|
* Default footer item renderer
|
|
78
|
-
* @param
|
|
78
|
+
* @param rows Rows
|
|
79
|
+
* @param props Renderer props
|
|
80
|
+
* @param location Renderer location (column index)
|
|
79
81
|
* @returns Component
|
|
80
82
|
*/
|
|
81
|
-
function defaultFooterItemRenderer(_rows, { index, states, checkable }) {
|
|
83
|
+
function defaultFooterItemRenderer(_rows, { index, states, checkable }, location = 0) {
|
|
82
84
|
const { selectedItems, loadedItems, hasNextPage } = states;
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
if (index === location) {
|
|
86
|
+
if (checkable) {
|
|
87
|
+
return [
|
|
88
|
+
selectedItems.length,
|
|
89
|
+
loadedItems.toLocaleString() + (hasNextPage ? '+' : '')
|
|
90
|
+
].join(' / ');
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return loadedItems.toLocaleString() + (hasNextPage ? '+' : '');
|
|
94
|
+
}
|
|
91
95
|
}
|
|
92
96
|
return undefined;
|
|
93
97
|
}
|
|
@@ -51,7 +51,7 @@ export interface ResponsibleContainerProps<T extends {}, F extends DataTypes.Bas
|
|
|
51
51
|
/**
|
|
52
52
|
* Listbox SX (dataGrid determines the case)
|
|
53
53
|
*/
|
|
54
|
-
listBoxSx?: (dataGrid: boolean) => SxProps<Theme>;
|
|
54
|
+
listBoxSx?: (dataGrid: boolean, height: number) => SxProps<Theme>;
|
|
55
55
|
/**
|
|
56
56
|
* Load data callback
|
|
57
57
|
*/
|
|
@@ -60,6 +60,10 @@ export interface ResponsibleContainerProps<T extends {}, F extends DataTypes.Bas
|
|
|
60
60
|
* Methods
|
|
61
61
|
*/
|
|
62
62
|
mRef?: React.MutableRefObject<GridMethodRef | undefined>;
|
|
63
|
+
/**
|
|
64
|
+
* Paddings
|
|
65
|
+
*/
|
|
66
|
+
paddings?: {};
|
|
63
67
|
/**
|
|
64
68
|
* Pull to refresh data
|
|
65
69
|
*/
|
|
@@ -5,9 +5,19 @@ import { GridDataGet } from '../components/GridLoader';
|
|
|
5
5
|
import useCombinedRefs from '../uses/useCombinedRefs';
|
|
6
6
|
import { useDimensions } from '../uses/useDimensions';
|
|
7
7
|
import { DataGridEx, DataGridExCalColumns } from './DataGridEx';
|
|
8
|
+
import { MUGlobal } from './MUGlobal';
|
|
8
9
|
import { PullToRefreshUI } from './PullToRefreshUI';
|
|
9
10
|
import { ScrollerListEx } from './ScrollerListEx';
|
|
10
11
|
import { SearchBar } from './SearchBar';
|
|
12
|
+
function getDefaultSearchBoxSx(paddings) {
|
|
13
|
+
const half = MUGlobal.half(paddings);
|
|
14
|
+
return {
|
|
15
|
+
paddingLeft: half,
|
|
16
|
+
paddingRight: half,
|
|
17
|
+
paddingTop: half,
|
|
18
|
+
marginBottom: half
|
|
19
|
+
};
|
|
20
|
+
}
|
|
11
21
|
/**
|
|
12
22
|
* Responsible container
|
|
13
23
|
* @param props Props
|
|
@@ -15,35 +25,36 @@ import { SearchBar } from './SearchBar';
|
|
|
15
25
|
*/
|
|
16
26
|
export function ResponsibleContainer(props) {
|
|
17
27
|
// Destruct
|
|
18
|
-
const { adjustHeight, columns, dataGridMinWidth = DataGridExCalColumns(columns).total, fields, fieldTemplate, height, listBoxSx, loadData, mRef, pullToRefresh = true, searchBoxSx, sizeReadyMiliseconds = 0, ...rest } = props;
|
|
28
|
+
const { adjustHeight, columns, dataGridMinWidth = DataGridExCalColumns(columns).total, fields, fieldTemplate, height, listBoxSx, loadData, mRef, paddings = MUGlobal.pagePaddings, pullToRefresh = true, searchBoxSx = getDefaultSearchBoxSx(paddings), sizeReadyMiliseconds = 0, ...rest } = props;
|
|
19
29
|
// Labels
|
|
20
30
|
const labels = Labels.CommonPage;
|
|
21
31
|
// Refs
|
|
22
32
|
const refs = React.useRef({});
|
|
33
|
+
const state = refs.current;
|
|
23
34
|
const mRefs = useCombinedRefs(mRef, (ref) => {
|
|
24
35
|
if (ref == null)
|
|
25
36
|
return;
|
|
26
|
-
|
|
37
|
+
state.ref = ref;
|
|
27
38
|
});
|
|
28
39
|
// Update mounted state
|
|
29
40
|
React.useEffect(() => {
|
|
30
41
|
return () => {
|
|
31
|
-
|
|
42
|
+
state.mounted = false;
|
|
32
43
|
};
|
|
33
44
|
}, []);
|
|
34
45
|
// Has fields
|
|
35
46
|
const hasFields = fields != null && fields.length > 0;
|
|
36
47
|
// Load data
|
|
37
48
|
const localLoadData = (props) => {
|
|
38
|
-
|
|
49
|
+
state.mounted = true;
|
|
39
50
|
const data = GridDataGet(props, fieldTemplate);
|
|
40
51
|
return loadData(data);
|
|
41
52
|
};
|
|
42
53
|
// On submit callback
|
|
43
54
|
const onSubmit = (data, _reset) => {
|
|
44
|
-
if (data == null ||
|
|
55
|
+
if (data == null || state.ref == null)
|
|
45
56
|
return;
|
|
46
|
-
|
|
57
|
+
state.ref.reset({ data });
|
|
47
58
|
};
|
|
48
59
|
// Watch container
|
|
49
60
|
const { dimensions } = useDimensions(1, undefined, sizeReadyMiliseconds, (_preRect, rect) => {
|
|
@@ -51,15 +62,15 @@ export function ResponsibleContainer(props) {
|
|
|
51
62
|
if (rect == null)
|
|
52
63
|
return true;
|
|
53
64
|
// Last rect
|
|
54
|
-
const lastRect =
|
|
65
|
+
const lastRect = state.rect;
|
|
55
66
|
// 32 = scroll bar width
|
|
56
67
|
if (lastRect != null &&
|
|
57
|
-
|
|
68
|
+
state.mounted !== true &&
|
|
58
69
|
Math.abs(rect.width - lastRect.width) <= 32 &&
|
|
59
70
|
Math.abs(rect.height - lastRect.height) <= 32)
|
|
60
71
|
return true;
|
|
61
72
|
// Hold the new rect
|
|
62
|
-
|
|
73
|
+
state.rect = rect;
|
|
63
74
|
return false;
|
|
64
75
|
});
|
|
65
76
|
// Rect
|
|
@@ -68,7 +79,7 @@ export function ResponsibleContainer(props) {
|
|
|
68
79
|
const [list, showDataGrid] = (() => {
|
|
69
80
|
// No layout
|
|
70
81
|
if (rect == null)
|
|
71
|
-
return [null,
|
|
82
|
+
return [null, undefined];
|
|
72
83
|
// Width
|
|
73
84
|
const width = rect.width;
|
|
74
85
|
// Show DataGrid or List dependng on width
|
|
@@ -80,12 +91,11 @@ export function ResponsibleContainer(props) {
|
|
|
80
91
|
}
|
|
81
92
|
else {
|
|
82
93
|
// Auto calculation
|
|
83
|
-
heightLocal =
|
|
84
|
-
window.innerHeight - Math.round(rect.top + rect.height + 1);
|
|
94
|
+
heightLocal = window.innerHeight - Math.round(rect.bottom + 1);
|
|
85
95
|
const style = window.getComputedStyle(dimensions[0][1]);
|
|
86
|
-
const
|
|
87
|
-
if (!isNaN(
|
|
88
|
-
heightLocal -=
|
|
96
|
+
const boxMargin = parseFloat(style.marginBottom);
|
|
97
|
+
if (!isNaN(boxMargin))
|
|
98
|
+
heightLocal -= 3 * boxMargin; // 1 - Box, 2 - Page bottom
|
|
89
99
|
if (adjustHeight != null) {
|
|
90
100
|
heightLocal -= adjustHeight(heightLocal);
|
|
91
101
|
}
|
|
@@ -94,7 +104,9 @@ export function ResponsibleContainer(props) {
|
|
|
94
104
|
// Delete
|
|
95
105
|
delete rest.itemRenderer;
|
|
96
106
|
return [
|
|
97
|
-
React.createElement(Box, { sx: listBoxSx == null
|
|
107
|
+
React.createElement(Box, { sx: listBoxSx == null
|
|
108
|
+
? undefined
|
|
109
|
+
: listBoxSx(true, heightLocal) },
|
|
98
110
|
React.createElement(DataGridEx, { autoLoad: !hasFields, height: heightLocal, width: rect.width, loadData: localLoadData, mRef: mRefs, columns: columns, ...rest })),
|
|
99
111
|
true
|
|
100
112
|
];
|
|
@@ -109,23 +121,30 @@ export function ResponsibleContainer(props) {
|
|
|
109
121
|
delete rest.hoverColor;
|
|
110
122
|
delete rest.selectable;
|
|
111
123
|
return [
|
|
112
|
-
React.createElement(Box, { sx: listBoxSx == null
|
|
124
|
+
React.createElement(Box, { sx: listBoxSx == null
|
|
125
|
+
? undefined
|
|
126
|
+
: listBoxSx(false, heightLocal) },
|
|
113
127
|
React.createElement(ScrollerListEx, { autoLoad: !hasFields, width: rect.width, height: heightLocal, loadData: localLoadData, mRef: mRefs, ...rest })),
|
|
114
128
|
false
|
|
115
129
|
];
|
|
116
130
|
})();
|
|
131
|
+
const searchBar = React.useMemo(() => {
|
|
132
|
+
if (!hasFields || showDataGrid == null)
|
|
133
|
+
return;
|
|
134
|
+
return (React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit, className: `searchBar${showDataGrid ? 'Grid' : 'List'}` }));
|
|
135
|
+
}, [showDataGrid, hasFields]);
|
|
117
136
|
// Pull container
|
|
118
|
-
const pullContainer =
|
|
119
|
-
?
|
|
137
|
+
const pullContainer = showDataGrid == null
|
|
138
|
+
? undefined
|
|
139
|
+
: showDataGrid
|
|
120
140
|
? '.DataGridEx-Body'
|
|
121
|
-
: '.ScrollerListEx-Body'
|
|
122
|
-
: undefined;
|
|
141
|
+
: '.ScrollerListEx-Body';
|
|
123
142
|
// Layout
|
|
124
143
|
return (React.createElement(React.Fragment, null,
|
|
125
144
|
React.createElement(Stack, null,
|
|
126
|
-
React.createElement(Box, { ref: dimensions[0][0], sx: searchBoxSx },
|
|
145
|
+
React.createElement(Box, { ref: dimensions[0][0], sx: searchBoxSx }, searchBar),
|
|
127
146
|
list),
|
|
128
|
-
pullToRefresh && pullContainer && (React.createElement(PullToRefreshUI, { mainElement: pullContainer, triggerElement: pullContainer, instructionsPullToRefresh: labels.pullToRefresh, instructionsReleaseToRefresh: labels.releaseToRefresh, instructionsRefreshing: labels.refreshing, onRefresh: () => { var _a; return (_a =
|
|
147
|
+
pullToRefresh && pullContainer && (React.createElement(PullToRefreshUI, { mainElement: pullContainer, triggerElement: pullContainer, instructionsPullToRefresh: labels.pullToRefresh, instructionsReleaseToRefresh: labels.releaseToRefresh, instructionsRefreshing: labels.refreshing, onRefresh: () => { var _a; return (_a = state.ref) === null || _a === void 0 ? void 0 : _a.reset(); }, shouldPullToRefresh: () => {
|
|
129
148
|
const container = document.querySelector(pullContainer);
|
|
130
149
|
return !(container === null || container === void 0 ? void 0 : container.scrollTop);
|
|
131
150
|
} }))));
|
package/lib/mu/SearchBar.js
CHANGED
|
@@ -63,12 +63,12 @@ export function SearchBar(props) {
|
|
|
63
63
|
const [index, updateIndex] = React.useState();
|
|
64
64
|
// Drawer open / close
|
|
65
65
|
const [open, updateOpen] = React.useState(false);
|
|
66
|
-
//
|
|
67
|
-
const
|
|
66
|
+
// State
|
|
67
|
+
const state = React.useRef({}).current;
|
|
68
68
|
// Watch container
|
|
69
69
|
const { dimensions } = useDimensions(1, (target, rect) => {
|
|
70
70
|
// Same logic from resetButtonRef
|
|
71
|
-
if (rect.width ===
|
|
71
|
+
if (rect.width === state.lastMaxWidth)
|
|
72
72
|
return false;
|
|
73
73
|
// Len
|
|
74
74
|
const len = target.children.length;
|
|
@@ -96,10 +96,10 @@ export function SearchBar(props) {
|
|
|
96
96
|
return;
|
|
97
97
|
// Container width
|
|
98
98
|
let maxWidth = containerRect.width;
|
|
99
|
-
if (maxWidth ===
|
|
99
|
+
if (maxWidth === state.lastMaxWidth) {
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
state.lastMaxWidth = maxWidth;
|
|
103
103
|
// More button
|
|
104
104
|
const buttonMore = resetButton.previousElementSibling;
|
|
105
105
|
// Cached button width
|
|
@@ -174,8 +174,8 @@ export function SearchBar(props) {
|
|
|
174
174
|
const handleForm = (event) => {
|
|
175
175
|
if (event.nativeEvent.cancelable && !event.nativeEvent.composed)
|
|
176
176
|
return;
|
|
177
|
-
if (
|
|
178
|
-
|
|
177
|
+
if (state.form == null)
|
|
178
|
+
state.form = event.currentTarget;
|
|
179
179
|
handleSubmit();
|
|
180
180
|
};
|
|
181
181
|
// Handle more button click
|
|
@@ -186,54 +186,56 @@ export function SearchBar(props) {
|
|
|
186
186
|
const moreFormChange = (event) => {
|
|
187
187
|
if (event.nativeEvent.cancelable && !event.nativeEvent.composed)
|
|
188
188
|
return;
|
|
189
|
-
if (
|
|
190
|
-
|
|
189
|
+
if (state.moreForm == null)
|
|
190
|
+
state.moreForm = event.currentTarget;
|
|
191
191
|
handleSubmit();
|
|
192
192
|
};
|
|
193
193
|
// Reset
|
|
194
194
|
const handleReset = () => {
|
|
195
195
|
// Clear form values
|
|
196
|
-
if (
|
|
197
|
-
resetForm(
|
|
198
|
-
if (
|
|
199
|
-
resetForm(
|
|
196
|
+
if (state.form != null)
|
|
197
|
+
resetForm(state.form);
|
|
198
|
+
if (state.moreForm != null)
|
|
199
|
+
resetForm(state.moreForm);
|
|
200
200
|
// Resubmit
|
|
201
201
|
handleSubmitInstant(true);
|
|
202
202
|
};
|
|
203
203
|
// Submit
|
|
204
|
-
const handleSubmit = () => {
|
|
205
|
-
if (
|
|
206
|
-
clearTimeout(
|
|
204
|
+
const handleSubmit = (delay = 480) => {
|
|
205
|
+
if (state.submitSeed != null) {
|
|
206
|
+
clearTimeout(state.submitSeed);
|
|
207
207
|
}
|
|
208
208
|
// Delay the change
|
|
209
|
-
|
|
209
|
+
state.submitSeed = window.setTimeout(handleSubmitInstant, delay);
|
|
210
210
|
};
|
|
211
211
|
// Submit at once
|
|
212
212
|
const handleSubmitInstant = (reset = false) => {
|
|
213
213
|
// Reset timeout
|
|
214
|
-
|
|
214
|
+
state.submitSeed = undefined;
|
|
215
215
|
// Prepare data
|
|
216
|
-
const data = new FormData(
|
|
217
|
-
if (
|
|
218
|
-
DomUtils.mergeFormData(data, new FormData(
|
|
216
|
+
const data = new FormData(state.form);
|
|
217
|
+
if (state.moreForm != null) {
|
|
218
|
+
DomUtils.mergeFormData(data, new FormData(state.moreForm));
|
|
219
219
|
}
|
|
220
220
|
onSubmit(data, reset);
|
|
221
221
|
};
|
|
222
222
|
// First loading
|
|
223
223
|
React.useEffect(() => {
|
|
224
|
-
// Delayed way
|
|
225
|
-
handleSubmit();
|
|
226
224
|
return () => {
|
|
227
225
|
// Clear the seeds
|
|
228
|
-
if (
|
|
229
|
-
clearTimeout(
|
|
226
|
+
if (state.submitSeed != null)
|
|
227
|
+
clearTimeout(state.submitSeed);
|
|
230
228
|
};
|
|
231
229
|
}, []);
|
|
230
|
+
React.useEffect(() => {
|
|
231
|
+
// Delayed way
|
|
232
|
+
handleSubmit(100);
|
|
233
|
+
}, [className]);
|
|
232
234
|
// Layout
|
|
233
235
|
return (React.createElement(React.Fragment, null,
|
|
234
236
|
React.createElement("form", { id: "SearchBarForm", className: className, onChange: handleForm, ref: (form) => {
|
|
235
237
|
if (form)
|
|
236
|
-
|
|
238
|
+
state.form = form;
|
|
237
239
|
} },
|
|
238
240
|
React.createElement(Stack, { ref: dimensions[0][0], justifyContent: "center", alignItems: "center", direction: "row", spacing: 1, height: innerHeight, sx: {
|
|
239
241
|
'& > :not(style)': {
|
|
@@ -260,7 +262,7 @@ export function SearchBar(props) {
|
|
|
260
262
|
}, open: open, onClose: () => updateOpen(false) },
|
|
261
263
|
React.createElement("form", { onChange: moreFormChange, ref: (form) => {
|
|
262
264
|
if (form)
|
|
263
|
-
|
|
265
|
+
state.moreForm = form;
|
|
264
266
|
} },
|
|
265
267
|
React.createElement(Stack, { direction: "column", alignItems: "stretch", spacing: 2, padding: 2 }, moreItems))))));
|
|
266
268
|
}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
/// <reference types="react" />
|
|
3
2
|
import { CommonPageProps } from './CommonPageProps';
|
|
4
|
-
/**
|
|
5
|
-
* Default pull container
|
|
6
|
-
*/
|
|
7
|
-
export declare const CommonPagePullContainer = "#page-container";
|
|
8
3
|
/**
|
|
9
4
|
* Default scroll container
|
|
10
5
|
*/
|
|
11
|
-
export declare const CommonPageScrollContainer:
|
|
6
|
+
export declare const CommonPageScrollContainer: typeof globalThis;
|
|
12
7
|
/**
|
|
13
8
|
* Common page
|
|
14
9
|
* @param props Props
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FabBox } from '../FabBox';
|
|
3
3
|
import { ScrollTopFab } from '../ScrollTopFab';
|
|
4
|
-
import { PullToRefreshUI } from '../PullToRefreshUI';
|
|
5
4
|
import { Labels } from '../../app/Labels';
|
|
6
5
|
import { MUGlobal } from '../MUGlobal';
|
|
7
6
|
import { MoreFab } from '../MoreFab';
|
|
8
7
|
import { ReactAppStateDetector } from '../../app/ReactApp';
|
|
9
8
|
import { Container, Fab } from '@mui/material';
|
|
10
9
|
import RefreshIcon from '@mui/icons-material/Refresh';
|
|
11
|
-
/**
|
|
12
|
-
* Default pull container
|
|
13
|
-
*/
|
|
14
|
-
export const CommonPagePullContainer = '#page-container';
|
|
15
10
|
/**
|
|
16
11
|
* Default scroll container
|
|
17
12
|
*/
|
|
@@ -22,7 +17,7 @@ export const CommonPageScrollContainer = global;
|
|
|
22
17
|
*/
|
|
23
18
|
export function CommonPage(props) {
|
|
24
19
|
// Destruct
|
|
25
|
-
const { children, disableGutters = true, fabButtons, fabColumnDirection, fabPaddingAdjust = 1.5, fabSize = 'small', maxWidth = false, moreActions, onRefresh, onUpdate, onUpdateAll, paddings = MUGlobal.pagePaddings, scrollContainer, targetFields,
|
|
20
|
+
const { children, disableGutters = true, fabButtons, fabColumnDirection, fabPaddingAdjust = 1.5, fabSize = 'small', maxWidth = false, moreActions, onRefresh, onUpdate, onUpdateAll, paddings = MUGlobal.pagePaddings, scrollContainer, targetFields, sx = {}, ...rest } = props;
|
|
26
21
|
// Merge style
|
|
27
22
|
Object.assign(sx, {
|
|
28
23
|
padding: paddings
|
|
@@ -59,9 +54,5 @@ export function CommonPage(props) {
|
|
|
59
54
|
onRefresh != null && (React.createElement(Fab, { title: labels.refresh, size: fabSize, onClick: onRefresh, sx: { display: { xs: 'none', md: 'inherit' } } },
|
|
60
55
|
React.createElement(RefreshIcon, null))),
|
|
61
56
|
React.createElement(MoreFab, { size: fabSize, title: labels.more, actions: moreActions })),
|
|
62
|
-
children)
|
|
63
|
-
onRefresh != null && pullContainer != null && (React.createElement(PullToRefreshUI, { mainElement: pullContainer, triggerElement: pullContainer, instructionsPullToRefresh: labels.pullToRefresh, instructionsReleaseToRefresh: labels.releaseToRefresh, instructionsRefreshing: labels.refreshing, onRefresh: onRefresh, shouldPullToRefresh: () => {
|
|
64
|
-
const container = document.querySelector(pullContainer);
|
|
65
|
-
return !(container === null || container === void 0 ? void 0 : container.scrollTop);
|
|
66
|
-
} }))));
|
|
57
|
+
children)));
|
|
67
58
|
}
|
|
@@ -13,7 +13,7 @@ import { CommonPage } from './CommonPage';
|
|
|
13
13
|
* @returns Component
|
|
14
14
|
*/
|
|
15
15
|
export function DataGridPage(props) {
|
|
16
|
-
var _a
|
|
16
|
+
var _a;
|
|
17
17
|
// Destruct
|
|
18
18
|
const { adjustHeight, fields, fieldTemplate, height, loadData, mRef, sizeReadyMiliseconds = 100, pageProps = {}, ...rest } = props;
|
|
19
19
|
(_a = pageProps.paddings) !== null && _a !== void 0 ? _a : (pageProps.paddings = MUGlobal.pagePaddings);
|
|
@@ -69,12 +69,8 @@ export function DataGridPage(props) {
|
|
|
69
69
|
return;
|
|
70
70
|
ref.reset({ data });
|
|
71
71
|
}, [ref, data]);
|
|
72
|
-
// Pull container id
|
|
73
|
-
const pullContainer = ((_b = states.element) === null || _b === void 0 ? void 0 : _b.parentElement)
|
|
74
|
-
? '.DataGridEx-Body'
|
|
75
|
-
: undefined;
|
|
76
72
|
// Layout
|
|
77
|
-
return (React.createElement(CommonPage, { ...pageProps, scrollContainer: states.element
|
|
73
|
+
return (React.createElement(CommonPage, { ...pageProps, scrollContainer: states.element },
|
|
78
74
|
React.createElement(Stack, null,
|
|
79
75
|
React.createElement(Box, { ref: dimensions[0][0], sx: {
|
|
80
76
|
paddingBottom: pageProps.paddings
|
|
@@ -61,13 +61,9 @@ export function FixedListPage(props) {
|
|
|
61
61
|
}, ...rest })));
|
|
62
62
|
}
|
|
63
63
|
}, [rect]);
|
|
64
|
-
// Pull container id
|
|
65
|
-
const pullContainer = (scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.parentElement)
|
|
66
|
-
? '#' + (scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.parentElement.id)
|
|
67
|
-
: undefined;
|
|
68
64
|
const { paddings, ...pageRest } = pageProps;
|
|
69
65
|
// Layout
|
|
70
|
-
return (React.createElement(CommonPage, { ...pageRest, paddings: {}, scrollContainer: scrollContainer
|
|
66
|
+
return (React.createElement(CommonPage, { ...pageRest, paddings: {}, scrollContainer: scrollContainer },
|
|
71
67
|
React.createElement(Stack, null,
|
|
72
68
|
React.createElement(Box, { ref: dimensions[0][0], sx: { padding: paddings } },
|
|
73
69
|
React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit })),
|
package/lib/mu/pages/ListPage.js
CHANGED
|
@@ -5,7 +5,7 @@ import useCombinedRefs from '../../uses/useCombinedRefs';
|
|
|
5
5
|
import { MUGlobal } from '../MUGlobal';
|
|
6
6
|
import { ScrollerListEx } from '../ScrollerListEx';
|
|
7
7
|
import { SearchBar } from '../SearchBar';
|
|
8
|
-
import { CommonPage,
|
|
8
|
+
import { CommonPage, CommonPageScrollContainer } from './CommonPage';
|
|
9
9
|
/**
|
|
10
10
|
* List page
|
|
11
11
|
* @param props Props
|
|
@@ -41,7 +41,7 @@ export function ListPage(props) {
|
|
|
41
41
|
return loadData(data);
|
|
42
42
|
};
|
|
43
43
|
// Layout
|
|
44
|
-
return (React.createElement(CommonPage, { ...pageProps, scrollContainer: CommonPageScrollContainer
|
|
44
|
+
return (React.createElement(CommonPage, { ...pageProps, scrollContainer: CommonPageScrollContainer },
|
|
45
45
|
React.createElement(Stack, null,
|
|
46
46
|
React.createElement(Box, { sx: {
|
|
47
47
|
paddingBottom: pageProps.paddings
|