awing-library 2.1.2-dev.545 → 2.1.2-dev.547

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../src/AWING/AsyncAutocomplete/Container.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC,2CA+N5E"}
1
+ {"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../src/AWING/AsyncAutocomplete/Container.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC,2CAyO5E"}
@@ -45,10 +45,10 @@ function AsyncAutocomplete(props) {
45
45
  setHasMore(true);
46
46
  fetchRef.current?.(search, 1, (results)=>{
47
47
  if (!active) return;
48
- if (results && results.length > 0) setOptions([
49
- ...results
50
- ]);
51
- else if (results && 0 === results.length) setHasMore(false);
48
+ if (results) {
49
+ setOptions(results);
50
+ setHasMore(results.length === pageSize);
51
+ }
52
52
  });
53
53
  return ()=>{
54
54
  active = false;
@@ -127,6 +127,10 @@ function AsyncAutocomplete(props) {
127
127
  value: multiple ? value ?? [] : value ?? null,
128
128
  onChange: (_event, newValue)=>{
129
129
  if (onChange) onChange(newValue);
130
+ if (multiple) {
131
+ setInputValue('');
132
+ setSearchString('');
133
+ }
130
134
  },
131
135
  onInputChange: (_event, newInputValue, reason)=>{
132
136
  if ('reset' === reason) {
@@ -138,6 +142,12 @@ function AsyncAutocomplete(props) {
138
142
  setSearchString(newInputValue);
139
143
  } else setInputValue(newInputValue);
140
144
  },
145
+ onBlur: ()=>{
146
+ if (multiple) {
147
+ setInputValue('');
148
+ setSearchString('');
149
+ } else setInputValue(value ? getOptionLabel(value) : '');
150
+ },
141
151
  clearOnBlur: false,
142
152
  loading: loading,
143
153
  slotProps: {
@@ -6,7 +6,7 @@ import { fireEvent, render, screen } from "@testing-library/react";
6
6
  import { Constants } from "../../Commons/Constant.js";
7
7
  import container from "./container.js";
8
8
  var __webpack_modules__ = {
9
- "../DataInput": function(module) {
9
+ "AWING/DataInput": function(module) {
10
10
  module.exports = __WEBPACK_EXTERNAL_MODULE__DataInput_index_js_c7933a4f__;
11
11
  },
12
12
  "../helper": function(module) {
@@ -23,7 +23,7 @@ function __webpack_require__(moduleId) {
23
23
  __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
24
24
  return module.exports;
25
25
  }
26
- var index_js_ = __webpack_require__("../DataInput");
26
+ var index_js_ = __webpack_require__("AWING/DataInput");
27
27
  jest.mock('../DataInput', ()=>({
28
28
  __esModule: true,
29
29
  default: jest.fn(),
@@ -91,7 +91,7 @@ jest.mock('@mui/material', ()=>({
91
91
  children: children
92
92
  })
93
93
  }));
94
- const mockInputFactory = __webpack_require__("../DataInput")["default"];
94
+ const mockInputFactory = __webpack_require__("AWING/DataInput")["default"];
95
95
  const mockCalculateValue = __webpack_require__("../helper").calculateValue;
96
96
  const mockConvertFormulaToBinaryTree = __webpack_require__("../helper").convertFormulaToBinaryTree;
97
97
  const mockReplaceFieldsValue = __webpack_require__("../helper").replaceFieldsValue;
@@ -5,7 +5,7 @@ import { act, fireEvent, render, screen, waitFor } from "@testing-library/react"
5
5
  import containerOptimized from "./containerOptimized.js";
6
6
  import { createFormStateManager } from "./formStateManager.js";
7
7
  var __webpack_modules__ = {
8
- "../DataInput": function(module) {
8
+ "AWING/DataInput": function(module) {
9
9
  module.exports = __WEBPACK_EXTERNAL_MODULE__DataInput_index_js_c7933a4f__;
10
10
  }
11
11
  };
@@ -98,7 +98,7 @@ jest.mock('@mui/material', ()=>({
98
98
  children: children
99
99
  })
100
100
  }));
101
- const mockInputFactory = __webpack_require__("../DataInput")["default"];
101
+ const mockInputFactory = __webpack_require__("AWING/DataInput")["default"];
102
102
  describe('DataForm Optimized - Performance Tests', ()=>{
103
103
  let inputRenderCounts = {};
104
104
  const mockFields = [
@@ -5,6 +5,7 @@ type Value = string | number;
5
5
  export interface LazyAutocompleteFieldDefinition<T> extends Omit<AutocompleteFieldDefinition<T>, 'options' | 'type'> {
6
6
  type: FIELD_TYPE.LAZY_AUTOCOMPLETE | 'lazyautocomplete';
7
7
  fetchOptions: () => Promise<MenuOption<Value>[]>;
8
+ additionalOptions?: MenuOption<Value>[];
8
9
  }
9
10
  export declare const LazyAutocompleteInput: <T>(fieldDefinition: LazyAutocompleteFieldDefinition<T>) => import("react/jsx-runtime").JSX.Element;
10
11
  export default LazyAutocompleteInput;
@@ -1 +1 @@
1
- {"version":3,"file":"LazyAutocompleteInput.d.ts","sourceRoot":"","sources":["../../../../src/AWING/DataInput/components/LazyAutocompleteInput.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAGlE,KAAK,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAC7B,MAAM,WAAW,+BAA+B,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,2BAA2B,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAChH,IAAI,EAAE,UAAU,CAAC,iBAAiB,GAAG,kBAAkB,CAAC;IACxD,YAAY,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;CACpD;AAED,eAAO,MAAM,qBAAqB,GAAI,CAAC,mBAAoB,+BAA+B,CAAC,CAAC,CAAC,4CAmH5F,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"LazyAutocompleteInput.d.ts","sourceRoot":"","sources":["../../../../src/AWING/DataInput/components/LazyAutocompleteInput.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAGlE,KAAK,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAC7B,MAAM,WAAW,+BAA+B,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,2BAA2B,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAChH,IAAI,EAAE,UAAU,CAAC,iBAAiB,GAAG,kBAAkB,CAAC;IACxD,YAAY,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACjD,iBAAiB,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;CAC3C;AAED,eAAO,MAAM,qBAAqB,GAAI,CAAC,mBAAoB,+BAA+B,CAAC,CAAC,CAAC,4CA2H5F,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -9,7 +9,7 @@ const LazyAutocompleteInput_LazyAutocompleteInput = (fieldDefinition)=>{
9
9
  const { t } = useTranslation(void 0, {
10
10
  i18n: i18n
11
11
  });
12
- const { fetchOptions, value, onChange, readOnly, error, disableHelperText, helperText, disableClearable, multiple = false, isDirectory = false, onValidateCustom, disabled, required = false, clearOnEscape = true, ...other } = fieldDefinition;
12
+ const { fetchOptions, value, onChange, readOnly, error, disableHelperText, helperText, disableClearable, multiple = false, isDirectory = false, onValidateCustom, disabled, required = false, clearOnEscape = true, additionalOptions, ...other } = fieldDefinition;
13
13
  const [open, setOpen] = useState(false);
14
14
  const [options, setOptions] = useState([]);
15
15
  const [fetched, setFetched] = useState(false);
@@ -22,7 +22,15 @@ const LazyAutocompleteInput_LazyAutocompleteInput = (fieldDefinition)=>{
22
22
  };
23
23
  useEffect(()=>{
24
24
  if (open && !fetched) fetchOptions().then((res)=>{
25
- setOptions(res);
25
+ let finalOptions = res;
26
+ if (additionalOptions) finalOptions = Array.isArray(additionalOptions) ? [
27
+ ...additionalOptions,
28
+ ...res
29
+ ] : [
30
+ additionalOptions,
31
+ ...res
32
+ ];
33
+ setOptions(finalOptions);
26
34
  setFetched(true);
27
35
  });
28
36
  }, [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.2-dev.545",
3
+ "version": "2.1.2-dev.547",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {