@bolttech/molecules-dropdown 0.33.1 → 0.33.2

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.
Files changed (2) hide show
  1. package/index.cjs +22 -10
  2. package/package.json +3 -3
package/index.cjs CHANGED
@@ -2766,12 +2766,18 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
2766
2766
  // eslint-disable-next-line react-hooks/exhaustive-deps
2767
2767
  }, [internalSelectedOption]);
2768
2768
  react.useEffect(() => {
2769
- if (value && value !== (internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.id)) {
2769
+ if (value !== (internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.id)) {
2770
2770
  const foundOption = optionList === null || optionList === void 0 ? void 0 : optionList.find(option => option.id === value);
2771
- setInternalSelectedOption(foundOption);
2772
- setInputValue((foundOption === null || foundOption === void 0 ? void 0 : foundOption.value) || '');
2773
- if (!asyncOptionList) {
2774
- setInputLabel((foundOption === null || foundOption === void 0 ? void 0 : foundOption.label) || '');
2771
+ if (!value && internalSelectedOption) {
2772
+ setInternalSelectedOption(undefined);
2773
+ setInputValue('');
2774
+ setInputLabel('');
2775
+ } else if (foundOption) {
2776
+ setInternalSelectedOption(foundOption);
2777
+ setInputValue((foundOption === null || foundOption === void 0 ? void 0 : foundOption.value) || '');
2778
+ if (!asyncOptionList) {
2779
+ setInputLabel((foundOption === null || foundOption === void 0 ? void 0 : foundOption.label) || '');
2780
+ }
2775
2781
  }
2776
2782
  }
2777
2783
  if (!isFirstRender || currentOptionList.length === 0) return;
@@ -2917,14 +2923,20 @@ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef((_a, ref) => {
2917
2923
  // eslint-disable-next-line react-hooks/exhaustive-deps
2918
2924
  }, [internalSelectedOption]);
2919
2925
  react.useEffect(() => {
2920
- if (value && value !== (internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.id)) {
2926
+ if (value !== (internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.id)) {
2921
2927
  const option = optionList === null || optionList === void 0 ? void 0 : optionList.map(currentOptionsList => {
2922
2928
  return currentOptionsList.options.find(option => option.id === value);
2923
2929
  }).find(item => !!item);
2924
- setInternalSelectedOption(option);
2925
- setInputValue((option === null || option === void 0 ? void 0 : option.value) || '');
2926
- if (!asyncOptionList) {
2927
- setInputLabel((option === null || option === void 0 ? void 0 : option.label) || '');
2930
+ if (!value && internalSelectedOption) {
2931
+ setInternalSelectedOption(undefined);
2932
+ setInputValue('');
2933
+ setInputLabel('');
2934
+ } else if (option) {
2935
+ setInternalSelectedOption(option);
2936
+ setInputValue((option === null || option === void 0 ? void 0 : option.value) || '');
2937
+ if (!asyncOptionList) {
2938
+ setInputLabel((option === null || option === void 0 ? void 0 : option.label) || '');
2939
+ }
2928
2940
  }
2929
2941
  return;
2930
2942
  }
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@bolttech/molecules-dropdown",
3
- "version": "0.33.1",
3
+ "version": "0.33.2",
4
4
  "main": "./index.cjs",
5
5
  "type": "commonjs",
6
6
  "types": "./src/index.d.ts",
7
7
  "dependencies": {
8
8
  "@bolttech/atoms-icon": "0.24.0",
9
- "@bolttech/atoms-input": "0.27.1",
9
+ "@bolttech/atoms-input": "0.27.0",
10
10
  "@bolttech/atoms-select": "0.24.0",
11
11
  "@bolttech/default-theme": "0.10.0",
12
- "@bolttech/form-engine": "3.1.0-beta.13",
12
+ "@bolttech/form-engine": "3.1.0-beta.21",
13
13
  "@bolttech/frontend-foundations": "0.10.0",
14
14
  "@bolttech/ui-utils": "0.5.0",
15
15
  "react": "18.2.0",