@etsoo/materialui 1.2.16 → 1.2.17

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/Tiplist.js CHANGED
@@ -3,8 +3,8 @@ import { DataTypes } from "@etsoo/shared";
3
3
  import { Autocomplete } from "@mui/material";
4
4
  import React from "react";
5
5
  import { globalApp } from "./app/ReactApp";
6
- import { InputField } from "./InputField";
7
6
  import { SearchField } from "./SearchField";
7
+ import { InputField } from "./InputField";
8
8
  /**
9
9
  * Tiplist
10
10
  * @param props Props
@@ -34,7 +34,9 @@ export function Tiplist(props) {
34
34
  value: null
35
35
  });
36
36
  // Input value
37
- const inputValue = React.useMemo(() => states.value && states.value[idField], [states.value]);
37
+ const inputValue = React.useMemo(() => states.value && typeof states.value === "object"
38
+ ? states.value[idField]
39
+ : undefined, [states.value]);
38
40
  React.useEffect(() => {
39
41
  if (localValue != null)
40
42
  stateUpdate({ value: localValue });
@@ -117,20 +119,25 @@ export function Tiplist(props) {
117
119
  }
118
120
  }
119
121
  };
120
- if (localIdValue != null && localIdValue !== "") {
121
- if (state.idLoaded) {
122
- // Set default
123
- if (!state.idSet && states.options.length == 1) {
124
- stateUpdate({ value: states.options[0] });
125
- state.idSet = true;
126
- }
122
+ React.useEffect(() => {
123
+ if (localIdValue == null && inputValue != null) {
124
+ setInputValue(null);
127
125
  }
128
- else {
129
- // Load id data
130
- loadDataDirect(undefined, localIdValue);
131
- state.idLoaded = true;
126
+ else if (localIdValue != null && localIdValue !== "") {
127
+ if (state.idLoaded) {
128
+ // Set default
129
+ if (!state.idSet && states.options.length == 1) {
130
+ stateUpdate({ value: states.options[0] });
131
+ state.idSet = true;
132
+ }
133
+ }
134
+ else {
135
+ // Load id data
136
+ loadDataDirect(undefined, localIdValue);
137
+ state.idLoaded = true;
138
+ }
132
139
  }
133
- }
140
+ }, [state, localIdValue]);
134
141
  React.useEffect(() => {
135
142
  return () => {
136
143
  isMounted.current = false;
package/lib/TiplistPro.js CHANGED
@@ -109,20 +109,25 @@ export function TiplistPro(props) {
109
109
  }
110
110
  }
111
111
  };
112
- if (localIdValue != null && localIdValue !== "") {
113
- if (state.idLoaded) {
114
- // Set default
115
- if (!state.idSet && states.options.length == 1) {
116
- stateUpdate({ value: states.options[0] });
117
- state.idSet = true;
118
- }
112
+ React.useEffect(() => {
113
+ if (localIdValue == null && inputValue != null) {
114
+ setInputValue(null);
119
115
  }
120
- else {
121
- // Load id data
122
- loadDataDirect(undefined, localIdValue);
123
- state.idLoaded = true;
116
+ else if (localIdValue != null && localIdValue !== "") {
117
+ if (state.idLoaded) {
118
+ // Set default
119
+ if (!state.idSet && states.options.length == 1) {
120
+ stateUpdate({ value: states.options[0] });
121
+ state.idSet = true;
122
+ }
123
+ }
124
+ else {
125
+ // Load id data
126
+ loadDataDirect(undefined, localIdValue);
127
+ state.idLoaded = true;
128
+ }
124
129
  }
125
- }
130
+ }, [state, localIdValue]);
126
131
  React.useEffect(() => {
127
132
  return () => {
128
133
  isMounted.current = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.2.16",
3
+ "version": "1.2.17",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,9 +50,9 @@
50
50
  "@emotion/css": "^11.10.8",
51
51
  "@emotion/react": "^11.10.8",
52
52
  "@emotion/styled": "^11.10.8",
53
- "@etsoo/appscript": "^1.3.96",
53
+ "@etsoo/appscript": "^1.3.97",
54
54
  "@etsoo/notificationbase": "^1.1.24",
55
- "@etsoo/react": "^1.6.70",
55
+ "@etsoo/react": "^1.6.71",
56
56
  "@etsoo/shared": "^1.2.1",
57
57
  "@mui/icons-material": "^5.11.16",
58
58
  "@mui/material": "^5.12.2",
@@ -71,17 +71,17 @@
71
71
  "react-dom": "^18.2.0",
72
72
  "react-draggable": "^4.4.5",
73
73
  "react-imask": "^6.6.1",
74
- "react-router-dom": "^6.10.0",
74
+ "react-router-dom": "^6.11.0",
75
75
  "react-window": "^1.8.9"
76
76
  },
77
77
  "devDependencies": {
78
- "@babel/cli": "^7.21.0",
79
- "@babel/core": "^7.21.4",
78
+ "@babel/cli": "^7.21.5",
79
+ "@babel/core": "^7.21.5",
80
80
  "@babel/plugin-transform-runtime": "^7.21.4",
81
- "@babel/preset-env": "^7.21.4",
81
+ "@babel/preset-env": "^7.21.5",
82
82
  "@babel/preset-react": "^7.18.6",
83
- "@babel/preset-typescript": "^7.21.4",
84
- "@babel/runtime-corejs3": "^7.21.0",
83
+ "@babel/preset-typescript": "^7.21.5",
84
+ "@babel/runtime-corejs3": "^7.21.5",
85
85
  "@testing-library/jest-dom": "^5.16.5",
86
86
  "@testing-library/react": "^14.0.0",
87
87
  "@types/jest": "^29.5.1",
package/src/Tiplist.tsx CHANGED
@@ -2,10 +2,10 @@ import { ReactUtils, useDelayedExecutor } from "@etsoo/react";
2
2
  import { DataTypes, IdDefaultType, ListType } from "@etsoo/shared";
3
3
  import { Autocomplete, AutocompleteRenderInputParams } from "@mui/material";
4
4
  import React from "react";
5
- import { globalApp } from "./app/ReactApp";
6
5
  import { AutocompleteExtendedProps } from "./AutocompleteExtendedProps";
7
- import { InputField } from "./InputField";
6
+ import { globalApp } from "./app/ReactApp";
8
7
  import { SearchField } from "./SearchField";
8
+ import { InputField } from "./InputField";
9
9
 
10
10
  /**
11
11
  * Tiplist props
@@ -118,7 +118,10 @@ export function Tiplist<
118
118
 
119
119
  // Input value
120
120
  const inputValue = React.useMemo(
121
- () => states.value && states.value[idField],
121
+ () =>
122
+ states.value && typeof states.value === "object"
123
+ ? states.value[idField]
124
+ : undefined,
122
125
  [states.value]
123
126
  );
124
127
 
@@ -222,19 +225,23 @@ export function Tiplist<
222
225
  }
223
226
  };
224
227
 
225
- if (localIdValue != null && (localIdValue as any) !== "") {
226
- if (state.idLoaded) {
227
- // Set default
228
- if (!state.idSet && states.options.length == 1) {
229
- stateUpdate({ value: states.options[0] });
230
- state.idSet = true;
228
+ React.useEffect(() => {
229
+ if (localIdValue == null && inputValue != null) {
230
+ setInputValue(null);
231
+ } else if (localIdValue != null && (localIdValue as any) !== "") {
232
+ if (state.idLoaded) {
233
+ // Set default
234
+ if (!state.idSet && states.options.length == 1) {
235
+ stateUpdate({ value: states.options[0] });
236
+ state.idSet = true;
237
+ }
238
+ } else {
239
+ // Load id data
240
+ loadDataDirect(undefined, localIdValue);
241
+ state.idLoaded = true;
231
242
  }
232
- } else {
233
- // Load id data
234
- loadDataDirect(undefined, localIdValue);
235
- state.idLoaded = true;
236
243
  }
237
- }
244
+ }, [state, localIdValue]);
238
245
 
239
246
  React.useEffect(() => {
240
247
  return () => {
@@ -235,19 +235,23 @@ export function TiplistPro<T extends ListType2 = ListType2>(
235
235
  }
236
236
  };
237
237
 
238
- if (localIdValue != null && (localIdValue as any) !== "") {
239
- if (state.idLoaded) {
240
- // Set default
241
- if (!state.idSet && states.options.length == 1) {
242
- stateUpdate({ value: states.options[0] });
243
- state.idSet = true;
238
+ React.useEffect(() => {
239
+ if (localIdValue == null && inputValue != null) {
240
+ setInputValue(null);
241
+ } else if (localIdValue != null && (localIdValue as any) !== "") {
242
+ if (state.idLoaded) {
243
+ // Set default
244
+ if (!state.idSet && states.options.length == 1) {
245
+ stateUpdate({ value: states.options[0] });
246
+ state.idSet = true;
247
+ }
248
+ } else {
249
+ // Load id data
250
+ loadDataDirect(undefined, localIdValue);
251
+ state.idLoaded = true;
244
252
  }
245
- } else {
246
- // Load id data
247
- loadDataDirect(undefined, localIdValue);
248
- state.idLoaded = true;
249
253
  }
250
- }
254
+ }, [state, localIdValue]);
251
255
 
252
256
  React.useEffect(() => {
253
257
  return () => {