@razorpay/blade 10.13.0 → 10.13.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.
@@ -13653,7 +13653,8 @@ var makeInputDisplayValue = function makeInputDisplayValue(selectedIndices, opti
13653
13653
 
13654
13654
  // When one item is selected, we display that item's title in input
13655
13655
  if (selectedIndices.length === 1) {
13656
- return options[selectedIndices[0]].title;
13656
+ var _options$selectedIndi;
13657
+ return (_options$selectedIndi = options[selectedIndices[0]]) === null || _options$selectedIndi === void 0 ? void 0 : _options$selectedIndi.title;
13657
13658
  }
13658
13659
 
13659
13660
  // When more than one item is selected, we display the count of items
@@ -23275,6 +23276,12 @@ var useControlledDropdownInput = function useControlledDropdownInput(props) {
23275
23276
  setIsControlled(true);
23276
23277
  }
23277
23278
  selectValues(props.value);
23279
+
23280
+ // in single select AutoComplete, we have to set inputValue of autocomplete according to the new selection.
23281
+ if (selectionType === 'single' && !Array.isArray(props.value) && !props.isSelectInput) {
23282
+ var _props$syncInputValue;
23283
+ (_props$syncInputValue = props.syncInputValueWithSelection) === null || _props$syncInputValue === void 0 ? void 0 : _props$syncInputValue.call(props, props.value);
23284
+ }
23278
23285
  }
23279
23286
  // eslint-disable-next-line react-hooks/exhaustive-deps
23280
23287
  }, [props.value, options]);
@@ -23336,7 +23343,9 @@ var _BaseDropdownInputTrigger = function _BaseDropdownInputTrigger(props, ref) {
23336
23343
  onChange: props.onChange,
23337
23344
  name: props.name,
23338
23345
  value: props.value,
23339
- defaultValue: props.defaultValue
23346
+ defaultValue: props.defaultValue,
23347
+ syncInputValueWithSelection: props.syncInputValueWithSelection,
23348
+ isSelectInput: props.isSelectInput
23340
23349
  });
23341
23350
  var getValue = function getValue() {
23342
23351
  var prefix = '';
@@ -23588,7 +23597,7 @@ var useAutoComplete = function useAutoComplete(_ref) {
23588
23597
  setActiveIndex(firstItemOptionIndex);
23589
23598
  }
23590
23599
  // eslint-disable-next-line react-hooks/exhaustive-deps
23591
- }, [globalFilteredValues.length]);
23600
+ }, [globalFilteredValues.length, options.length]);
23592
23601
 
23593
23602
  // When input is empty or its single select, we want all items to be shown in filter on open of dropdown
23594
23603
  React__default.useEffect(function () {
@@ -23629,7 +23638,7 @@ var useAutoComplete = function useAutoComplete(_ref) {
23629
23638
  // eslint-disable-next-line no-lonely-if
23630
23639
  if (value && options && options.length > 0) {
23631
23640
  var filteredOptions = getOptionValues().filter(function (optionValue) {
23632
- return optionValue.toLowerCase().startsWith(value.toLowerCase());
23641
+ return optionValue.toLowerCase().includes(value.toLowerCase());
23633
23642
  });
23634
23643
  setGlobalFilteredValues(filteredOptions);
23635
23644
  } else {
@@ -23739,6 +23748,17 @@ var _AutoComplete = function _AutoComplete(props, ref) {
23739
23748
  onChange: onSelectionChange,
23740
23749
  isSelectInput: false,
23741
23750
  inputValue: inputValue,
23751
+ syncInputValueWithSelection: function syncInputValueWithSelection(value) {
23752
+ var _selectedOption$title;
23753
+ if (!value) {
23754
+ setInputValue('');
23755
+ return;
23756
+ }
23757
+ var selectedOption = options.find(function (option) {
23758
+ return option.value === value;
23759
+ });
23760
+ setInputValue((_selectedOption$title = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.title) !== null && _selectedOption$title !== void 0 ? _selectedOption$title : '');
23761
+ },
23742
23762
  onTriggerKeydown: onTriggerKeydown,
23743
23763
  onInputValueChange: onInputValueChange,
23744
23764
  onTriggerClick: function onTriggerClick(triggerEvent) {