@bolttech/molecules-dropdown 0.33.1 → 0.34.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.
package/index.cjs CHANGED
@@ -2484,7 +2484,7 @@ const ReusableDropdownComponent = _a => {
2484
2484
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
2485
2485
  children: [jsxRuntime.jsxs(ContainerDropdown, {
2486
2486
  "$variant": variant,
2487
- "$hasValue": inputValue,
2487
+ "$hasValue": inputValue !== null || inputValue !== undefined || inputValue !== '',
2488
2488
  "$hasError": hasError,
2489
2489
  "$hasHelperText": !!helperMessage,
2490
2490
  disabled: disabled,
@@ -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.34.0",
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.28.0",
10
10
  "@bolttech/atoms-select": "0.24.0",
11
- "@bolttech/default-theme": "0.10.0",
12
- "@bolttech/form-engine": "3.1.0-beta.13",
11
+ "@bolttech/default-theme": "0.14.1",
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",
@@ -3,7 +3,7 @@
3
3
  import { StyleVariants } from './molecules-dropdown.type';
4
4
  type DropdownStyledProps = {
5
5
  $variant: StyleVariants;
6
- $hasValue: string;
6
+ $hasValue: boolean;
7
7
  $hasError?: boolean;
8
8
  $hasHelperText?: boolean;
9
9
  disabled?: boolean;