@etsoo/react 1.1.90 → 1.1.94
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.d.ts +6 -2
- package/lib/mu/ComboBox.js +3 -3
- package/lib/mu/NotifierMU.js +9 -6
- package/lib/mu/Tiplist.d.ts +6 -2
- package/lib/mu/Tiplist.js +2 -2
- package/lib/states/PageState.d.ts +1 -1
- package/lib/states/PageState.js +1 -1
- package/package.json +1 -1
- package/src/mu/ComboBox.tsx +25 -5
- package/src/mu/NotifierMU.tsx +14 -11
- package/src/mu/Tiplist.tsx +11 -3
- package/src/states/PageState.ts +2 -2
package/lib/mu/ComboBox.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DataTypes } from '@etsoo/shared';
|
|
3
|
-
import { AutocompleteProps } from '@mui/material';
|
|
3
|
+
import { AutocompleteProps, TextFieldProps } from '@mui/material';
|
|
4
4
|
/**
|
|
5
5
|
* ComboBox props
|
|
6
6
|
*/
|
|
7
|
-
export interface ComboBoxProps<T extends Record<string, any>> extends Omit<AutocompleteProps<T, undefined,
|
|
7
|
+
export interface ComboBoxProps<T extends Record<string, any>> extends Omit<AutocompleteProps<T, undefined, boolean, false>, 'renderInput'> {
|
|
8
8
|
/**
|
|
9
9
|
* Id field, default is id
|
|
10
10
|
*/
|
|
@@ -13,6 +13,10 @@ export interface ComboBoxProps<T extends Record<string, any>> extends Omit<Autoc
|
|
|
13
13
|
* Id value
|
|
14
14
|
*/
|
|
15
15
|
idValue?: DataTypes.IdType;
|
|
16
|
+
/**
|
|
17
|
+
* Input props
|
|
18
|
+
*/
|
|
19
|
+
inputProps?: TextFieldProps;
|
|
16
20
|
/**
|
|
17
21
|
* Label of the field
|
|
18
22
|
*/
|
package/lib/mu/ComboBox.js
CHANGED
|
@@ -10,7 +10,7 @@ import { SearchField } from './SearchField';
|
|
|
10
10
|
*/
|
|
11
11
|
export function ComboBox(props) {
|
|
12
12
|
// Destruct
|
|
13
|
-
const { search = false, idField = 'id', idValue, defaultValue, label, name, options, readOnly, onChange, value, sx = { minWidth: '120px' }, ...rest } = props;
|
|
13
|
+
const { search = false, idField = 'id', inputProps, idValue, defaultValue, label, name, options, disableClearable = true, readOnly = true, onChange, value, sx = { minWidth: '120px' }, ...rest } = props;
|
|
14
14
|
// Value input ref
|
|
15
15
|
const inputRef = React.createRef();
|
|
16
16
|
// Local default value
|
|
@@ -34,7 +34,7 @@ export function ComboBox(props) {
|
|
|
34
34
|
// Layout
|
|
35
35
|
return (React.createElement("div", null,
|
|
36
36
|
React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, defaultValue: localIdValue }),
|
|
37
|
-
React.createElement(Autocomplete, { defaultValue: localValue, isOptionEqualToValue: (option, value) => option[idField] === value[idField], onChange: (event, value, reason, details) => {
|
|
37
|
+
React.createElement(Autocomplete, { defaultValue: localValue, disableClearable: disableClearable, isOptionEqualToValue: (option, value) => option[idField] === value[idField], onChange: (event, value, reason, details) => {
|
|
38
38
|
// Input value
|
|
39
39
|
const input = inputRef.current;
|
|
40
40
|
if (input) {
|
|
@@ -50,5 +50,5 @@ export function ComboBox(props) {
|
|
|
50
50
|
// Custom
|
|
51
51
|
if (onChange != null)
|
|
52
52
|
onChange(event, value, reason, details);
|
|
53
|
-
}, sx: sx, renderInput: (params) => search ? (React.createElement(SearchField, { ...addReadOnly(params), label: label })) : (React.createElement(InputField, { ...addReadOnly(params), label: label })), options: options, ...rest })));
|
|
53
|
+
}, sx: sx, renderInput: (params) => search ? (React.createElement(SearchField, { ...inputProps, ...addReadOnly(params), label: label })) : (React.createElement(InputField, { ...inputProps, ...addReadOnly(params), label: label })), options: options, ...rest })));
|
|
54
54
|
}
|
package/lib/mu/NotifierMU.js
CHANGED
|
@@ -24,10 +24,13 @@ const IconDialogTitle = styled(DialogTitle) `
|
|
|
24
24
|
export class NotificationMU extends NotificationReact {
|
|
25
25
|
// On return
|
|
26
26
|
// Dismiss first, then run callback
|
|
27
|
-
returnValue(value) {
|
|
27
|
+
async returnValue(value) {
|
|
28
|
+
if (this.onReturn) {
|
|
29
|
+
const result = await this.onReturn(value);
|
|
30
|
+
if (result === false)
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
28
33
|
this.dismiss();
|
|
29
|
-
if (this.onReturn)
|
|
30
|
-
this.onReturn(value);
|
|
31
34
|
}
|
|
32
35
|
// Create alert
|
|
33
36
|
createAlert(_props, className, classes) {
|
|
@@ -57,7 +60,7 @@ export class NotificationMU extends NotificationReact {
|
|
|
57
60
|
React.createElement(DialogContent, null,
|
|
58
61
|
React.createElement(DialogContentText, null, this.content)),
|
|
59
62
|
React.createElement(DialogActions, null,
|
|
60
|
-
React.createElement(
|
|
63
|
+
React.createElement(LoadingButton, { color: "primary", onClick: async () => await this.returnValue(undefined), autoFocus: true }, labels.alertOK))));
|
|
61
64
|
}
|
|
62
65
|
// Create confirm
|
|
63
66
|
createConfirm(_props, className, classes) {
|
|
@@ -73,8 +76,8 @@ export class NotificationMU extends NotificationReact {
|
|
|
73
76
|
React.createElement(DialogContent, null,
|
|
74
77
|
React.createElement(DialogContentText, null, this.content)),
|
|
75
78
|
React.createElement(DialogActions, null,
|
|
76
|
-
React.createElement(
|
|
77
|
-
React.createElement(
|
|
79
|
+
React.createElement(LoadingButton, { color: "secondary", onClick: async () => await this.returnValue(false) }, noLabel),
|
|
80
|
+
React.createElement(LoadingButton, { color: "primary", onClick: async () => await this.returnValue(true), autoFocus: true }, yesLabel))));
|
|
78
81
|
}
|
|
79
82
|
createMessageColor() {
|
|
80
83
|
if (this.type === NotificationMessageType.Danger)
|
package/lib/mu/Tiplist.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DataTypes } from '@etsoo/shared';
|
|
3
|
-
import { AutocompleteProps } from '@mui/material';
|
|
3
|
+
import { AutocompleteProps, TextFieldProps } from '@mui/material';
|
|
4
4
|
/**
|
|
5
5
|
* Tiplist props
|
|
6
6
|
*/
|
|
7
|
-
export interface TiplistProps<T extends Record<string, any>> extends Omit<AutocompleteProps<T, undefined,
|
|
7
|
+
export interface TiplistProps<T extends Record<string, any>> extends Omit<AutocompleteProps<T, undefined, boolean, false>, 'renderInput' | 'options' | 'open'> {
|
|
8
8
|
/**
|
|
9
9
|
* Id field, default is id
|
|
10
10
|
*/
|
|
@@ -13,6 +13,10 @@ export interface TiplistProps<T extends Record<string, any>> extends Omit<Autoco
|
|
|
13
13
|
* Id value
|
|
14
14
|
*/
|
|
15
15
|
idValue?: DataTypes.IdType;
|
|
16
|
+
/**
|
|
17
|
+
* Input props
|
|
18
|
+
*/
|
|
19
|
+
inputProps?: TextFieldProps;
|
|
16
20
|
/**
|
|
17
21
|
* Label of the field
|
|
18
22
|
*/
|
package/lib/mu/Tiplist.js
CHANGED
|
@@ -10,7 +10,7 @@ import { SearchField } from './SearchField';
|
|
|
10
10
|
*/
|
|
11
11
|
export function Tiplist(props) {
|
|
12
12
|
// Destruct
|
|
13
|
-
const { search = false, idField = 'id', idValue, label, loadData, defaultValue, value, name, readOnly, onChange, sx = { minWidth: '150px' }, ...rest } = props;
|
|
13
|
+
const { search = false, idField = 'id', idValue, inputProps, label, loadData, defaultValue, value, name, readOnly, onChange, sx = { minWidth: '150px' }, ...rest } = props;
|
|
14
14
|
// Value input ref
|
|
15
15
|
const inputRef = React.createRef();
|
|
16
16
|
// Local value
|
|
@@ -149,5 +149,5 @@ export function Tiplist(props) {
|
|
|
149
149
|
open: false,
|
|
150
150
|
...(!states.value && { options: [] })
|
|
151
151
|
});
|
|
152
|
-
}, loading: states.loading, sx: sx, renderInput: (params) => search ? (React.createElement(SearchField, { onChange: changeHandle, readOnly: readOnly,
|
|
152
|
+
}, loading: states.loading, sx: sx, renderInput: (params) => search ? (React.createElement(SearchField, { ...inputProps, onChange: changeHandle, readOnly: readOnly, label: label })) : (React.createElement(InputField, { ...inputProps, onChange: changeHandle, ...addReadOnly(params), label: label })), isOptionEqualToValue: (option, value) => option[idField] === value[idField], ...rest })));
|
|
153
153
|
}
|
package/lib/states/PageState.js
CHANGED
package/package.json
CHANGED
package/src/mu/ComboBox.tsx
CHANGED
|
@@ -2,7 +2,8 @@ import { DataTypes } from '@etsoo/shared';
|
|
|
2
2
|
import {
|
|
3
3
|
Autocomplete,
|
|
4
4
|
AutocompleteProps,
|
|
5
|
-
AutocompleteRenderInputParams
|
|
5
|
+
AutocompleteRenderInputParams,
|
|
6
|
+
TextFieldProps
|
|
6
7
|
} from '@mui/material';
|
|
7
8
|
import React from 'react';
|
|
8
9
|
import { Utils } from '../app/Utils';
|
|
@@ -13,7 +14,10 @@ import { SearchField } from './SearchField';
|
|
|
13
14
|
* ComboBox props
|
|
14
15
|
*/
|
|
15
16
|
export interface ComboBoxProps<T extends Record<string, any>>
|
|
16
|
-
extends Omit<
|
|
17
|
+
extends Omit<
|
|
18
|
+
AutocompleteProps<T, undefined, boolean, false>,
|
|
19
|
+
'renderInput'
|
|
20
|
+
> {
|
|
17
21
|
/**
|
|
18
22
|
* Id field, default is id
|
|
19
23
|
*/
|
|
@@ -24,6 +28,11 @@ export interface ComboBoxProps<T extends Record<string, any>>
|
|
|
24
28
|
*/
|
|
25
29
|
idValue?: DataTypes.IdType;
|
|
26
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Input props
|
|
33
|
+
*/
|
|
34
|
+
inputProps?: TextFieldProps;
|
|
35
|
+
|
|
27
36
|
/**
|
|
28
37
|
* Label of the field
|
|
29
38
|
*/
|
|
@@ -57,12 +66,14 @@ export function ComboBox<T extends Record<string, any>>(
|
|
|
57
66
|
const {
|
|
58
67
|
search = false,
|
|
59
68
|
idField = 'id',
|
|
69
|
+
inputProps,
|
|
60
70
|
idValue,
|
|
61
71
|
defaultValue,
|
|
62
72
|
label,
|
|
63
73
|
name,
|
|
64
74
|
options,
|
|
65
|
-
|
|
75
|
+
disableClearable = true,
|
|
76
|
+
readOnly = true,
|
|
66
77
|
onChange,
|
|
67
78
|
value,
|
|
68
79
|
sx = { minWidth: '120px' },
|
|
@@ -109,6 +120,7 @@ export function ComboBox<T extends Record<string, any>>(
|
|
|
109
120
|
{/* Previous input will reset first, next input trigger change works */}
|
|
110
121
|
<Autocomplete
|
|
111
122
|
defaultValue={localValue}
|
|
123
|
+
disableClearable={disableClearable}
|
|
112
124
|
isOptionEqualToValue={(option: T, value: T) =>
|
|
113
125
|
option[idField] === value[idField]
|
|
114
126
|
}
|
|
@@ -135,9 +147,17 @@ export function ComboBox<T extends Record<string, any>>(
|
|
|
135
147
|
sx={sx}
|
|
136
148
|
renderInput={(params) =>
|
|
137
149
|
search ? (
|
|
138
|
-
<SearchField
|
|
150
|
+
<SearchField
|
|
151
|
+
{...inputProps}
|
|
152
|
+
{...addReadOnly(params)}
|
|
153
|
+
label={label}
|
|
154
|
+
/>
|
|
139
155
|
) : (
|
|
140
|
-
<InputField
|
|
156
|
+
<InputField
|
|
157
|
+
{...inputProps}
|
|
158
|
+
{...addReadOnly(params)}
|
|
159
|
+
label={label}
|
|
160
|
+
/>
|
|
141
161
|
)
|
|
142
162
|
}
|
|
143
163
|
options={options}
|
package/src/mu/NotifierMU.tsx
CHANGED
|
@@ -60,9 +60,12 @@ const IconDialogTitle = styled(DialogTitle)`
|
|
|
60
60
|
export class NotificationMU extends NotificationReact {
|
|
61
61
|
// On return
|
|
62
62
|
// Dismiss first, then run callback
|
|
63
|
-
private returnValue(value: any) {
|
|
63
|
+
private async returnValue(value: any) {
|
|
64
|
+
if (this.onReturn) {
|
|
65
|
+
const result = await this.onReturn(value);
|
|
66
|
+
if (result === false) return;
|
|
67
|
+
}
|
|
64
68
|
this.dismiss();
|
|
65
|
-
if (this.onReturn) this.onReturn(value);
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
// Create alert
|
|
@@ -107,13 +110,13 @@ export class NotificationMU extends NotificationReact {
|
|
|
107
110
|
<DialogContentText>{this.content}</DialogContentText>
|
|
108
111
|
</DialogContent>
|
|
109
112
|
<DialogActions>
|
|
110
|
-
<
|
|
113
|
+
<LoadingButton
|
|
111
114
|
color="primary"
|
|
112
|
-
onClick={() => this.returnValue(undefined)}
|
|
115
|
+
onClick={async () => await this.returnValue(undefined)}
|
|
113
116
|
autoFocus
|
|
114
117
|
>
|
|
115
118
|
{labels.alertOK}
|
|
116
|
-
</
|
|
119
|
+
</LoadingButton>
|
|
117
120
|
</DialogActions>
|
|
118
121
|
</Dialog>
|
|
119
122
|
);
|
|
@@ -149,19 +152,19 @@ export class NotificationMU extends NotificationReact {
|
|
|
149
152
|
<DialogContentText>{this.content}</DialogContentText>
|
|
150
153
|
</DialogContent>
|
|
151
154
|
<DialogActions>
|
|
152
|
-
<
|
|
155
|
+
<LoadingButton
|
|
153
156
|
color="secondary"
|
|
154
|
-
onClick={() => this.returnValue(false)}
|
|
157
|
+
onClick={async () => await this.returnValue(false)}
|
|
155
158
|
>
|
|
156
159
|
{noLabel}
|
|
157
|
-
</
|
|
158
|
-
<
|
|
160
|
+
</LoadingButton>
|
|
161
|
+
<LoadingButton
|
|
159
162
|
color="primary"
|
|
160
|
-
onClick={() => this.returnValue(true)}
|
|
163
|
+
onClick={async () => await this.returnValue(true)}
|
|
161
164
|
autoFocus
|
|
162
165
|
>
|
|
163
166
|
{yesLabel}
|
|
164
|
-
</
|
|
167
|
+
</LoadingButton>
|
|
165
168
|
</DialogActions>
|
|
166
169
|
</Dialog>
|
|
167
170
|
);
|
package/src/mu/Tiplist.tsx
CHANGED
|
@@ -2,7 +2,8 @@ import { DataTypes } from '@etsoo/shared';
|
|
|
2
2
|
import {
|
|
3
3
|
Autocomplete,
|
|
4
4
|
AutocompleteProps,
|
|
5
|
-
AutocompleteRenderInputParams
|
|
5
|
+
AutocompleteRenderInputParams,
|
|
6
|
+
TextFieldProps
|
|
6
7
|
} from '@mui/material';
|
|
7
8
|
import React from 'react';
|
|
8
9
|
import { Utils } from '../app/Utils';
|
|
@@ -14,7 +15,7 @@ import { SearchField } from './SearchField';
|
|
|
14
15
|
*/
|
|
15
16
|
export interface TiplistProps<T extends Record<string, any>>
|
|
16
17
|
extends Omit<
|
|
17
|
-
AutocompleteProps<T, undefined,
|
|
18
|
+
AutocompleteProps<T, undefined, boolean, false>,
|
|
18
19
|
'renderInput' | 'options' | 'open'
|
|
19
20
|
> {
|
|
20
21
|
/**
|
|
@@ -27,6 +28,11 @@ export interface TiplistProps<T extends Record<string, any>>
|
|
|
27
28
|
*/
|
|
28
29
|
idValue?: DataTypes.IdType;
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Input props
|
|
33
|
+
*/
|
|
34
|
+
inputProps?: TextFieldProps;
|
|
35
|
+
|
|
30
36
|
/**
|
|
31
37
|
* Label of the field
|
|
32
38
|
*/
|
|
@@ -75,6 +81,7 @@ export function Tiplist<T extends Record<string, any>>(props: TiplistProps<T>) {
|
|
|
75
81
|
search = false,
|
|
76
82
|
idField = 'id',
|
|
77
83
|
idValue,
|
|
84
|
+
inputProps,
|
|
78
85
|
label,
|
|
79
86
|
loadData,
|
|
80
87
|
defaultValue,
|
|
@@ -286,13 +293,14 @@ export function Tiplist<T extends Record<string, any>>(props: TiplistProps<T>) {
|
|
|
286
293
|
renderInput={(params) =>
|
|
287
294
|
search ? (
|
|
288
295
|
<SearchField
|
|
296
|
+
{...inputProps}
|
|
289
297
|
onChange={changeHandle}
|
|
290
298
|
readOnly={readOnly}
|
|
291
|
-
{...params}
|
|
292
299
|
label={label}
|
|
293
300
|
/>
|
|
294
301
|
) : (
|
|
295
302
|
<InputField
|
|
303
|
+
{...inputProps}
|
|
296
304
|
onChange={changeHandle}
|
|
297
305
|
{...addReadOnly(params)}
|
|
298
306
|
label={label}
|
package/src/states/PageState.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface IPageData extends IState {
|
|
|
9
9
|
/**
|
|
10
10
|
* Page title
|
|
11
11
|
*/
|
|
12
|
-
title
|
|
12
|
+
title?: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -89,7 +89,7 @@ export class PageState<D extends IPageData> {
|
|
|
89
89
|
return state;
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
|
-
{
|
|
92
|
+
{} as D,
|
|
93
93
|
{} as PageCalls<D>
|
|
94
94
|
);
|
|
95
95
|
|