@etsoo/react 1.4.83 → 1.4.87
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/app/ServiceApp.d.ts +2 -1
- package/lib/app/ServiceApp.js +4 -2
- package/lib/mu/AuditDisplay.js +7 -6
- package/lib/mu/ComboBox.d.ts +4 -0
- package/lib/mu/ComboBox.js +2 -2
- package/lib/mu/SelectBool.js +2 -2
- package/lib/mu/SelectEx.d.ts +4 -0
- package/lib/mu/SelectEx.js +2 -2
- package/lib/mu/pages/ViewPage.js +5 -2
- package/package.json +3 -3
- package/src/app/ServiceApp.ts +4 -2
- package/src/mu/AuditDisplay.tsx +13 -9
- package/src/mu/ComboBox.tsx +7 -1
- package/src/mu/SelectBool.tsx +2 -2
- package/src/mu/SelectEx.tsx +7 -1
- package/src/mu/pages/ViewPage.tsx +6 -2
package/lib/app/ServiceApp.d.ts
CHANGED
|
@@ -34,8 +34,9 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
34
34
|
constructor(settings: S, name: string);
|
|
35
35
|
/**
|
|
36
36
|
* Go to the login page
|
|
37
|
+
* @param tryLogin Try to login again
|
|
37
38
|
*/
|
|
38
|
-
toLoginPage(): void;
|
|
39
|
+
toLoginPage(tryLogin?: boolean): void;
|
|
39
40
|
/**
|
|
40
41
|
* Refresh token
|
|
41
42
|
* @param props Props
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -41,8 +41,9 @@ export class ServiceApp extends ReactApp {
|
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Go to the login page
|
|
44
|
+
* @param tryLogin Try to login again
|
|
44
45
|
*/
|
|
45
|
-
toLoginPage() {
|
|
46
|
+
toLoginPage(tryLogin) {
|
|
46
47
|
const coreUrl = this.settings.webUrl;
|
|
47
48
|
window.location.href =
|
|
48
49
|
coreUrl +
|
|
@@ -51,7 +52,8 @@ export class ServiceApp extends ReactApp {
|
|
|
51
52
|
'&' +
|
|
52
53
|
DomUtils.CultureField +
|
|
53
54
|
'=' +
|
|
54
|
-
this.culture
|
|
55
|
+
this.culture +
|
|
56
|
+
(tryLogin ? '' : '&tryLogin=false');
|
|
55
57
|
}
|
|
56
58
|
/**
|
|
57
59
|
* Refresh token
|
package/lib/mu/AuditDisplay.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Utils } from '@etsoo/shared';
|
|
2
|
-
import { Button, Divider, Table, TableBody, TableCell, TableHead, TableRow, useTheme } from '@mui/material';
|
|
2
|
+
import { Button, Divider, Table, TableBody, TableCell, TableHead, TableRow, Typography, useTheme } from '@mui/material';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { globalApp, NotificationMessageType } from '..';
|
|
5
5
|
import { ListMoreDisplay } from './ListMoreDisplay';
|
|
@@ -57,11 +57,11 @@ export function AuditDisplay(props) {
|
|
|
57
57
|
React.createElement(TableCell, null, getLabel(row.field)),
|
|
58
58
|
React.createElement(TableCell, { align: "right" }, formatValue(row.oldValue)),
|
|
59
59
|
React.createElement(TableCell, { align: "right" }, formatValue(row.newValue))))))));
|
|
60
|
-
globalApp.notifier.alert(undefined, undefined, NotificationMessageType.Info, { fullScreen: globalApp.smDown, inputs
|
|
60
|
+
globalApp.notifier.alert([undefined, dataComparisonLabel], undefined, NotificationMessageType.Info, { fullScreen: globalApp.smDown, inputs });
|
|
61
61
|
};
|
|
62
62
|
// Destruct
|
|
63
63
|
const { getItemStyle = (index, theme) => ({
|
|
64
|
-
padding: theme.spacing(1),
|
|
64
|
+
padding: [theme.spacing(1.5), theme.spacing(1)].join(' '),
|
|
65
65
|
background: index % 2 === 0
|
|
66
66
|
? theme.palette.grey[100]
|
|
67
67
|
: theme.palette.grey[50]
|
|
@@ -69,15 +69,16 @@ export function AuditDisplay(props) {
|
|
|
69
69
|
return (React.createElement(React.Fragment, null,
|
|
70
70
|
data.changes != null && (React.createElement(Button, { variant: "outlined", size: "small", onClick: () => showDataComparison(data.changes), sx: {
|
|
71
71
|
marginLeft: theme.spacing(1),
|
|
72
|
+
marginTop: theme.spacing(-0.5),
|
|
72
73
|
float: 'right'
|
|
73
74
|
} }, dataComparisonLabel)),
|
|
74
|
-
formatDate(data.creation) +
|
|
75
|
+
React.createElement(Typography, null, formatDate(data.creation) +
|
|
75
76
|
', [' +
|
|
76
77
|
getLabel(data.action) +
|
|
77
78
|
'], ' +
|
|
78
|
-
data.user));
|
|
79
|
+
data.user)));
|
|
79
80
|
}, headerTitle = (React.createElement(React.Fragment, null,
|
|
80
|
-
getLabel('audits'),
|
|
81
|
+
React.createElement(Typography, null, getLabel('audits')),
|
|
81
82
|
React.createElement(Divider, null))), ...rest } = props;
|
|
82
83
|
// Layout
|
|
83
84
|
return (React.createElement(ListMoreDisplay, { headerTitle: headerTitle, ...rest }, (data, index) => (React.createElement("div", { key: data.id, style: getItemStyle(index, theme) }, itemRenderer(data, index)))));
|
package/lib/mu/ComboBox.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
|
|
|
5
5
|
* ComboBox props
|
|
6
6
|
*/
|
|
7
7
|
export interface ComboBoxProps<T extends {}> extends AutocompleteExtendedProps<T> {
|
|
8
|
+
/**
|
|
9
|
+
* Auto add blank item
|
|
10
|
+
*/
|
|
11
|
+
autoAddBlankItem?: boolean;
|
|
8
12
|
/**
|
|
9
13
|
* Data readonly
|
|
10
14
|
*/
|
package/lib/mu/ComboBox.js
CHANGED
|
@@ -12,7 +12,7 @@ import { SearchField } from './SearchField';
|
|
|
12
12
|
*/
|
|
13
13
|
export function ComboBox(props) {
|
|
14
14
|
// Destruct
|
|
15
|
-
const { search = false, idField = 'id', idValue, inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, defaultValue, label, labelField = 'label', loadData, onLoadData, name, inputAutoComplete = 'off', options, dataReadonly = true, readOnly, onChange, openOnFocus = true, value, getOptionLabel = (option) => String(Reflect.get(option, labelField)), sx = { minWidth: '150px' }, ...rest } = props;
|
|
15
|
+
const { search = false, autoAddBlankItem = search, idField = 'id', idValue, inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, defaultValue, label, labelField = 'label', loadData, onLoadData, name, inputAutoComplete = 'off', options, dataReadonly = true, readOnly, onChange, openOnFocus = true, value, getOptionLabel = (option) => String(Reflect.get(option, labelField)), sx = { minWidth: '150px' }, ...rest } = props;
|
|
16
16
|
// Value input ref
|
|
17
17
|
const inputRef = React.createRef();
|
|
18
18
|
// Options state
|
|
@@ -82,7 +82,7 @@ export function ComboBox(props) {
|
|
|
82
82
|
return;
|
|
83
83
|
if (onLoadData)
|
|
84
84
|
onLoadData(result);
|
|
85
|
-
if (
|
|
85
|
+
if (autoAddBlankItem) {
|
|
86
86
|
SharedUtils.addBlankItem(result, idField, labelField);
|
|
87
87
|
}
|
|
88
88
|
setOptions(result);
|
package/lib/mu/SelectBool.js
CHANGED
|
@@ -9,13 +9,13 @@ import { SelectEx } from './SelectEx';
|
|
|
9
9
|
*/
|
|
10
10
|
export function SelectBool(props) {
|
|
11
11
|
// Destruct
|
|
12
|
-
const { search = true, ...rest } = props;
|
|
12
|
+
const { search = true, autoAddBlankItem = search, ...rest } = props;
|
|
13
13
|
// Options
|
|
14
14
|
const options = [
|
|
15
15
|
{ id: 'false', label: globalApp.get('no') },
|
|
16
16
|
{ id: 'true', label: globalApp.get('yes') }
|
|
17
17
|
];
|
|
18
|
-
if (
|
|
18
|
+
if (autoAddBlankItem)
|
|
19
19
|
Utils.addBlankItem(options);
|
|
20
20
|
// Layout
|
|
21
21
|
return React.createElement(SelectEx, { options: options, search: search, ...rest });
|
package/lib/mu/SelectEx.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ import { IdLabelDto } from '@etsoo/appscript';
|
|
|
5
5
|
* Extended select component props
|
|
6
6
|
*/
|
|
7
7
|
export interface SelectExProps<T extends {}> extends Omit<SelectProps, 'labelId' | 'input' | 'native'> {
|
|
8
|
+
/**
|
|
9
|
+
* Auto add blank item
|
|
10
|
+
*/
|
|
11
|
+
autoAddBlankItem?: boolean;
|
|
8
12
|
/**
|
|
9
13
|
* Id field, default is id
|
|
10
14
|
*/
|
package/lib/mu/SelectEx.js
CHANGED
|
@@ -12,7 +12,7 @@ import { Utils } from '@etsoo/shared';
|
|
|
12
12
|
export function SelectEx(props) {
|
|
13
13
|
var _a;
|
|
14
14
|
// Destruct
|
|
15
|
-
const { defaultValue, idField = 'id', itemIconRenderer, label, labelField = 'label', loadData, onItemClick, onLoadData, multiple = false, name, options = [], search = false, value, onChange, ...rest } = props;
|
|
15
|
+
const { defaultValue, idField = 'id', itemIconRenderer, label, labelField = 'label', loadData, onItemClick, onLoadData, multiple = false, name, options = [], search = false, autoAddBlankItem = search, value, onChange, ...rest } = props;
|
|
16
16
|
// Options state
|
|
17
17
|
const [localOptions, setOptions] = React.useState(options);
|
|
18
18
|
const isMounted = React.useRef(true);
|
|
@@ -97,7 +97,7 @@ export function SelectEx(props) {
|
|
|
97
97
|
return;
|
|
98
98
|
if (onLoadData)
|
|
99
99
|
onLoadData(result);
|
|
100
|
-
if (
|
|
100
|
+
if (autoAddBlankItem) {
|
|
101
101
|
Utils.addBlankItem(result, idField, labelField);
|
|
102
102
|
}
|
|
103
103
|
setOptions(result);
|
package/lib/mu/pages/ViewPage.js
CHANGED
|
@@ -18,6 +18,7 @@ function getItemField(field, data) {
|
|
|
18
18
|
var _a, _b, _c;
|
|
19
19
|
// Item data and label
|
|
20
20
|
let itemData, itemLabel, gridProps = {};
|
|
21
|
+
let xs = 6;
|
|
21
22
|
if (Array.isArray(field)) {
|
|
22
23
|
const [fieldData, fieldType, renderProps] = field;
|
|
23
24
|
itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
|
|
@@ -25,11 +26,13 @@ function getItemField(field, data) {
|
|
|
25
26
|
}
|
|
26
27
|
else if (typeof field === 'object') {
|
|
27
28
|
// Destruct
|
|
28
|
-
const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow
|
|
29
|
+
const { data: fieldData, dataType, label: fieldLabel, renderProps, singleRow, ...rest } = field;
|
|
29
30
|
gridProps = {
|
|
30
31
|
...rest,
|
|
31
32
|
...(singleRow && { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 })
|
|
32
33
|
};
|
|
34
|
+
if (singleRow === false)
|
|
35
|
+
xs = 12;
|
|
33
36
|
// Field data
|
|
34
37
|
if (typeof fieldData === 'function')
|
|
35
38
|
itemData = fieldData(data);
|
|
@@ -50,7 +53,7 @@ function getItemField(field, data) {
|
|
|
50
53
|
return [
|
|
51
54
|
itemData,
|
|
52
55
|
itemLabel,
|
|
53
|
-
{ xs
|
|
56
|
+
{ xs, sm: 6, md: 6, lg: 4, xl: 3, ...gridProps }
|
|
54
57
|
];
|
|
55
58
|
}
|
|
56
59
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.87",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,8 +50,8 @@
|
|
|
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.
|
|
54
|
-
"@etsoo/notificationbase": "^1.1.
|
|
53
|
+
"@etsoo/appscript": "^1.2.34",
|
|
54
|
+
"@etsoo/notificationbase": "^1.1.1",
|
|
55
55
|
"@etsoo/shared": "^1.1.9",
|
|
56
56
|
"@mui/icons-material": "^5.3.1",
|
|
57
57
|
"@mui/material": "^5.4.0",
|
package/src/app/ServiceApp.ts
CHANGED
|
@@ -69,8 +69,9 @@ export class ServiceApp<
|
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Go to the login page
|
|
72
|
+
* @param tryLogin Try to login again
|
|
72
73
|
*/
|
|
73
|
-
override toLoginPage() {
|
|
74
|
+
override toLoginPage(tryLogin?: boolean) {
|
|
74
75
|
const coreUrl = this.settings.webUrl;
|
|
75
76
|
window.location.href =
|
|
76
77
|
coreUrl +
|
|
@@ -79,7 +80,8 @@ export class ServiceApp<
|
|
|
79
80
|
'&' +
|
|
80
81
|
DomUtils.CultureField +
|
|
81
82
|
'=' +
|
|
82
|
-
this.culture
|
|
83
|
+
this.culture +
|
|
84
|
+
(tryLogin ? '' : '&tryLogin=false');
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
/**
|
package/src/mu/AuditDisplay.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
TableHead,
|
|
9
9
|
TableRow,
|
|
10
10
|
Theme,
|
|
11
|
+
Typography,
|
|
11
12
|
useTheme
|
|
12
13
|
} from '@mui/material';
|
|
13
14
|
import React, { CSSProperties } from 'react';
|
|
@@ -126,17 +127,17 @@ export function AuditDisplay(props: AuditDisplayProps) {
|
|
|
126
127
|
);
|
|
127
128
|
|
|
128
129
|
globalApp.notifier.alert(
|
|
129
|
-
undefined,
|
|
130
|
+
[undefined, dataComparisonLabel],
|
|
130
131
|
undefined,
|
|
131
132
|
NotificationMessageType.Info,
|
|
132
|
-
{ fullScreen: globalApp.smDown, inputs
|
|
133
|
+
{ fullScreen: globalApp.smDown, inputs }
|
|
133
134
|
);
|
|
134
135
|
};
|
|
135
136
|
|
|
136
137
|
// Destruct
|
|
137
138
|
const {
|
|
138
139
|
getItemStyle = (index, theme) => ({
|
|
139
|
-
padding: theme.spacing(1),
|
|
140
|
+
padding: [theme.spacing(1.5), theme.spacing(1)].join(' '),
|
|
140
141
|
background:
|
|
141
142
|
index % 2 === 0
|
|
142
143
|
? theme.palette.grey[100]
|
|
@@ -152,23 +153,26 @@ export function AuditDisplay(props: AuditDisplayProps) {
|
|
|
152
153
|
onClick={() => showDataComparison(data.changes!)}
|
|
153
154
|
sx={{
|
|
154
155
|
marginLeft: theme.spacing(1),
|
|
156
|
+
marginTop: theme.spacing(-0.5),
|
|
155
157
|
float: 'right'
|
|
156
158
|
}}
|
|
157
159
|
>
|
|
158
160
|
{dataComparisonLabel}
|
|
159
161
|
</Button>
|
|
160
162
|
)}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
<Typography>
|
|
164
|
+
{formatDate(data.creation) +
|
|
165
|
+
', [' +
|
|
166
|
+
getLabel(data.action) +
|
|
167
|
+
'], ' +
|
|
168
|
+
data.user}
|
|
169
|
+
</Typography>
|
|
166
170
|
</React.Fragment>
|
|
167
171
|
);
|
|
168
172
|
},
|
|
169
173
|
headerTitle = (
|
|
170
174
|
<React.Fragment>
|
|
171
|
-
{getLabel('audits')}
|
|
175
|
+
<Typography>{getLabel('audits')}</Typography>
|
|
172
176
|
<Divider />
|
|
173
177
|
</React.Fragment>
|
|
174
178
|
),
|
package/src/mu/ComboBox.tsx
CHANGED
|
@@ -13,6 +13,11 @@ import { SearchField } from './SearchField';
|
|
|
13
13
|
*/
|
|
14
14
|
export interface ComboBoxProps<T extends {}>
|
|
15
15
|
extends AutocompleteExtendedProps<T> {
|
|
16
|
+
/**
|
|
17
|
+
* Auto add blank item
|
|
18
|
+
*/
|
|
19
|
+
autoAddBlankItem?: boolean;
|
|
20
|
+
|
|
16
21
|
/**
|
|
17
22
|
* Data readonly
|
|
18
23
|
*/
|
|
@@ -48,6 +53,7 @@ export function ComboBox<T extends {} = IdLabelDto>(props: ComboBoxProps<T>) {
|
|
|
48
53
|
// Destruct
|
|
49
54
|
const {
|
|
50
55
|
search = false,
|
|
56
|
+
autoAddBlankItem = search,
|
|
51
57
|
idField = 'id',
|
|
52
58
|
idValue,
|
|
53
59
|
inputError,
|
|
@@ -156,7 +162,7 @@ export function ComboBox<T extends {} = IdLabelDto>(props: ComboBoxProps<T>) {
|
|
|
156
162
|
loadData().then((result) => {
|
|
157
163
|
if (result == null || !isMounted.current) return;
|
|
158
164
|
if (onLoadData) onLoadData(result);
|
|
159
|
-
if (
|
|
165
|
+
if (autoAddBlankItem) {
|
|
160
166
|
SharedUtils.addBlankItem(result, idField, labelField);
|
|
161
167
|
}
|
|
162
168
|
setOptions(result);
|
package/src/mu/SelectBool.tsx
CHANGED
|
@@ -17,7 +17,7 @@ export interface SelectBoolProps
|
|
|
17
17
|
*/
|
|
18
18
|
export function SelectBool(props: SelectBoolProps) {
|
|
19
19
|
// Destruct
|
|
20
|
-
const { search = true, ...rest } = props;
|
|
20
|
+
const { search = true, autoAddBlankItem = search, ...rest } = props;
|
|
21
21
|
|
|
22
22
|
// Options
|
|
23
23
|
const options: IdLabelDto<string>[] = [
|
|
@@ -25,7 +25,7 @@ export function SelectBool(props: SelectBoolProps) {
|
|
|
25
25
|
{ id: 'true', label: globalApp.get('yes')! }
|
|
26
26
|
];
|
|
27
27
|
|
|
28
|
-
if (
|
|
28
|
+
if (autoAddBlankItem) Utils.addBlankItem(options);
|
|
29
29
|
|
|
30
30
|
// Layout
|
|
31
31
|
return <SelectEx options={options} search={search} {...rest} />;
|
package/src/mu/SelectEx.tsx
CHANGED
|
@@ -21,6 +21,11 @@ import { Utils } from '@etsoo/shared';
|
|
|
21
21
|
*/
|
|
22
22
|
export interface SelectExProps<T extends {}>
|
|
23
23
|
extends Omit<SelectProps, 'labelId' | 'input' | 'native'> {
|
|
24
|
+
/**
|
|
25
|
+
* Auto add blank item
|
|
26
|
+
*/
|
|
27
|
+
autoAddBlankItem?: boolean;
|
|
28
|
+
|
|
24
29
|
/**
|
|
25
30
|
* Id field, default is id
|
|
26
31
|
*/
|
|
@@ -82,6 +87,7 @@ export function SelectEx<T extends {} = IdLabelDto>(props: SelectExProps<T>) {
|
|
|
82
87
|
name,
|
|
83
88
|
options = [],
|
|
84
89
|
search = false,
|
|
90
|
+
autoAddBlankItem = search,
|
|
85
91
|
value,
|
|
86
92
|
onChange,
|
|
87
93
|
...rest
|
|
@@ -172,7 +178,7 @@ export function SelectEx<T extends {} = IdLabelDto>(props: SelectExProps<T>) {
|
|
|
172
178
|
loadData().then((result) => {
|
|
173
179
|
if (result == null || !isMounted.current) return;
|
|
174
180
|
if (onLoadData) onLoadData(result);
|
|
175
|
-
if (
|
|
181
|
+
if (autoAddBlankItem) {
|
|
176
182
|
Utils.addBlankItem(result, idField, labelField);
|
|
177
183
|
}
|
|
178
184
|
setOptions(result);
|
|
@@ -103,6 +103,8 @@ function getItemField<T>(
|
|
|
103
103
|
itemLabel: React.ReactNode,
|
|
104
104
|
gridProps: GridProps = {};
|
|
105
105
|
|
|
106
|
+
let xs = 6;
|
|
107
|
+
|
|
106
108
|
if (Array.isArray(field)) {
|
|
107
109
|
const [fieldData, fieldType, renderProps] = field;
|
|
108
110
|
itemData = GridDataFormat(data[fieldData], fieldType, renderProps);
|
|
@@ -114,7 +116,7 @@ function getItemField<T>(
|
|
|
114
116
|
dataType,
|
|
115
117
|
label: fieldLabel,
|
|
116
118
|
renderProps,
|
|
117
|
-
singleRow
|
|
119
|
+
singleRow,
|
|
118
120
|
...rest
|
|
119
121
|
} = field;
|
|
120
122
|
|
|
@@ -123,6 +125,8 @@ function getItemField<T>(
|
|
|
123
125
|
...(singleRow && { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 })
|
|
124
126
|
};
|
|
125
127
|
|
|
128
|
+
if (singleRow === false) xs = 12;
|
|
129
|
+
|
|
126
130
|
// Field data
|
|
127
131
|
if (typeof fieldData === 'function') itemData = fieldData(data);
|
|
128
132
|
else if (dataType == null) itemData = formatItemData(data[fieldData]);
|
|
@@ -144,7 +148,7 @@ function getItemField<T>(
|
|
|
144
148
|
return [
|
|
145
149
|
itemData,
|
|
146
150
|
itemLabel,
|
|
147
|
-
{ xs
|
|
151
|
+
{ xs, sm: 6, md: 6, lg: 4, xl: 3, ...gridProps }
|
|
148
152
|
];
|
|
149
153
|
}
|
|
150
154
|
|