@etsoo/materialui 1.1.55 → 1.1.56
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 -0
- package/lib/ResponsibleContainer.js +3 -3
- package/lib/SearchBar.js +3 -5
- package/lib/app/ReactApp.d.ts +7 -5
- package/lib/app/ReactApp.js +4 -3
- package/lib/pages/ResponsivePage.d.ts +2 -2
- package/lib/pages/ResponsivePage.js +7 -7
- package/lib/pages/SearchPageProps.d.ts +12 -4
- package/package.json +1 -1
- package/src/ResponsibleContainer.tsx +8 -1
- package/src/SearchBar.tsx +3 -5
- package/src/app/ReactApp.ts +8 -6
- package/src/pages/ResponsivePage.tsx +55 -55
- package/src/pages/SearchPageProps.ts +39 -29
|
@@ -82,6 +82,10 @@ export type ResponsibleContainerProps<T extends object, F extends DataTypes.Basi
|
|
|
82
82
|
* Size ready to read miliseconds span
|
|
83
83
|
*/
|
|
84
84
|
sizeReadyMiliseconds?: number;
|
|
85
|
+
/**
|
|
86
|
+
* SearchBar height
|
|
87
|
+
*/
|
|
88
|
+
searchBarHeight?: number;
|
|
85
89
|
};
|
|
86
90
|
/**
|
|
87
91
|
* Responsible container
|
|
@@ -22,7 +22,7 @@ function defaultContainerBoxSx(paddings, hasField, _dataGrid) {
|
|
|
22
22
|
*/
|
|
23
23
|
export function ResponsibleContainer(props) {
|
|
24
24
|
// Destruct
|
|
25
|
-
const { adjustHeight, columns, containerBoxSx = defaultContainerBoxSx, dataGridMinWidth = Math.max(576, DataGridExCalColumns(columns).total), elementReady, fields, fieldTemplate, height, topHeight, loadData, mRef, paddings = MUGlobal.pagePaddings, pullToRefresh = true, quickAction, sizeReadyMiliseconds = 0, ...rest } = props;
|
|
25
|
+
const { adjustHeight, columns, containerBoxSx = defaultContainerBoxSx, dataGridMinWidth = Math.max(576, DataGridExCalColumns(columns).total), elementReady, fields, fieldTemplate, height, topHeight, loadData, mRef, paddings = MUGlobal.pagePaddings, pullToRefresh = true, quickAction, sizeReadyMiliseconds = 0, searchBarHeight, ...rest } = props;
|
|
26
26
|
// Labels
|
|
27
27
|
const labels = Labels.CommonPage;
|
|
28
28
|
// Refs
|
|
@@ -132,8 +132,8 @@ export function ResponsibleContainer(props) {
|
|
|
132
132
|
const searchBar = React.useMemo(() => {
|
|
133
133
|
if (!hasFields || showDataGrid == null)
|
|
134
134
|
return;
|
|
135
|
-
return (React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}
|
|
136
|
-
}, [showDataGrid, hasFields]);
|
|
135
|
+
return (React.createElement(SearchBar, { fields: fields, onSubmit: onSubmit, className: `searchBar${showDataGrid ? "Grid" : "List"}`, innerHeight: searchBarHeight }));
|
|
136
|
+
}, [showDataGrid, hasFields, searchBarHeight]);
|
|
137
137
|
// Pull container
|
|
138
138
|
const pullContainer = showDataGrid == null
|
|
139
139
|
? undefined
|
package/lib/SearchBar.js
CHANGED
|
@@ -52,7 +52,7 @@ const setChildState = (child, enabled) => {
|
|
|
52
52
|
*/
|
|
53
53
|
export function SearchBar(props) {
|
|
54
54
|
// Destruct
|
|
55
|
-
const { className, fields, innerHeight =
|
|
55
|
+
const { className, fields, innerHeight = 45.6, onSubmit } = props;
|
|
56
56
|
// Labels
|
|
57
57
|
const labels = Labels.CommonPage;
|
|
58
58
|
// Spacing
|
|
@@ -223,14 +223,12 @@ export function SearchBar(props) {
|
|
|
223
223
|
if (form)
|
|
224
224
|
state.form = form;
|
|
225
225
|
} },
|
|
226
|
-
React.createElement(Stack, { ref: dimensions[0][0], justifyContent: "center", alignItems: "center", direction: "row", spacing: 1, height: innerHeight, sx: {
|
|
226
|
+
React.createElement(Stack, { ref: dimensions[0][0], justifyContent: "center", alignItems: "center", direction: "row", spacing: 1, height: innerHeight < 1 ? undefined : innerHeight, sx: {
|
|
227
227
|
"& > :not(style)": {
|
|
228
228
|
flexBasis: "auto",
|
|
229
229
|
flexGrow: 0,
|
|
230
230
|
flexShrink: 0,
|
|
231
|
-
maxWidth: "180px"
|
|
232
|
-
},
|
|
233
|
-
"& > :not:first-child": {
|
|
231
|
+
maxWidth: "180px",
|
|
234
232
|
visibility: "hidden"
|
|
235
233
|
},
|
|
236
234
|
"& > .hiddenChild": {
|
package/lib/app/ReactApp.d.ts
CHANGED
|
@@ -61,10 +61,11 @@ export interface IReactAppBase {
|
|
|
61
61
|
*/
|
|
62
62
|
setPageData(data: IPageData): void;
|
|
63
63
|
/**
|
|
64
|
-
* Set page title and
|
|
65
|
-
* @param
|
|
64
|
+
* Set page title and subtitle
|
|
65
|
+
* @param title Page title
|
|
66
|
+
* @param subtitle Page subtitle
|
|
66
67
|
*/
|
|
67
|
-
|
|
68
|
+
setPageTitle(title: string, subtitle?: string): void;
|
|
68
69
|
/**
|
|
69
70
|
* Set page title and data
|
|
70
71
|
* @param title Page title
|
|
@@ -183,10 +184,11 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
|
|
|
183
184
|
*/
|
|
184
185
|
setPageData(data: P): void;
|
|
185
186
|
/**
|
|
186
|
-
* Set page title and
|
|
187
|
+
* Set page title and subtitle
|
|
187
188
|
* @param title Page title
|
|
189
|
+
* @param subtitle Page subtitle
|
|
188
190
|
*/
|
|
189
|
-
setPageTitle(title: string): void;
|
|
191
|
+
setPageTitle(title: string, subtitle?: string): void;
|
|
190
192
|
/**
|
|
191
193
|
* Navigate to Url or delta
|
|
192
194
|
* @param url Url or delta
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -206,12 +206,13 @@ export class ReactApp extends CoreApp {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
|
-
* Set page title and
|
|
209
|
+
* Set page title and subtitle
|
|
210
210
|
* @param title Page title
|
|
211
|
+
* @param subtitle Page subtitle
|
|
211
212
|
*/
|
|
212
|
-
setPageTitle(title) {
|
|
213
|
+
setPageTitle(title, subtitle) {
|
|
213
214
|
// Data
|
|
214
|
-
const data = { title };
|
|
215
|
+
const data = { title, subtitle };
|
|
215
216
|
// Dispatch the change
|
|
216
217
|
if (this.pageStateDispatch != null) {
|
|
217
218
|
this.pageStateDispatch({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes, IdDefaultType } from
|
|
3
|
-
import { ResponsePageProps } from
|
|
2
|
+
import { DataTypes, IdDefaultType } from "@etsoo/shared";
|
|
3
|
+
import { ResponsePageProps } from "./ResponsivePageProps";
|
|
4
4
|
/**
|
|
5
5
|
* Fixed height list page
|
|
6
6
|
* @param props Props
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { MUGlobal } from
|
|
3
|
-
import { ResponsibleContainer } from
|
|
4
|
-
import { CommonPage } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MUGlobal } from "../MUGlobal";
|
|
3
|
+
import { ResponsibleContainer } from "../ResponsibleContainer";
|
|
4
|
+
import { CommonPage } from "./CommonPage";
|
|
5
5
|
/**
|
|
6
6
|
* Fixed height list page
|
|
7
7
|
* @param props Props
|
|
@@ -24,15 +24,15 @@ export function ResponsivePage(props) {
|
|
|
24
24
|
// .SearchBox keep the same to avoid flick when switching between DataGrid and List
|
|
25
25
|
return {
|
|
26
26
|
paddingTop: paddings,
|
|
27
|
-
|
|
27
|
+
"& .SearchBox": {
|
|
28
28
|
marginLeft: paddings,
|
|
29
29
|
marginRight: paddings,
|
|
30
30
|
marginBottom: hasField ? half : 0
|
|
31
31
|
},
|
|
32
|
-
|
|
32
|
+
"& .ListBox": {
|
|
33
33
|
marginBottom: paddings
|
|
34
34
|
},
|
|
35
|
-
|
|
35
|
+
"& .DataGridBox": {
|
|
36
36
|
marginLeft: paddings,
|
|
37
37
|
marginRight: paddings,
|
|
38
38
|
marginBottom: paddings
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { GridJsonData, GridLoader } from
|
|
3
|
-
import { DataTypes } from
|
|
4
|
-
import { CommonPageProps } from
|
|
2
|
+
import { GridJsonData, GridLoader } from "@etsoo/react";
|
|
3
|
+
import { DataTypes } from "@etsoo/shared";
|
|
4
|
+
import { CommonPageProps } from "./CommonPageProps";
|
|
5
5
|
/**
|
|
6
6
|
* Search page props
|
|
7
7
|
*/
|
|
8
|
-
export type SearchPageProps<T extends object, F extends DataTypes.BasicTemplate> = Omit<GridLoader<T>,
|
|
8
|
+
export type SearchPageProps<T extends object, F extends DataTypes.BasicTemplate> = Omit<GridLoader<T>, "loadData"> & {
|
|
9
9
|
/**
|
|
10
10
|
* Search fields
|
|
11
11
|
*/
|
|
@@ -27,4 +27,12 @@ export type SearchPageProps<T extends object, F extends DataTypes.BasicTemplate>
|
|
|
27
27
|
* @default 100
|
|
28
28
|
*/
|
|
29
29
|
sizeReadyMiliseconds?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Top height
|
|
32
|
+
*/
|
|
33
|
+
topHeight?: number;
|
|
34
|
+
/**
|
|
35
|
+
* SearchBar height
|
|
36
|
+
*/
|
|
37
|
+
searchBarHeight?: number;
|
|
30
38
|
};
|
package/package.json
CHANGED
|
@@ -136,6 +136,11 @@ export type ResponsibleContainerProps<
|
|
|
136
136
|
* Size ready to read miliseconds span
|
|
137
137
|
*/
|
|
138
138
|
sizeReadyMiliseconds?: number;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* SearchBar height
|
|
142
|
+
*/
|
|
143
|
+
searchBarHeight?: number;
|
|
139
144
|
};
|
|
140
145
|
|
|
141
146
|
interface LocalRefs<T> {
|
|
@@ -184,6 +189,7 @@ export function ResponsibleContainer<
|
|
|
184
189
|
pullToRefresh = true,
|
|
185
190
|
quickAction,
|
|
186
191
|
sizeReadyMiliseconds = 0,
|
|
192
|
+
searchBarHeight,
|
|
187
193
|
...rest
|
|
188
194
|
} = props;
|
|
189
195
|
|
|
@@ -344,9 +350,10 @@ export function ResponsibleContainer<
|
|
|
344
350
|
fields={fields}
|
|
345
351
|
onSubmit={onSubmit}
|
|
346
352
|
className={`searchBar${showDataGrid ? "Grid" : "List"}`}
|
|
353
|
+
innerHeight={searchBarHeight}
|
|
347
354
|
/>
|
|
348
355
|
);
|
|
349
|
-
}, [showDataGrid, hasFields]);
|
|
356
|
+
}, [showDataGrid, hasFields, searchBarHeight]);
|
|
350
357
|
|
|
351
358
|
// Pull container
|
|
352
359
|
const pullContainer =
|
package/src/SearchBar.tsx
CHANGED
|
@@ -83,7 +83,7 @@ const setChildState = (child: Element, enabled: boolean) => {
|
|
|
83
83
|
*/
|
|
84
84
|
export function SearchBar(props: SearchBarProps) {
|
|
85
85
|
// Destruct
|
|
86
|
-
const { className, fields, innerHeight =
|
|
86
|
+
const { className, fields, innerHeight = 45.6, onSubmit } = props;
|
|
87
87
|
|
|
88
88
|
// Labels
|
|
89
89
|
const labels = Labels.CommonPage;
|
|
@@ -311,15 +311,13 @@ export function SearchBar(props: SearchBarProps) {
|
|
|
311
311
|
alignItems="center"
|
|
312
312
|
direction="row"
|
|
313
313
|
spacing={1}
|
|
314
|
-
height={innerHeight}
|
|
314
|
+
height={innerHeight < 1 ? undefined : innerHeight}
|
|
315
315
|
sx={{
|
|
316
316
|
"& > :not(style)": {
|
|
317
317
|
flexBasis: "auto",
|
|
318
318
|
flexGrow: 0,
|
|
319
319
|
flexShrink: 0,
|
|
320
|
-
maxWidth: "180px"
|
|
321
|
-
},
|
|
322
|
-
"& > :not:first-child": {
|
|
320
|
+
maxWidth: "180px",
|
|
323
321
|
visibility: "hidden"
|
|
324
322
|
},
|
|
325
323
|
"& > .hiddenChild": {
|
package/src/app/ReactApp.ts
CHANGED
|
@@ -133,10 +133,11 @@ export interface IReactAppBase {
|
|
|
133
133
|
setPageData(data: IPageData): void;
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
|
-
* Set page title and
|
|
137
|
-
* @param
|
|
136
|
+
* Set page title and subtitle
|
|
137
|
+
* @param title Page title
|
|
138
|
+
* @param subtitle Page subtitle
|
|
138
139
|
*/
|
|
139
|
-
|
|
140
|
+
setPageTitle(title: string, subtitle?: string): void;
|
|
140
141
|
|
|
141
142
|
/**
|
|
142
143
|
* Set page title and data
|
|
@@ -425,12 +426,13 @@ export class ReactApp<
|
|
|
425
426
|
}
|
|
426
427
|
|
|
427
428
|
/**
|
|
428
|
-
* Set page title and
|
|
429
|
+
* Set page title and subtitle
|
|
429
430
|
* @param title Page title
|
|
431
|
+
* @param subtitle Page subtitle
|
|
430
432
|
*/
|
|
431
|
-
setPageTitle(title: string): void {
|
|
433
|
+
setPageTitle(title: string, subtitle?: string): void {
|
|
432
434
|
// Data
|
|
433
|
-
const data = { title } as P;
|
|
435
|
+
const data = { title, subtitle } as P;
|
|
434
436
|
|
|
435
437
|
// Dispatch the change
|
|
436
438
|
if (this.pageStateDispatch != null) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DataTypes, IdDefaultType } from
|
|
2
|
-
import React from
|
|
3
|
-
import { MUGlobal } from
|
|
4
|
-
import { ResponsibleContainer } from
|
|
5
|
-
import { CommonPage } from
|
|
6
|
-
import { ResponsePageProps } from
|
|
1
|
+
import { DataTypes, IdDefaultType } from "@etsoo/shared";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { MUGlobal } from "../MUGlobal";
|
|
4
|
+
import { ResponsibleContainer } from "../ResponsibleContainer";
|
|
5
|
+
import { CommonPage } from "./CommonPage";
|
|
6
|
+
import { ResponsePageProps } from "./ResponsivePageProps";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Fixed height list page
|
|
@@ -11,58 +11,58 @@ import { ResponsePageProps } from './ResponsivePageProps';
|
|
|
11
11
|
* @returns Component
|
|
12
12
|
*/
|
|
13
13
|
export function ResponsivePage<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
T extends object,
|
|
15
|
+
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
|
|
16
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
17
17
|
>(props: ResponsePageProps<T, F, D>) {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// Destruct
|
|
19
|
+
const { pageProps = {}, ...rest } = props;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
pageProps.paddings ??= MUGlobal.pagePaddings;
|
|
22
|
+
const { paddings, fabColumnDirection, ...pageRest } = pageProps;
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
// State
|
|
25
|
+
const [scrollContainer, setScrollContainer] = React.useState<HTMLElement>();
|
|
26
|
+
const [direction, setDirection] = React.useState(fabColumnDirection);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
// Layout
|
|
29
|
+
return (
|
|
30
|
+
<CommonPage
|
|
31
|
+
{...pageRest}
|
|
32
|
+
paddings={{}}
|
|
33
|
+
scrollContainer={scrollContainer}
|
|
34
|
+
fabColumnDirection={direction}
|
|
35
|
+
>
|
|
36
|
+
<ResponsibleContainer<T, F, D>
|
|
37
|
+
paddings={paddings}
|
|
38
|
+
containerBoxSx={(paddings, hasField, _dataGrid) => {
|
|
39
|
+
// Half
|
|
40
|
+
const half = MUGlobal.half(paddings);
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
42
|
+
// .SearchBox keep the same to avoid flick when switching between DataGrid and List
|
|
43
|
+
return {
|
|
44
|
+
paddingTop: paddings,
|
|
45
|
+
"& .SearchBox": {
|
|
46
|
+
marginLeft: paddings,
|
|
47
|
+
marginRight: paddings,
|
|
48
|
+
marginBottom: hasField ? half : 0
|
|
49
|
+
},
|
|
50
|
+
"& .ListBox": {
|
|
51
|
+
marginBottom: paddings
|
|
52
|
+
},
|
|
53
|
+
"& .DataGridBox": {
|
|
54
|
+
marginLeft: paddings,
|
|
55
|
+
marginRight: paddings,
|
|
56
|
+
marginBottom: paddings
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}}
|
|
60
|
+
elementReady={(element, isDataGrid) => {
|
|
61
|
+
setDirection(!isDataGrid);
|
|
62
|
+
setScrollContainer(element);
|
|
63
|
+
}}
|
|
64
|
+
{...rest}
|
|
65
|
+
/>
|
|
66
|
+
</CommonPage>
|
|
67
|
+
);
|
|
68
68
|
}
|
|
@@ -1,39 +1,49 @@
|
|
|
1
|
-
import { GridJsonData, GridLoader } from
|
|
2
|
-
import { DataTypes } from
|
|
3
|
-
import { CommonPageProps } from
|
|
1
|
+
import { GridJsonData, GridLoader } from "@etsoo/react";
|
|
2
|
+
import { DataTypes } from "@etsoo/shared";
|
|
3
|
+
import { CommonPageProps } from "./CommonPageProps";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Search page props
|
|
7
7
|
*/
|
|
8
8
|
export type SearchPageProps<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
> = Omit<GridLoader<T>,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
T extends object,
|
|
10
|
+
F extends DataTypes.BasicTemplate
|
|
11
|
+
> = Omit<GridLoader<T>, "loadData"> & {
|
|
12
|
+
/**
|
|
13
|
+
* Search fields
|
|
14
|
+
*/
|
|
15
|
+
fields: React.ReactElement[];
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Search field template
|
|
19
|
+
*/
|
|
20
|
+
fieldTemplate?: F;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Load data callback
|
|
24
|
+
*/
|
|
25
|
+
loadData: (
|
|
26
|
+
data: GridJsonData & DataTypes.BasicTemplateType<F>
|
|
27
|
+
) => PromiseLike<T[] | null | undefined>;
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Page props
|
|
31
|
+
*/
|
|
32
|
+
pageProps?: CommonPageProps;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Size ready to read miliseconds span
|
|
36
|
+
* @default 100
|
|
37
|
+
*/
|
|
38
|
+
sizeReadyMiliseconds?: number;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Top height
|
|
42
|
+
*/
|
|
43
|
+
topHeight?: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* SearchBar height
|
|
47
|
+
*/
|
|
48
|
+
searchBarHeight?: number;
|
|
39
49
|
};
|