@bolttech/molecules-dropdown 0.20.0 → 0.20.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.
Files changed (2) hide show
  1. package/index.cjs +28 -16
  2. package/package.json +7 -7
package/index.cjs CHANGED
@@ -2521,7 +2521,9 @@ const ReusableDropdownComponent = _a => {
2521
2521
  })]
2522
2522
  }), jsxRuntime.jsx(ClickableElement, {
2523
2523
  onClick: () => {
2524
- if (!disabled) setShowSelectComponent(!showSelectComponent);
2524
+ if (!disabled) {
2525
+ setShowSelectComponent(!showSelectComponent);
2526
+ }
2525
2527
  },
2526
2528
  children: jsxRuntime.jsx(atomsIcon.Icon, {
2527
2529
  dataTestId: `${dataTestId}-icon`,
@@ -2691,11 +2693,17 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
2691
2693
  const [internalSelectedOption, setInternalSelectedOption] = react.useState();
2692
2694
  const inputRef = react.useRef(null);
2693
2695
  react.useEffect(() => {
2694
- const normalizeOptionList = () => __awaiter(void 0, void 0, void 0, function* () {
2695
- return yield filterOptionsParam(inputValue, optionList, urlFilterOptions);
2696
- });
2697
- normalizeOptionList().then(optionsResponse => setCurrentOptionList([...optionsResponse])).catch(error => console.error('An error happens when trying to normalize options', error));
2698
- }, [filterOptionsParam, optionList, urlFilterOptions, inputValue]);
2696
+ if ((internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.value) === inputValue) {
2697
+ setCurrentOptionList([]);
2698
+ } else {
2699
+ const normalizeOptionList = () => __awaiter(void 0, void 0, void 0, function* () {
2700
+ return yield filterOptionsParam(inputValue, optionList, urlFilterOptions);
2701
+ });
2702
+ normalizeOptionList().then(optionsResponse => {
2703
+ setCurrentOptionList([...optionsResponse]);
2704
+ }).catch(error => console.error('An error happens when trying to normalize options', error));
2705
+ }
2706
+ }, [filterOptionsParam, optionList, urlFilterOptions, inputValue, internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.value]);
2699
2707
  const setSelectedOptionOnInputValue = react.useCallback(() => {
2700
2708
  if (!inputValue && internalSelectedOption) {
2701
2709
  setInputValue((internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.value) || '');
@@ -2726,17 +2734,17 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
2726
2734
  setIsFirstRender(false);
2727
2735
  }, [currentOptionList, setSelectedOptionOnInputValue, value, internalSelectedOption, optionList, isFirstRender]);
2728
2736
  return jsxRuntime.jsxs(SectionContainer, Object.assign({
2729
- onClick: () => {
2730
- var _a;
2731
- return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
2732
- },
2733
2737
  "$variant": variant,
2734
2738
  id: `${id}-container`,
2735
2739
  "data-testid": `${dataTestId}-container`,
2736
2740
  style: {
2737
2741
  maxWidth: (_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.style.width
2738
2742
  },
2739
- ref: ref
2743
+ ref: ref,
2744
+ onClick: () => {
2745
+ var _a;
2746
+ return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
2747
+ }
2740
2748
  }, uiUtils.applyDataAttributes(props), {
2741
2749
  children: [jsxRuntime.jsx(ReusableDropdownComponent, Object.assign({
2742
2750
  id: id,
@@ -2804,11 +2812,15 @@ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef((_a, ref) => {
2804
2812
  const [internalSelectedOption, setInternalSelectedOption] = react.useState();
2805
2813
  const inputRef = react.useRef(null);
2806
2814
  react.useEffect(() => {
2807
- const normalizeOptionList = () => __awaiter(void 0, void 0, void 0, function* () {
2808
- return yield filterOptionsParam(inputValue, optionList, urlFilterOptions);
2809
- });
2810
- normalizeOptionList().then(optionsResponse => setCurrentOptionList([...optionsResponse])).catch(error => console.error('An error happens when trying to normalize options', error));
2811
- }, [filterOptionsParam, optionList, urlFilterOptions, inputValue]);
2815
+ if ((internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.value) === inputValue) {
2816
+ setCurrentOptionList([]);
2817
+ } else {
2818
+ const normalizeOptionList = () => __awaiter(void 0, void 0, void 0, function* () {
2819
+ return yield filterOptionsParam(inputValue, optionList, urlFilterOptions);
2820
+ });
2821
+ normalizeOptionList().then(optionsResponse => setCurrentOptionList([...optionsResponse])).catch(error => console.error('An error happens when trying to normalize options', error));
2822
+ }
2823
+ }, [filterOptionsParam, optionList, urlFilterOptions, inputValue, internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.value]);
2812
2824
  const setSelectedOptionOnInputValue = react.useCallback(() => {
2813
2825
  if (!inputValue && internalSelectedOption) {
2814
2826
  setInputValue((internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.value) || '');
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@bolttech/molecules-dropdown",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "main": "./index.cjs",
5
5
  "type": "commonjs",
6
6
  "types": "./src/index.d.ts",
7
7
  "dependencies": {
8
- "@bolttech/atoms-icon": "0.22.0",
9
- "@bolttech/atoms-input": "0.21.0",
10
- "@bolttech/atoms-select": "0.19.2",
11
- "@bolttech/default-theme": "0.1.0",
8
+ "@bolttech/atoms-icon": "0.22.1",
9
+ "@bolttech/atoms-input": "0.0.1",
10
+ "@bolttech/atoms-select": "0.19.3",
11
+ "@bolttech/default-theme": "0.1.1",
12
12
  "@bolttech/form-engine": "0.5.0",
13
- "@bolttech/frontend-foundations": "0.3.0",
14
- "@bolttech/ui-utils": "0.2.0",
13
+ "@bolttech/frontend-foundations": "0.3.1",
14
+ "@bolttech/ui-utils": "0.2.2",
15
15
  "react": "18.2.0",
16
16
  "react-dom": "18.2.0",
17
17
  "styled-components": "6.1.1"