@visns-studio/visns-components 5.0.22 → 5.0.23

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/package.json CHANGED
@@ -77,7 +77,7 @@
77
77
  "react-dom": "^17.0.0 || ^18.0.0"
78
78
  },
79
79
  "name": "@visns-studio/visns-components",
80
- "version": "5.0.22",
80
+ "version": "5.0.23",
81
81
  "description": "Various packages to assist in the development of our Custom Applications.",
82
82
  "main": "src/index.js",
83
83
  "files": [
@@ -166,29 +166,36 @@ function Field({
166
166
  if (_inputValue > 0) {
167
167
  if (Array.isArray(s.child)) {
168
168
  s.child.forEach((a) => {
169
- filter = {
170
- where: [
171
- {
172
- id: s.id,
173
- value: _inputValue,
174
- },
175
- ],
176
- };
169
+ if (a) {
170
+ filter = {
171
+ where: [
172
+ {
173
+ id: s.id,
174
+ value: _inputValue,
175
+ },
176
+ ],
177
+ };
178
+
179
+ if (a.fields) {
180
+ filter.fields = a.fields;
181
+ }
177
182
 
178
- if (a.fields) {
179
- filter.fields = a.fields;
180
- }
183
+ if (a.orderBy) {
184
+ filter.orderBy = a.orderBy;
185
+ }
181
186
 
182
- if (a.orderBy) {
183
- filter.orderBy = a.orderBy;
187
+ CustomFetch(
188
+ a.url,
189
+ 'POST',
190
+ filter,
191
+ function (result) {
192
+ childDropdownCallback({
193
+ id: a.id,
194
+ data: result.data,
195
+ });
196
+ }
197
+ );
184
198
  }
185
-
186
- CustomFetch(a.url, 'POST', filter, function (result) {
187
- childDropdownCallback({
188
- id: a.id,
189
- data: result.data,
190
- });
191
- });
192
199
  });
193
200
  } else {
194
201
  filter = {
@@ -208,8 +215,8 @@ function Field({
208
215
  filter.orderBy = s.orderBy;
209
216
  }
210
217
 
211
- if (a.where) {
212
- forEach(a.where, (w) => {
218
+ if (s.where) {
219
+ forEach(s.where, (w) => {
213
220
  filter.where.push(w);
214
221
  });
215
222
  }
@@ -284,7 +284,7 @@ function Form({
284
284
  });
285
285
  };
286
286
 
287
- // Switch cases to handle different actions
287
+ // // Switch cases to handle different actions
288
288
  switch (action.action) {
289
289
  case 'select-option':
290
290
  case 'create-option': // New case to handle create-option
@@ -22,13 +22,27 @@ function MultiSelect({
22
22
  const prevInputValueRef = useRef();
23
23
 
24
24
  useEffect(() => {
25
- const _options = Array.isArray(options)
26
- ? options.map((a) => ({
27
- value: a.id,
28
- label: a.label || a.name || a.description || 'Unknown',
29
- ...a,
30
- }))
31
- : [];
25
+ const _options =
26
+ Array.isArray(options) && options.length > 0
27
+ ? options.map((a) => {
28
+ if (a && typeof a === 'object') {
29
+ return {
30
+ value: a.id || 'unknown-id',
31
+ label:
32
+ a.label ||
33
+ a.name ||
34
+ a.description ||
35
+ 'Unknown',
36
+ ...a,
37
+ };
38
+ }
39
+ console.warn('Invalid item in options array:', a);
40
+ return {
41
+ value: 'unknown-id',
42
+ label: 'Unknown',
43
+ };
44
+ })
45
+ : [];
32
46
  setSelectOptions(_options);
33
47
  }, [options]);
34
48
 
@@ -57,7 +71,6 @@ function MultiSelect({
57
71
  },
58
72
  ]
59
73
  : [];
60
-
61
74
  setSelectValue(_values);
62
75
  prevInputValueRef.current = inputValue;
63
76
  }