@bolttech/molecules-dropdown 0.17.0 → 0.17.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 +18 -4
  2. package/package.json +7 -7
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,14 @@ 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
+ setInternalSelectedOption(optionList === null || optionList === void 0 ? void 0 : optionList.find(option => option.id === value));
2705
+ return;
2706
+ }
2702
2707
  if (!isFirstRender || currentOptionList.length === 0) return;
2703
2708
  setInternalSelectedOption(currentOptionList.find(option => option.id === value));
2704
2709
  setIsFirstRender(false);
2705
- }, [currentOptionList, isFirstRender, setSelectedOptionOnInputValue, value]);
2710
+ }, [currentOptionList, setSelectedOptionOnInputValue, value, internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.id, optionList, isFirstRender]);
2706
2711
  return jsxRuntime.jsxs(SectionContainer, Object.assign({
2707
2712
  onClick: () => {
2708
2713
  var _a;
@@ -2774,12 +2779,12 @@ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef((_a, ref) => {
2774
2779
  placeholder
2775
2780
  } = _a,
2776
2781
  props = __rest(_a, ["label", "variant", "required", "optionList", "disabled", "errorMessage", "urlFilterOptions", "dataTestId", "filterOptionsParam", "value", "onChange", "onBlur", "onFocus", "placeholder"]);
2782
+ const [isFirstRender, setIsFirstRender] = react.useState(true);
2777
2783
  const [showSelectComponent, setShowSelectComponent] = react.useState(false);
2778
2784
  const [currentOptionList, setCurrentOptionList] = react.useState([]);
2779
2785
  const [inputValue, setInputValue] = react.useState('');
2780
2786
  const [inputLabel, setInputLabel] = react.useState('');
2781
2787
  const [internalSelectedOption, setInternalSelectedOption] = react.useState();
2782
- const [isFirstRender, setIsFirstRender] = react.useState(true);
2783
2788
  const inputRef = react.useRef(null);
2784
2789
  react.useEffect(() => {
2785
2790
  const normalizeOptionList = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -2810,12 +2815,21 @@ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef((_a, ref) => {
2810
2815
  // eslint-disable-next-line react-hooks/exhaustive-deps
2811
2816
  }, [internalSelectedOption]);
2812
2817
  react.useEffect(() => {
2818
+ if (value !== (internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.id)) {
2819
+ const option = (optionList === null || optionList === void 0 ? void 0 : optionList.map(currentOptionsList => {
2820
+ return currentOptionsList.options.find(option => option.id === value);
2821
+ })[0]) || undefined;
2822
+ setInternalSelectedOption(option);
2823
+ setInputValue((option === null || option === void 0 ? void 0 : option.value) || '');
2824
+ setInputLabel((option === null || option === void 0 ? void 0 : option.label) || '');
2825
+ return;
2826
+ }
2813
2827
  if (!isFirstRender || currentOptionList.length === 0) return;
2814
2828
  setInternalSelectedOption(currentOptionList.map(optionsList => {
2815
2829
  return optionsList.options.find(option => option.id === value);
2816
2830
  })[0] || undefined);
2817
2831
  setIsFirstRender(false);
2818
- }, [currentOptionList, isFirstRender, setSelectedOptionOnInputValue, value]);
2832
+ }, [currentOptionList, value, optionList, internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.id, isFirstRender]);
2819
2833
  return jsxRuntime.jsxs(SectionContainer, Object.assign({
2820
2834
  onClick: () => {
2821
2835
  var _a;
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@bolttech/molecules-dropdown",
3
- "version": "0.17.0",
3
+ "version": "0.17.2",
4
4
  "main": "./index.cjs",
5
5
  "type": "commonjs",
6
6
  "types": "./src/index.d.ts",
7
7
  "dependencies": {
8
- "@bolttech/atoms-icon": "0.21.0",
9
- "@bolttech/atoms-input": "0.20.0",
10
- "@bolttech/atoms-select": "0.18.0",
11
- "@bolttech/default-theme": "0.0.1",
8
+ "@bolttech/atoms-icon": "0.21.2",
9
+ "@bolttech/atoms-input": "0.20.1",
10
+ "@bolttech/atoms-select": "0.18.1",
11
+ "@bolttech/default-theme": "0.0.3",
12
12
  "@bolttech/form-engine": "0.5.0",
13
- "@bolttech/frontend-foundations": "0.0.1",
14
- "@bolttech/ui-utils": "0.1.1",
13
+ "@bolttech/frontend-foundations": "0.1.1",
14
+ "@bolttech/ui-utils": "0.1.3",
15
15
  "react": "18.2.0",
16
16
  "react-dom": "18.2.0",
17
17
  "styled-components": "5.3.6"