@etsoo/materialui 1.2.17 → 1.2.19

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
@@ -123,11 +123,15 @@ export function Tiplist(props) {
123
123
  if (localIdValue == null && inputValue != null) {
124
124
  setInputValue(null);
125
125
  }
126
- else if (localIdValue != null && localIdValue !== "") {
126
+ }, [localIdValue]);
127
+ React.useEffect(() => {
128
+ if (localIdValue != null && localIdValue !== "") {
127
129
  if (state.idLoaded) {
128
130
  // Set default
129
- if (!state.idSet && states.options.length == 1) {
130
- stateUpdate({ value: states.options[0] });
131
+ if (!state.idSet && states.options.length > 0) {
132
+ stateUpdate({
133
+ value: states.options.find((o) => o[idField] === localIdValue)
134
+ });
131
135
  state.idSet = true;
132
136
  }
133
137
  }
@@ -137,7 +141,7 @@ export function Tiplist(props) {
137
141
  state.idLoaded = true;
138
142
  }
139
143
  }
140
- }, [state, localIdValue]);
144
+ }, [state.idLoaded, state.idSet, localIdValue, states.options]);
141
145
  React.useEffect(() => {
142
146
  return () => {
143
147
  isMounted.current = false;
package/lib/TiplistPro.js CHANGED
@@ -113,11 +113,15 @@ export function TiplistPro(props) {
113
113
  if (localIdValue == null && inputValue != null) {
114
114
  setInputValue(null);
115
115
  }
116
- else if (localIdValue != null && localIdValue !== "") {
116
+ }, [localIdValue]);
117
+ React.useEffect(() => {
118
+ if (localIdValue != null && localIdValue !== "") {
117
119
  if (state.idLoaded) {
118
120
  // Set default
119
- if (!state.idSet && states.options.length == 1) {
120
- stateUpdate({ value: states.options[0] });
121
+ if (!state.idSet && states.options.length > 0) {
122
+ stateUpdate({
123
+ value: states.options.find((o) => o.id === localIdValue)
124
+ });
121
125
  state.idSet = true;
122
126
  }
123
127
  }
@@ -127,7 +131,7 @@ export function TiplistPro(props) {
127
131
  state.idLoaded = true;
128
132
  }
129
133
  }
130
- }, [state, localIdValue]);
134
+ }, [state.idLoaded, state.idSet, localIdValue, states.options]);
131
135
  React.useEffect(() => {
132
136
  return () => {
133
137
  isMounted.current = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.2.17",
3
+ "version": "1.2.19",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,7 +50,7 @@
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.97",
53
+ "@etsoo/appscript": "^1.3.98",
54
54
  "@etsoo/notificationbase": "^1.1.24",
55
55
  "@etsoo/react": "^1.6.71",
56
56
  "@etsoo/shared": "^1.2.1",
package/src/Tiplist.tsx CHANGED
@@ -228,11 +228,17 @@ export function Tiplist<
228
228
  React.useEffect(() => {
229
229
  if (localIdValue == null && inputValue != null) {
230
230
  setInputValue(null);
231
- } else if (localIdValue != null && (localIdValue as any) !== "") {
231
+ }
232
+ }, [localIdValue]);
233
+
234
+ React.useEffect(() => {
235
+ if (localIdValue != null && (localIdValue as any) !== "") {
232
236
  if (state.idLoaded) {
233
237
  // Set default
234
- if (!state.idSet && states.options.length == 1) {
235
- stateUpdate({ value: states.options[0] });
238
+ if (!state.idSet && states.options.length > 0) {
239
+ stateUpdate({
240
+ value: states.options.find((o) => o[idField] === localIdValue)
241
+ });
236
242
  state.idSet = true;
237
243
  }
238
244
  } else {
@@ -241,7 +247,7 @@ export function Tiplist<
241
247
  state.idLoaded = true;
242
248
  }
243
249
  }
244
- }, [state, localIdValue]);
250
+ }, [state.idLoaded, state.idSet, localIdValue, states.options]);
245
251
 
246
252
  React.useEffect(() => {
247
253
  return () => {
@@ -238,11 +238,17 @@ export function TiplistPro<T extends ListType2 = ListType2>(
238
238
  React.useEffect(() => {
239
239
  if (localIdValue == null && inputValue != null) {
240
240
  setInputValue(null);
241
- } else if (localIdValue != null && (localIdValue as any) !== "") {
241
+ }
242
+ }, [localIdValue]);
243
+
244
+ React.useEffect(() => {
245
+ if (localIdValue != null && (localIdValue as any) !== "") {
242
246
  if (state.idLoaded) {
243
247
  // Set default
244
- if (!state.idSet && states.options.length == 1) {
245
- stateUpdate({ value: states.options[0] });
248
+ if (!state.idSet && states.options.length > 0) {
249
+ stateUpdate({
250
+ value: states.options.find((o) => o.id === localIdValue)
251
+ });
246
252
  state.idSet = true;
247
253
  }
248
254
  } else {
@@ -251,7 +257,7 @@ export function TiplistPro<T extends ListType2 = ListType2>(
251
257
  state.idLoaded = true;
252
258
  }
253
259
  }
254
- }, [state, localIdValue]);
260
+ }, [state.idLoaded, state.idSet, localIdValue, states.options]);
255
261
 
256
262
  React.useEffect(() => {
257
263
  return () => {