@visns-studio/visns-components 4.1.7 → 4.2.0

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.
@@ -8,20 +8,23 @@ function VisnsAsyncSelect({
8
8
  fields = [],
9
9
  inputValue,
10
10
  onChange,
11
+ orderBy,
11
12
  placeholder,
12
13
  settings,
13
14
  }) {
14
15
  const loadSuggestedOptions = useCallback(
15
16
  debounce((inputValue, callback) => {
16
- if (inputValue !== '') {
17
+ if (inputValue.length >= 3) {
17
18
  loadOptions(inputValue).then((options) => callback(options));
19
+ } else {
20
+ callback([]); // Return empty array if input is less than 3 characters
18
21
  }
19
22
  }, 500),
20
23
  []
21
24
  );
22
25
 
23
26
  const loadOptions = (inputValue) => {
24
- if (inputValue !== '') {
27
+ if (inputValue.length >= 3) {
25
28
  return new Promise((resolve, reject) => {
26
29
  let data = [];
27
30
 
@@ -38,6 +41,10 @@ function VisnsAsyncSelect({
38
41
  payload.fields = fields;
39
42
  }
40
43
 
44
+ if (orderBy) {
45
+ payload.orderBy = orderBy;
46
+ }
47
+
41
48
  CustomFetch(
42
49
  settings.url,
43
50
  'POST',
@@ -68,6 +75,8 @@ function VisnsAsyncSelect({
68
75
  }
69
76
  );
70
77
  });
78
+ } else {
79
+ return Promise.resolve([]); // Return empty array if input is less than 3 characters
71
80
  }
72
81
  };
73
82
 
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.7",
60
+ "version": "4.2.0",
61
61
  "description": "Various packages to assist in the development of our Custom Applications.",
62
62
  "main": "index.js",
63
63
  "scripts": {