@visns-studio/visns-components 4.1.6 → 4.1.8

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.
@@ -4,32 +4,46 @@ import SelectList from './SelectList';
4
4
  import AsyncSelect from 'react-select/async';
5
5
  import { debounce } from 'lodash';
6
6
 
7
- function VisnsAsyncSelect({ inputValue, onChange, placeholder, settings }) {
7
+ function VisnsAsyncSelect({
8
+ fields = [],
9
+ inputValue,
10
+ onChange,
11
+ placeholder,
12
+ settings,
13
+ }) {
8
14
  const loadSuggestedOptions = useCallback(
9
15
  debounce((inputValue, callback) => {
10
- if (inputValue !== '') {
16
+ if (inputValue.length >= 3) {
11
17
  loadOptions(inputValue).then((options) => callback(options));
18
+ } else {
19
+ callback([]); // Return empty array if input is less than 3 characters
12
20
  }
13
21
  }, 500),
14
22
  []
15
23
  );
16
24
 
17
25
  const loadOptions = (inputValue) => {
18
- if (inputValue !== '') {
26
+ if (inputValue.length >= 3) {
19
27
  return new Promise((resolve, reject) => {
20
28
  let data = [];
21
29
 
30
+ let payload = {
31
+ where: [
32
+ {
33
+ id: 'async',
34
+ value: inputValue,
35
+ },
36
+ ],
37
+ };
38
+
39
+ if (fields.length > 0) {
40
+ payload.fields = fields;
41
+ }
42
+
22
43
  CustomFetch(
23
44
  settings.url,
24
45
  'POST',
25
- {
26
- where: [
27
- {
28
- id: 'async',
29
- value: inputValue,
30
- },
31
- ],
32
- },
46
+ payload,
33
47
  function (result) {
34
48
  result.data.forEach((a) => {
35
49
  let _optionItem = {
@@ -56,6 +70,8 @@ function VisnsAsyncSelect({ inputValue, onChange, placeholder, settings }) {
56
70
  }
57
71
  );
58
72
  });
73
+ } else {
74
+ return Promise.resolve([]); // Return empty array if input is less than 3 characters
59
75
  }
60
76
  };
61
77
 
package/package.json CHANGED
@@ -57,7 +57,7 @@
57
57
  "react-dom": "^17.0.1"
58
58
  },
59
59
  "name": "@visns-studio/visns-components",
60
- "version": "4.1.6",
60
+ "version": "4.1.8",
61
61
  "description": "Various packages to assist in the development of our Custom Applications.",
62
62
  "main": "index.js",
63
63
  "scripts": {