@etsoo/react 1.4.42 → 1.4.46
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/mu/ResponsibleContainer.d.ts +1 -1
- package/lib/mu/ResponsibleContainer.js +4 -4
- package/lib/mu/TabBox.d.ts +4 -0
- package/lib/mu/TabBox.js +2 -1
- package/lib/mu/pages/ResponsivePage.js +3 -3
- package/package.json +3 -3
- package/src/mu/ResponsibleContainer.tsx +13 -4
- package/src/mu/TabBox.tsx +12 -1
- package/src/mu/pages/ResponsivePage.tsx +3 -3
|
@@ -23,7 +23,7 @@ export interface ResponsibleContainerProps<T extends {}, F extends DataTypes.Bas
|
|
|
23
23
|
/**
|
|
24
24
|
* Container box SX (dataGrid determines the case)
|
|
25
25
|
*/
|
|
26
|
-
containerBoxSx?: (paddings: {}, dataGrid?: boolean) => SxProps<Theme>;
|
|
26
|
+
containerBoxSx?: (paddings: {}, hasFields: boolean, dataGrid?: boolean) => SxProps<Theme>;
|
|
27
27
|
/**
|
|
28
28
|
* Min width to show Datagrid
|
|
29
29
|
*/
|
|
@@ -9,11 +9,11 @@ import { MUGlobal } from './MUGlobal';
|
|
|
9
9
|
import { PullToRefreshUI } from './PullToRefreshUI';
|
|
10
10
|
import { ScrollerListEx } from './ScrollerListEx';
|
|
11
11
|
import { SearchBar } from './SearchBar';
|
|
12
|
-
function defaultContainerBoxSx(paddings, _dataGrid) {
|
|
12
|
+
function defaultContainerBoxSx(paddings, hasField, _dataGrid) {
|
|
13
13
|
const half = MUGlobal.half(paddings);
|
|
14
14
|
return {
|
|
15
15
|
'& .SearchBox': {
|
|
16
|
-
marginBottom: half
|
|
16
|
+
marginBottom: hasField ? half : 0
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
}
|
|
@@ -145,9 +145,9 @@ export function ResponsibleContainer(props) {
|
|
|
145
145
|
// Layout
|
|
146
146
|
return (React.createElement(Box, { sx: containerBoxSx == null
|
|
147
147
|
? undefined
|
|
148
|
-
: containerBoxSx(paddings, showDataGrid) },
|
|
148
|
+
: containerBoxSx(paddings, hasFields, showDataGrid) },
|
|
149
149
|
React.createElement(Stack, null,
|
|
150
|
-
React.createElement(Box, { ref: dimensions[0][0], className: "SearchBox" }, searchBar),
|
|
150
|
+
React.createElement(Box, { ref: dimensions[0][0], className: "SearchBox", sx: { height: hasFields ? 40 : 0 } }, searchBar),
|
|
151
151
|
list),
|
|
152
152
|
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: () => {
|
|
153
153
|
const container = document.querySelector(pullContainer);
|
package/lib/mu/TabBox.d.ts
CHANGED
package/lib/mu/TabBox.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Utils } from '@etsoo/shared';
|
|
2
2
|
import { Box, Tab, Tabs } from '@mui/material';
|
|
3
|
+
import { Link } from '@reach/router';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
/**
|
|
5
6
|
* Tabs with box
|
|
@@ -25,6 +26,6 @@ export function TabBox(props) {
|
|
|
25
26
|
setValue(newValue);
|
|
26
27
|
if (onChange)
|
|
27
28
|
onChange(event, newValue);
|
|
28
|
-
}, ...rest }, tabs.map(({ children, panel, ...tabRest }, index) => (React.createElement(Tab, { key: index, value: index, ...tabRest }))))),
|
|
29
|
+
}, ...rest }, tabs.map(({ children, panel, ...tabRest }, index) => (React.createElement(Tab, { key: index, value: index, LinkComponent: tabRest.to ? Link : undefined, ...tabRest }))))),
|
|
29
30
|
tabs.map(({ children, panel }, index) => (React.createElement(Box, { key: index, hidden: value !== index, ...panel }, Utils.getResult(children, value === index))))));
|
|
30
31
|
}
|
|
@@ -18,16 +18,16 @@ export function ResponsivePage(props) {
|
|
|
18
18
|
const [direction, setDirection] = React.useState(fabColumnDirection);
|
|
19
19
|
// Layout
|
|
20
20
|
return (React.createElement(CommonPage, { ...pageRest, paddings: {}, scrollContainer: scrollContainer, fabColumnDirection: direction },
|
|
21
|
-
React.createElement(ResponsibleContainer, { paddings: paddings, containerBoxSx: (paddings, _dataGrid) => {
|
|
21
|
+
React.createElement(ResponsibleContainer, { paddings: paddings, containerBoxSx: (paddings, hasField, _dataGrid) => {
|
|
22
22
|
// Half
|
|
23
23
|
const half = MUGlobal.half(paddings);
|
|
24
24
|
// .SearchBox keep the same to avoid flick when switching between DataGrid and List
|
|
25
25
|
return {
|
|
26
|
+
paddingTop: paddings,
|
|
26
27
|
'& .SearchBox': {
|
|
27
28
|
marginLeft: paddings,
|
|
28
|
-
marginTop: paddings,
|
|
29
29
|
marginRight: paddings,
|
|
30
|
-
marginBottom: half
|
|
30
|
+
marginBottom: hasField ? half : 0
|
|
31
31
|
},
|
|
32
32
|
'& .ListBox': {
|
|
33
33
|
marginBottom: paddings
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.46",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@emotion/react": "^11.7.1",
|
|
51
51
|
"@emotion/style": "^0.8.0",
|
|
52
52
|
"@emotion/styled": "^11.6.0",
|
|
53
|
-
"@etsoo/appscript": "^1.2.
|
|
53
|
+
"@etsoo/appscript": "^1.2.24",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.0",
|
|
55
55
|
"@etsoo/shared": "^1.1.3",
|
|
56
56
|
"@mui/icons-material": "^5.2.5",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"eslint-plugin-react": "^7.28.0",
|
|
92
92
|
"jest": "^27.4.7",
|
|
93
93
|
"react-test-renderer": "^17.0.2",
|
|
94
|
-
"ts-jest": "^27.1.
|
|
94
|
+
"ts-jest": "^27.1.3",
|
|
95
95
|
"typescript": "^4.5.4"
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -55,7 +55,11 @@ export interface ResponsibleContainerProps<
|
|
|
55
55
|
/**
|
|
56
56
|
* Container box SX (dataGrid determines the case)
|
|
57
57
|
*/
|
|
58
|
-
containerBoxSx?: (
|
|
58
|
+
containerBoxSx?: (
|
|
59
|
+
paddings: {},
|
|
60
|
+
hasFields: boolean,
|
|
61
|
+
dataGrid?: boolean
|
|
62
|
+
) => SxProps<Theme>;
|
|
59
63
|
|
|
60
64
|
/**
|
|
61
65
|
* Min width to show Datagrid
|
|
@@ -135,12 +139,13 @@ interface LocalRefs {
|
|
|
135
139
|
|
|
136
140
|
function defaultContainerBoxSx(
|
|
137
141
|
paddings: {},
|
|
142
|
+
hasField: boolean,
|
|
138
143
|
_dataGrid?: boolean
|
|
139
144
|
): SxProps<Theme> {
|
|
140
145
|
const half = MUGlobal.half(paddings);
|
|
141
146
|
return {
|
|
142
147
|
'& .SearchBox': {
|
|
143
|
-
marginBottom: half
|
|
148
|
+
marginBottom: hasField ? half : 0
|
|
144
149
|
}
|
|
145
150
|
};
|
|
146
151
|
}
|
|
@@ -345,11 +350,15 @@ export function ResponsibleContainer<
|
|
|
345
350
|
sx={
|
|
346
351
|
containerBoxSx == null
|
|
347
352
|
? undefined
|
|
348
|
-
: containerBoxSx(paddings, showDataGrid)
|
|
353
|
+
: containerBoxSx(paddings, hasFields, showDataGrid)
|
|
349
354
|
}
|
|
350
355
|
>
|
|
351
356
|
<Stack>
|
|
352
|
-
<Box
|
|
357
|
+
<Box
|
|
358
|
+
ref={dimensions[0][0]}
|
|
359
|
+
className="SearchBox"
|
|
360
|
+
sx={{ height: hasFields ? 40 : 0 }}
|
|
361
|
+
>
|
|
353
362
|
{searchBar}
|
|
354
363
|
</Box>
|
|
355
364
|
{list}
|
package/src/mu/TabBox.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Utils } from '@etsoo/shared';
|
|
2
2
|
import { Box, BoxProps, Tab, TabProps, Tabs, TabsProps } from '@mui/material';
|
|
3
|
+
import { Link } from '@reach/router';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -15,6 +16,11 @@ export interface TabBoxPanel extends Omit<TabProps, 'value' | 'children'> {
|
|
|
15
16
|
* Panel box props
|
|
16
17
|
*/
|
|
17
18
|
panel?: Omit<BoxProps, 'hidden'>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* To URL
|
|
22
|
+
*/
|
|
23
|
+
to?: string;
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
/**
|
|
@@ -93,7 +99,12 @@ export function TabBox(props: TabBoxPros) {
|
|
|
93
99
|
{...rest}
|
|
94
100
|
>
|
|
95
101
|
{tabs.map(({ children, panel, ...tabRest }, index) => (
|
|
96
|
-
<Tab
|
|
102
|
+
<Tab
|
|
103
|
+
key={index}
|
|
104
|
+
value={index}
|
|
105
|
+
LinkComponent={tabRest.to ? Link : undefined}
|
|
106
|
+
{...tabRest}
|
|
107
|
+
/>
|
|
97
108
|
))}
|
|
98
109
|
</Tabs>
|
|
99
110
|
</Box>
|
|
@@ -34,17 +34,17 @@ export function ResponsivePage<
|
|
|
34
34
|
>
|
|
35
35
|
<ResponsibleContainer<T, F>
|
|
36
36
|
paddings={paddings}
|
|
37
|
-
containerBoxSx={(paddings, _dataGrid) => {
|
|
37
|
+
containerBoxSx={(paddings, hasField, _dataGrid) => {
|
|
38
38
|
// Half
|
|
39
39
|
const half = MUGlobal.half(paddings);
|
|
40
40
|
|
|
41
41
|
// .SearchBox keep the same to avoid flick when switching between DataGrid and List
|
|
42
42
|
return {
|
|
43
|
+
paddingTop: paddings,
|
|
43
44
|
'& .SearchBox': {
|
|
44
45
|
marginLeft: paddings,
|
|
45
|
-
marginTop: paddings,
|
|
46
46
|
marginRight: paddings,
|
|
47
|
-
marginBottom: half
|
|
47
|
+
marginBottom: hasField ? half : 0
|
|
48
48
|
},
|
|
49
49
|
'& .ListBox': {
|
|
50
50
|
marginBottom: paddings
|