@etsoo/react 1.4.43 → 1.4.47
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/ComboBox.js +4 -0
- package/lib/mu/ResponsibleContainer.d.ts +1 -1
- package/lib/mu/ResponsibleContainer.js +4 -4
- package/lib/mu/SelectEx.js +4 -0
- package/lib/mu/pages/ResponsivePage.js +3 -3
- package/package.json +4 -4
- package/src/mu/ComboBox.tsx +5 -0
- package/src/mu/ResponsibleContainer.tsx +13 -4
- package/src/mu/SelectEx.tsx +5 -0
- package/src/mu/pages/ResponsivePage.tsx +3 -3
package/lib/mu/ComboBox.js
CHANGED
|
@@ -16,6 +16,10 @@ export function ComboBox(props) {
|
|
|
16
16
|
// Options state
|
|
17
17
|
const [localOptions, setOptions] = React.useState(options);
|
|
18
18
|
const isMounted = React.useRef(true);
|
|
19
|
+
// When options change
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
setOptions(options);
|
|
22
|
+
}, [options]);
|
|
19
23
|
// Local default value
|
|
20
24
|
let localValue = idValue != null
|
|
21
25
|
? localOptions.find((o) => Reflect.get(o, idField) === idValue)
|
|
@@ -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/SelectEx.js
CHANGED
|
@@ -15,6 +15,10 @@ export function SelectEx(props) {
|
|
|
15
15
|
// Options state
|
|
16
16
|
const [localOptions, setOptions] = React.useState(options);
|
|
17
17
|
const isMounted = React.useRef(true);
|
|
18
|
+
// When options change
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
setOptions(options);
|
|
21
|
+
}, [options]);
|
|
18
22
|
// Local value
|
|
19
23
|
const valueSource = (_a = defaultValue !== null && defaultValue !== void 0 ? defaultValue : value) !== null && _a !== void 0 ? _a : '';
|
|
20
24
|
let localValue;
|
|
@@ -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.47",
|
|
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",
|
|
@@ -85,13 +85,13 @@
|
|
|
85
85
|
"@types/react-test-renderer": "^17.0.1",
|
|
86
86
|
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
|
87
87
|
"@typescript-eslint/parser": "^5.9.1",
|
|
88
|
-
"eslint": "^8.
|
|
88
|
+
"eslint": "^8.7.0",
|
|
89
89
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
90
90
|
"eslint-plugin-import": "^2.25.4",
|
|
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
|
}
|
package/src/mu/ComboBox.tsx
CHANGED
|
@@ -72,6 +72,11 @@ export function ComboBox<T extends {} = IdLabelDto>(props: ComboBoxProps<T>) {
|
|
|
72
72
|
const [localOptions, setOptions] = React.useState(options);
|
|
73
73
|
const isMounted = React.useRef(true);
|
|
74
74
|
|
|
75
|
+
// When options change
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
setOptions(options);
|
|
78
|
+
}, [options]);
|
|
79
|
+
|
|
75
80
|
// Local default value
|
|
76
81
|
let localValue =
|
|
77
82
|
idValue != null
|
|
@@ -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/SelectEx.tsx
CHANGED
|
@@ -90,6 +90,11 @@ export function SelectEx<T extends {} = IdLabelDto>(props: SelectExProps<T>) {
|
|
|
90
90
|
const [localOptions, setOptions] = React.useState(options);
|
|
91
91
|
const isMounted = React.useRef(true);
|
|
92
92
|
|
|
93
|
+
// When options change
|
|
94
|
+
React.useEffect(() => {
|
|
95
|
+
setOptions(options);
|
|
96
|
+
}, [options]);
|
|
97
|
+
|
|
93
98
|
// Local value
|
|
94
99
|
const valueSource = defaultValue ?? value ?? '';
|
|
95
100
|
let localValue: unknown | unknown[];
|
|
@@ -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
|