@etsoo/react 1.2.57 → 1.2.58
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 +6 -2
- package/lib/mu/SelectEx.d.ts +2 -2
- package/lib/mu/SelectEx.js +5 -1
- package/lib/mu/Tiplist.js +5 -1
- package/package.json +1 -1
- package/src/mu/ComboBox.tsx +6 -2
- package/src/mu/SelectEx.tsx +7 -5
- package/src/mu/Tiplist.tsx +5 -1
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,
|
|
13
|
+
const { search = false, idField = 'id', idValue, inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, defaultValue, label, labelField = 'label', loadData, onLoadData, name, inputAutoComplete = 'off', options = [], readOnly = true, onChange, value, getOptionLabel = (option) => String(Reflect.get(option, labelField)), sx = { minWidth: '150px' }, ...rest } = props;
|
|
14
14
|
// Value input ref
|
|
15
15
|
const inputRef = React.createRef();
|
|
16
16
|
// Options state
|
|
@@ -27,7 +27,11 @@ export function ComboBox(props) {
|
|
|
27
27
|
const localIdValue = localValue && Reflect.get(localValue, idField);
|
|
28
28
|
// State
|
|
29
29
|
// null for controlled
|
|
30
|
-
const [stateValue, setStateValue] = React.useState(
|
|
30
|
+
const [stateValue, setStateValue] = React.useState(null);
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
if (localValue != null)
|
|
33
|
+
setStateValue(localValue);
|
|
34
|
+
}, [localValue]);
|
|
31
35
|
// Add readOnly
|
|
32
36
|
const addReadOnly = (params) => {
|
|
33
37
|
if (readOnly != null) {
|
package/lib/mu/SelectEx.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { IdLabelDto } from '@etsoo/appscript';
|
|
|
4
4
|
/**
|
|
5
5
|
* Extended select component props
|
|
6
6
|
*/
|
|
7
|
-
export interface SelectExProps<T extends
|
|
7
|
+
export interface SelectExProps<T extends {}> extends Omit<SelectProps, 'labelId' | 'input' | 'native'> {
|
|
8
8
|
/**
|
|
9
9
|
* Id field, default is id
|
|
10
10
|
*/
|
|
@@ -43,4 +43,4 @@ export interface SelectExProps<T extends Record<string, any> = IdLabelDto> exten
|
|
|
43
43
|
* @param props Props
|
|
44
44
|
* @returns Component
|
|
45
45
|
*/
|
|
46
|
-
export declare function SelectEx<T extends
|
|
46
|
+
export declare function SelectEx<T extends {} = IdLabelDto>(props: SelectExProps<T>): JSX.Element;
|
package/lib/mu/SelectEx.js
CHANGED
|
@@ -28,7 +28,11 @@ export function SelectEx(props) {
|
|
|
28
28
|
localValue = valueSource;
|
|
29
29
|
}
|
|
30
30
|
// Value state
|
|
31
|
-
const [valueState, setValueState] = React.useState(
|
|
31
|
+
const [valueState, setValueState] = React.useState(null);
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
if (localValue != null)
|
|
34
|
+
setValueState(localValue);
|
|
35
|
+
}, [localValue]);
|
|
32
36
|
// Label id
|
|
33
37
|
const labelId = `selectex-label-${name}`;
|
|
34
38
|
// Item checked or not
|
package/lib/mu/Tiplist.js
CHANGED
|
@@ -26,8 +26,12 @@ export function Tiplist(props) {
|
|
|
26
26
|
// Loading unknown
|
|
27
27
|
open: false,
|
|
28
28
|
options: [],
|
|
29
|
-
value:
|
|
29
|
+
value: null
|
|
30
30
|
});
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
if (localValue != null)
|
|
33
|
+
stateUpdate({ value: localValue });
|
|
34
|
+
}, [localValue]);
|
|
31
35
|
// State
|
|
32
36
|
const [state] = React.useState({});
|
|
33
37
|
const isMounted = React.useRef(true);
|
package/package.json
CHANGED
package/src/mu/ComboBox.tsx
CHANGED
|
@@ -43,7 +43,6 @@ export function ComboBox<T extends {} = IdLabelDto>(props: ComboBoxProps<T>) {
|
|
|
43
43
|
search = false,
|
|
44
44
|
idField = 'id',
|
|
45
45
|
idValue,
|
|
46
|
-
inputAutoComplete = 'new-region',
|
|
47
46
|
inputError,
|
|
48
47
|
inputHelperText,
|
|
49
48
|
inputMargin,
|
|
@@ -56,6 +55,7 @@ export function ComboBox<T extends {} = IdLabelDto>(props: ComboBoxProps<T>) {
|
|
|
56
55
|
loadData,
|
|
57
56
|
onLoadData,
|
|
58
57
|
name,
|
|
58
|
+
inputAutoComplete = 'off',
|
|
59
59
|
options = [],
|
|
60
60
|
readOnly = true,
|
|
61
61
|
onChange,
|
|
@@ -86,7 +86,11 @@ export function ComboBox<T extends {} = IdLabelDto>(props: ComboBoxProps<T>) {
|
|
|
86
86
|
|
|
87
87
|
// State
|
|
88
88
|
// null for controlled
|
|
89
|
-
const [stateValue, setStateValue] = React.useState(
|
|
89
|
+
const [stateValue, setStateValue] = React.useState<T | null>(null);
|
|
90
|
+
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
if (localValue != null) setStateValue(localValue);
|
|
93
|
+
}, [localValue]);
|
|
90
94
|
|
|
91
95
|
// Add readOnly
|
|
92
96
|
const addReadOnly = (params: AutocompleteRenderInputParams) => {
|
package/src/mu/SelectEx.tsx
CHANGED
|
@@ -18,7 +18,7 @@ import { ListItemRightIcon } from './ListItemRightIcon';
|
|
|
18
18
|
/**
|
|
19
19
|
* Extended select component props
|
|
20
20
|
*/
|
|
21
|
-
export interface SelectExProps<T extends
|
|
21
|
+
export interface SelectExProps<T extends {}>
|
|
22
22
|
extends Omit<SelectProps, 'labelId' | 'input' | 'native'> {
|
|
23
23
|
/**
|
|
24
24
|
* Id field, default is id
|
|
@@ -66,9 +66,7 @@ export interface SelectExProps<T extends Record<string, any> = IdLabelDto>
|
|
|
66
66
|
* @param props Props
|
|
67
67
|
* @returns Component
|
|
68
68
|
*/
|
|
69
|
-
export function SelectEx<T extends
|
|
70
|
-
props: SelectExProps<T>
|
|
71
|
-
) {
|
|
69
|
+
export function SelectEx<T extends {} = IdLabelDto>(props: SelectExProps<T>) {
|
|
72
70
|
// Destruct
|
|
73
71
|
const {
|
|
74
72
|
defaultValue,
|
|
@@ -103,7 +101,11 @@ export function SelectEx<T extends Record<string, any> = IdLabelDto>(
|
|
|
103
101
|
}
|
|
104
102
|
|
|
105
103
|
// Value state
|
|
106
|
-
const [valueState, setValueState] = React.useState(
|
|
104
|
+
const [valueState, setValueState] = React.useState<unknown | null>(null);
|
|
105
|
+
|
|
106
|
+
React.useEffect(() => {
|
|
107
|
+
if (localValue != null) setValueState(localValue);
|
|
108
|
+
}, [localValue]);
|
|
107
109
|
|
|
108
110
|
// Label id
|
|
109
111
|
const labelId = `selectex-label-${name}`;
|
package/src/mu/Tiplist.tsx
CHANGED
|
@@ -78,10 +78,14 @@ export function Tiplist<T extends {} = IdLabelDto>(props: TiplistProps<T>) {
|
|
|
78
78
|
// Loading unknown
|
|
79
79
|
open: false,
|
|
80
80
|
options: [],
|
|
81
|
-
value:
|
|
81
|
+
value: null
|
|
82
82
|
}
|
|
83
83
|
);
|
|
84
84
|
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
if (localValue != null) stateUpdate({ value: localValue });
|
|
87
|
+
}, [localValue]);
|
|
88
|
+
|
|
85
89
|
// State
|
|
86
90
|
const [state] = React.useState<{
|
|
87
91
|
loadDataSeed?: number;
|