@bolttech/molecules-dropdown 0.17.1 → 0.17.3

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 +20 -4
  2. package/package.json +2 -2
package/index.cjs CHANGED
@@ -2484,6 +2484,7 @@ const ReusableDropdownComponent = _a => {
2484
2484
  value: inputLabel,
2485
2485
  variant: variant,
2486
2486
  placeholder: placeholder,
2487
+ autoComplete: "off",
2487
2488
  onChange: e => {
2488
2489
  var _a, _b;
2489
2490
  onChangeInputValue(((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.value) || '');
@@ -2667,12 +2668,12 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
2667
2668
  placeholder
2668
2669
  } = _a,
2669
2670
  props = __rest(_a, ["label", "variant", "required", "optionList", "disabled", "errorMessage", "urlFilterOptions", "id", "dataTestId", "filterOptionsParam", "value", "onChange", "onBlur", "onFocus", "placeholder"]);
2671
+ const [isFirstRender, setIsFirstRender] = react.useState(true);
2670
2672
  const [showSelectComponent, setShowSelectComponent] = react.useState(false);
2671
2673
  const [currentOptionList, setCurrentOptionList] = react.useState([]);
2672
2674
  const [inputValue, setInputValue] = react.useState('');
2673
2675
  const [inputLabel, setInputLabel] = react.useState('');
2674
2676
  const [internalSelectedOption, setInternalSelectedOption] = react.useState();
2675
- const [isFirstRender, setIsFirstRender] = react.useState(true);
2676
2677
  const inputRef = react.useRef(null);
2677
2678
  react.useEffect(() => {
2678
2679
  const normalizeOptionList = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -2699,10 +2700,16 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
2699
2700
  // eslint-disable-next-line react-hooks/exhaustive-deps
2700
2701
  }, [internalSelectedOption]);
2701
2702
  react.useEffect(() => {
2703
+ if (value !== (internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.id)) {
2704
+ const foundOption = optionList === null || optionList === void 0 ? void 0 : optionList.find(option => option.id === value);
2705
+ setInternalSelectedOption(foundOption);
2706
+ setInputValue((foundOption === null || foundOption === void 0 ? void 0 : foundOption.value) || '');
2707
+ setInputLabel((foundOption === null || foundOption === void 0 ? void 0 : foundOption.label) || '');
2708
+ }
2702
2709
  if (!isFirstRender || currentOptionList.length === 0) return;
2703
2710
  setInternalSelectedOption(currentOptionList.find(option => option.id === value));
2704
2711
  setIsFirstRender(false);
2705
- }, [currentOptionList, isFirstRender, setSelectedOptionOnInputValue, value]);
2712
+ }, [currentOptionList, setSelectedOptionOnInputValue, value, internalSelectedOption, optionList, isFirstRender]);
2706
2713
  return jsxRuntime.jsxs(SectionContainer, Object.assign({
2707
2714
  onClick: () => {
2708
2715
  var _a;
@@ -2774,12 +2781,12 @@ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef((_a, ref) => {
2774
2781
  placeholder
2775
2782
  } = _a,
2776
2783
  props = __rest(_a, ["label", "variant", "required", "optionList", "disabled", "errorMessage", "urlFilterOptions", "dataTestId", "filterOptionsParam", "value", "onChange", "onBlur", "onFocus", "placeholder"]);
2784
+ const [isFirstRender, setIsFirstRender] = react.useState(true);
2777
2785
  const [showSelectComponent, setShowSelectComponent] = react.useState(false);
2778
2786
  const [currentOptionList, setCurrentOptionList] = react.useState([]);
2779
2787
  const [inputValue, setInputValue] = react.useState('');
2780
2788
  const [inputLabel, setInputLabel] = react.useState('');
2781
2789
  const [internalSelectedOption, setInternalSelectedOption] = react.useState();
2782
- const [isFirstRender, setIsFirstRender] = react.useState(true);
2783
2790
  const inputRef = react.useRef(null);
2784
2791
  react.useEffect(() => {
2785
2792
  const normalizeOptionList = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -2810,12 +2817,21 @@ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef((_a, ref) => {
2810
2817
  // eslint-disable-next-line react-hooks/exhaustive-deps
2811
2818
  }, [internalSelectedOption]);
2812
2819
  react.useEffect(() => {
2820
+ if (value !== (internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.id)) {
2821
+ const option = (optionList === null || optionList === void 0 ? void 0 : optionList.map(currentOptionsList => {
2822
+ return currentOptionsList.options.find(option => option.id === value);
2823
+ })[0]) || undefined;
2824
+ setInternalSelectedOption(option);
2825
+ setInputValue((option === null || option === void 0 ? void 0 : option.value) || '');
2826
+ setInputLabel((option === null || option === void 0 ? void 0 : option.label) || '');
2827
+ return;
2828
+ }
2813
2829
  if (!isFirstRender || currentOptionList.length === 0) return;
2814
2830
  setInternalSelectedOption(currentOptionList.map(optionsList => {
2815
2831
  return optionsList.options.find(option => option.id === value);
2816
2832
  })[0] || undefined);
2817
2833
  setIsFirstRender(false);
2818
- }, [currentOptionList, isFirstRender, setSelectedOptionOnInputValue, value]);
2834
+ }, [currentOptionList, value, optionList, internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.id, isFirstRender]);
2819
2835
  return jsxRuntime.jsxs(SectionContainer, Object.assign({
2820
2836
  onClick: () => {
2821
2837
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolttech/molecules-dropdown",
3
- "version": "0.17.1",
3
+ "version": "0.17.3",
4
4
  "main": "./index.cjs",
5
5
  "type": "commonjs",
6
6
  "types": "./src/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "@bolttech/atoms-select": "0.18.1",
11
11
  "@bolttech/default-theme": "0.0.3",
12
12
  "@bolttech/form-engine": "0.5.0",
13
- "@bolttech/frontend-foundations": "0.0.3",
13
+ "@bolttech/frontend-foundations": "0.1.1",
14
14
  "@bolttech/ui-utils": "0.1.3",
15
15
  "react": "18.2.0",
16
16
  "react-dom": "18.2.0",