@aloudata/aloudata-design 2.13.4 → 2.13.5-beta.1

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.
@@ -26,7 +26,7 @@ declare const AldFormItem: {
26
26
  type InternalFormType = typeof AldForm;
27
27
  type OriginUseFormType<T> = typeof useForm<T>;
28
28
  type CompoundedComponent = InternalFormType & {
29
- useForm: <T>(...args: [...Parameters<OriginUseFormType<T>>, string?]) => ReturnType<OriginUseFormType<T>>;
29
+ useForm: <T = any>(...args: [...Parameters<OriginUseFormType<T>>, string?]) => ReturnType<OriginUseFormType<T>>;
30
30
  useFormInstance: typeof useFormInstance;
31
31
  useWatch: typeof useWatch;
32
32
  Item: typeof AldFormItem;
@@ -36,20 +36,33 @@ var defaultDropdownStyle = {
36
36
  minWidth: 192
37
37
  };
38
38
  var DEFAULT_LIST_ITEM_HEIGHT = 36;
39
- var getSelectedOptionsFromValue = function getSelectedOptionsFromValue(isMultiple, options, value, defaultValue) {
39
+ var getSelectedOptionsFromValue = function getSelectedOptionsFromValue(isMultiple, options, value, defaultValue, prevSelectOptions) {
40
40
  if (typeof value !== 'undefined') {
41
41
  if (isMultiple) {
42
42
  if (Array.isArray(value)) {
43
- var newOptions = options === null || options === void 0 ? void 0 : options.filter(function (option) {
44
- return value.includes(option.value);
43
+ var _newOptions = [];
44
+ value.forEach(function (currentValue) {
45
+ var newOption = options === null || options === void 0 ? void 0 : options.find(function (option) {
46
+ return option.value === currentValue;
47
+ });
48
+ if (newOption) {
49
+ _newOptions.push(newOption);
50
+ } else {
51
+ var prevOption = prevSelectOptions === null || prevSelectOptions === void 0 ? void 0 : prevSelectOptions.find(function (option) {
52
+ return option.value === currentValue;
53
+ });
54
+ if (prevOption) {
55
+ _newOptions.push(prevOption);
56
+ }
57
+ }
45
58
  });
46
- return newOptions || [];
59
+ return _newOptions;
47
60
  }
48
61
  } else {
49
- var _newOptions = options === null || options === void 0 ? void 0 : options.filter(function (option) {
62
+ var newOptions = options === null || options === void 0 ? void 0 : options.filter(function (option) {
50
63
  return option.value === value;
51
64
  });
52
- return _newOptions || [];
65
+ return newOptions || [];
53
66
  }
54
67
  return [];
55
68
  }
@@ -365,7 +378,9 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
365
378
  };
366
379
  useEffect(function () {
367
380
  if (updatedRef.current) {
368
- setSelectedOptions(getSelectedOptionsFromValue(isMultiple, innerOptions, value, defaultValue));
381
+ setSelectedOptions(function (prev) {
382
+ return getSelectedOptionsFromValue(isMultiple, innerOptions, value, defaultValue, prev);
383
+ });
369
384
  } else {
370
385
  updatedRef.current = true;
371
386
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloudata/aloudata-design",
3
- "version": "2.13.4",
3
+ "version": "2.13.5-beta.1",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",