@etsoo/react 1.4.75 → 1.4.76

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.
@@ -33,7 +33,7 @@ export interface ScrollerGridProps<T> extends GridLoader<T>, Omit<VariableSizeGr
33
33
  * Id field
34
34
  * @default id
35
35
  */
36
- idField?: keyof T;
36
+ idField?: string & keyof T;
37
37
  /**
38
38
  * Item renderer
39
39
  */
@@ -8,7 +8,7 @@ export interface AutocompleteExtendedProps<T extends Record<string, unknown>> ex
8
8
  /**
9
9
  * Id field, default is id
10
10
  */
11
- idField?: keyof T;
11
+ idField?: string & keyof T;
12
12
  /**
13
13
  * Id value
14
14
  */
@@ -12,7 +12,7 @@ export interface ComboBoxProps<T extends {}> extends AutocompleteExtendedProps<T
12
12
  /**
13
13
  * Label field
14
14
  */
15
- labelField?: keyof T;
15
+ labelField?: string & keyof T;
16
16
  /**
17
17
  * Load data callback
18
18
  */
@@ -31,7 +31,7 @@ export interface DnDListProps<D extends {}, E extends React.ElementType> {
31
31
  /**
32
32
  * Label field
33
33
  */
34
- labelField: keyof D;
34
+ labelField: string & keyof D;
35
35
  /**
36
36
  * Load data
37
37
  */
@@ -10,11 +10,11 @@ export interface ItemListProps<T extends Record<string, unknown>> {
10
10
  /**
11
11
  * Id field name
12
12
  */
13
- idField?: keyof T;
13
+ idField?: string & keyof T;
14
14
  /**
15
15
  * Label field name or callback
16
16
  */
17
- labelField?: keyof T | ((item: T) => string);
17
+ labelField?: (string & keyof T) | ((item: T) => string);
18
18
  /**
19
19
  * Button icon
20
20
  */
@@ -17,7 +17,7 @@ export interface OptionGroupProps<T extends Record<string, any> = IdLabelDto, D
17
17
  /**
18
18
  * Id field, default is id
19
19
  */
20
- idField?: keyof T;
20
+ idField?: string & keyof T;
21
21
  /**
22
22
  * Label
23
23
  */
@@ -25,7 +25,7 @@ export interface OptionGroupProps<T extends Record<string, any> = IdLabelDto, D
25
25
  /**
26
26
  * Label field, default is label
27
27
  */
28
- labelField?: keyof T;
28
+ labelField?: string & keyof T;
29
29
  /**
30
30
  * Multiple choose item
31
31
  */
@@ -40,7 +40,7 @@ export interface ScrollerListExProps<T> extends Omit<ScrollerListProps<T>, 'item
40
40
  /**
41
41
  * Id field
42
42
  */
43
- idField?: keyof T;
43
+ idField?: string & keyof T;
44
44
  /**
45
45
  * Inner item renderer
46
46
  */
@@ -8,7 +8,7 @@ export interface SelectExProps<T extends {}> extends Omit<SelectProps, 'labelId'
8
8
  /**
9
9
  * Id field, default is id
10
10
  */
11
- idField?: keyof T;
11
+ idField?: string & keyof T;
12
12
  /**
13
13
  * Item icon renderer
14
14
  */
@@ -16,7 +16,7 @@ export interface SelectExProps<T extends {}> extends Omit<SelectProps, 'labelId'
16
16
  /**
17
17
  * Label field, default is label
18
18
  */
19
- labelField?: ((option: T) => string) | keyof T;
19
+ labelField?: ((option: T) => string) | (string & keyof T);
20
20
  /**
21
21
  * Load data callback
22
22
  */
@@ -35,7 +35,7 @@ export interface TableExProps<T extends Record<string, any>> extends TableProps,
35
35
  /**
36
36
  * Id field
37
37
  */
38
- idField?: keyof T;
38
+ idField?: string & keyof T;
39
39
  /**
40
40
  * Max height
41
41
  */
package/lib/mu/Tiplist.js CHANGED
@@ -10,7 +10,6 @@ import { SearchField } from './SearchField';
10
10
  * @returns Component
11
11
  */
12
12
  export function Tiplist(props) {
13
- var _a;
14
13
  // Destruct
15
14
  const { search = false, idField = 'id', idValue, inputAutoComplete = 'off', inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, label, loadData, defaultValue, value, name, readOnly, onChange, openOnFocus = true, sx = { minWidth: '180px' }, ...rest } = props;
16
15
  // Value input ref
@@ -30,6 +29,8 @@ export function Tiplist(props) {
30
29
  options: [],
31
30
  value: null
32
31
  });
32
+ // Input value
33
+ const inputValue = React.useMemo(() => states.value && Reflect.get(states.value, idField), [states.value]);
33
34
  React.useEffect(() => {
34
35
  if (localValue != null)
35
36
  stateUpdate({ value: localValue });
@@ -134,7 +135,7 @@ export function Tiplist(props) {
134
135
  }, []);
135
136
  // Layout
136
137
  return (React.createElement("div", null,
137
- React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: (_a = (states.value && Reflect.get(states.value, idField))) !== null && _a !== void 0 ? _a : '', readOnly: true, onChange: inputOnChange }),
138
+ React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: inputValue !== null && inputValue !== void 0 ? inputValue : '', readOnly: true, onChange: inputOnChange }),
138
139
  React.createElement(Autocomplete, { filterOptions: (options, _state) => options, value: states.value, options: states.options, onChange: (event, value, reason, details) => {
139
140
  // Set value
140
141
  setInputValue(value);
@@ -9,7 +9,7 @@ export interface ViewPageField<T extends {}> extends GridProps {
9
9
  /**
10
10
  * Data field
11
11
  */
12
- data: keyof T | ((item: T) => React.ReactNode);
12
+ data: (string & keyof T) | ((item: T) => React.ReactNode);
13
13
  /**
14
14
  * Data type
15
15
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.4.75",
3
+ "version": "1.4.76",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -54,7 +54,7 @@ export interface ScrollerGridProps<T>
54
54
  * Id field
55
55
  * @default id
56
56
  */
57
- idField?: keyof T;
57
+ idField?: string & keyof T;
58
58
 
59
59
  /**
60
60
  * Item renderer
@@ -13,7 +13,7 @@ export interface AutocompleteExtendedProps<T extends Record<string, unknown>>
13
13
  /**
14
14
  * Id field, default is id
15
15
  */
16
- idField?: keyof T;
16
+ idField?: string & keyof T;
17
17
 
18
18
  /**
19
19
  * Id value
@@ -20,7 +20,7 @@ export interface ComboBoxProps<T extends {}>
20
20
  /**
21
21
  * Label field
22
22
  */
23
- labelField?: keyof T;
23
+ labelField?: string & keyof T;
24
24
 
25
25
  /**
26
26
  * Load data callback
@@ -50,7 +50,7 @@ export interface DnDListProps<D extends {}, E extends React.ElementType> {
50
50
  /**
51
51
  * Label field
52
52
  */
53
- labelField: keyof D;
53
+ labelField: string & keyof D;
54
54
 
55
55
  /**
56
56
  * Load data
@@ -22,12 +22,12 @@ export interface ItemListProps<T extends Record<string, unknown>> {
22
22
  /**
23
23
  * Id field name
24
24
  */
25
- idField?: keyof T;
25
+ idField?: string & keyof T;
26
26
 
27
27
  /**
28
28
  * Label field name or callback
29
29
  */
30
- labelField?: keyof T | ((item: T) => string);
30
+ labelField?: (string & keyof T) | ((item: T) => string);
31
31
 
32
32
  /**
33
33
  * Button icon
@@ -32,7 +32,7 @@ export interface OptionGroupProps<
32
32
  /**
33
33
  * Id field, default is id
34
34
  */
35
- idField?: keyof T;
35
+ idField?: string & keyof T;
36
36
 
37
37
  /**
38
38
  * Label
@@ -42,7 +42,7 @@ export interface OptionGroupProps<
42
42
  /**
43
43
  * Label field, default is label
44
44
  */
45
- labelField?: keyof T;
45
+ labelField?: string & keyof T;
46
46
 
47
47
  /**
48
48
  * Multiple choose item
@@ -127,7 +127,7 @@ export interface ScrollerListExProps<T>
127
127
  /**
128
128
  * Id field
129
129
  */
130
- idField?: keyof T;
130
+ idField?: string & keyof T;
131
131
 
132
132
  /**
133
133
  * Inner item renderer
@@ -23,7 +23,7 @@ export interface SelectExProps<T extends {}>
23
23
  /**
24
24
  * Id field, default is id
25
25
  */
26
- idField?: keyof T;
26
+ idField?: string & keyof T;
27
27
 
28
28
  /**
29
29
  * Item icon renderer
@@ -33,7 +33,7 @@ export interface SelectExProps<T extends {}>
33
33
  /**
34
34
  * Label field, default is label
35
35
  */
36
- labelField?: ((option: T) => string) | keyof T;
36
+ labelField?: ((option: T) => string) | (string & keyof T);
37
37
 
38
38
  /**
39
39
  * Load data callback
@@ -68,7 +68,7 @@ export interface TableExProps<T extends Record<string, any>>
68
68
  /**
69
69
  * Id field
70
70
  */
71
- idField?: keyof T;
71
+ idField?: string & keyof T;
72
72
 
73
73
  /**
74
74
  * Max height
@@ -107,7 +107,7 @@ export function TableEx<T extends Record<string, unknown>>(
107
107
  // Theme
108
108
  const theme = useTheme();
109
109
 
110
- type keyType = keyof T;
110
+ type keyType = string & keyof T;
111
111
 
112
112
  // Destruct
113
113
  const {
@@ -83,6 +83,12 @@ export function Tiplist<T extends {} = IdLabelDto>(props: TiplistProps<T>) {
83
83
  }
84
84
  );
85
85
 
86
+ // Input value
87
+ const inputValue = React.useMemo(
88
+ () => states.value && Reflect.get(states.value, idField),
89
+ [states.value]
90
+ );
91
+
86
92
  React.useEffect(() => {
87
93
  if (localValue != null) stateUpdate({ value: localValue });
88
94
  }, [localValue]);
@@ -219,9 +225,7 @@ export function Tiplist<T extends {} = IdLabelDto>(props: TiplistProps<T>) {
219
225
  type="text"
220
226
  style={{ display: 'none' }}
221
227
  name={name}
222
- value={
223
- (states.value && Reflect.get(states.value, idField)) ?? ''
224
- }
228
+ value={inputValue ?? ''}
225
229
  readOnly
226
230
  onChange={inputOnChange}
227
231
  />
@@ -24,7 +24,7 @@ export interface ViewPageField<T extends {}> extends GridProps {
24
24
  /**
25
25
  * Data field
26
26
  */
27
- data: keyof T | ((item: T) => React.ReactNode);
27
+ data: (string & keyof T) | ((item: T) => React.ReactNode);
28
28
 
29
29
  /**
30
30
  * Data type