@razorpay/blade 10.13.0 → 10.13.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.
@@ -5452,6 +5452,7 @@ declare const SelectInput: React__default.ForwardRefExoticComponent<(({
5452
5452
  name?: string | undefined;
5453
5453
  values: string[];
5454
5454
  }) => void) | undefined;
5455
+ syncInputValueWithSelection?: ((value: string) => void) | undefined;
5455
5456
  maxRows?: "multiple" | "single" | "expandable" | undefined;
5456
5457
  labelPosition?: "left" | "top" | "inside-input" | undefined;
5457
5458
  }) & React__default.RefAttributes<BladeElementRef>>;
@@ -5510,6 +5511,7 @@ declare const AutoComplete: React__default.ForwardRefExoticComponent<Pick<BaseIn
5510
5511
  name?: string | undefined;
5511
5512
  values: string[];
5512
5513
  }) => void) | undefined;
5514
+ syncInputValueWithSelection?: ((value: string) => void) | undefined;
5513
5515
  maxRows?: "multiple" | "single" | "expandable" | undefined;
5514
5516
  labelPosition?: "left" | "top" | "inside-input" | undefined;
5515
5517
  } & {
@@ -5534,6 +5536,12 @@ declare type DropdownInputTriggersCommonProps = Pick<BaseInputProps, 'label' | '
5534
5536
  name?: string;
5535
5537
  values: string[];
5536
5538
  }) => void;
5539
+ /**
5540
+ * Syncs the selected value to inputValue in AutoComplete
5541
+ *
5542
+ * Only needed in single select AutoComplete because inputValue is expected to be same as selected value there
5543
+ */
5544
+ syncInputValueWithSelection?: (value: string) => void;
5537
5545
  /**
5538
5546
  * constraints the height of input to given number rows
5539
5547
  *
@@ -23674,6 +23674,12 @@ var useControlledDropdownInput = function useControlledDropdownInput(props) {
23674
23674
  setIsControlled(true);
23675
23675
  }
23676
23676
  selectValues(props.value);
23677
+
23678
+ // in single select AutoComplete, we have to set inputValue of autocomplete according to the new selection.
23679
+ if (selectionType === 'single' && !Array.isArray(props.value) && !props.isSelectInput) {
23680
+ var _props$syncInputValue;
23681
+ (_props$syncInputValue = props.syncInputValueWithSelection) === null || _props$syncInputValue === void 0 ? void 0 : _props$syncInputValue.call(props, props.value);
23682
+ }
23677
23683
  }
23678
23684
  // eslint-disable-next-line react-hooks/exhaustive-deps
23679
23685
  }, [props.value, options]);
@@ -23735,7 +23741,9 @@ var _BaseDropdownInputTrigger = function _BaseDropdownInputTrigger(props, ref) {
23735
23741
  onChange: props.onChange,
23736
23742
  name: props.name,
23737
23743
  value: props.value,
23738
- defaultValue: props.defaultValue
23744
+ defaultValue: props.defaultValue,
23745
+ syncInputValueWithSelection: props.syncInputValueWithSelection,
23746
+ isSelectInput: props.isSelectInput
23739
23747
  });
23740
23748
  var getValue = function getValue() {
23741
23749
  var prefix = '';
@@ -24028,7 +24036,7 @@ var useAutoComplete = function useAutoComplete(_ref) {
24028
24036
  // eslint-disable-next-line no-lonely-if
24029
24037
  if (value && options && options.length > 0) {
24030
24038
  var filteredOptions = getOptionValues().filter(function (optionValue) {
24031
- return optionValue.toLowerCase().startsWith(value.toLowerCase());
24039
+ return optionValue.toLowerCase().includes(value.toLowerCase());
24032
24040
  });
24033
24041
  setGlobalFilteredValues(filteredOptions);
24034
24042
  } else {
@@ -24138,6 +24146,17 @@ var _AutoComplete = function _AutoComplete(props, ref) {
24138
24146
  onChange: onSelectionChange,
24139
24147
  isSelectInput: false,
24140
24148
  inputValue: inputValue,
24149
+ syncInputValueWithSelection: function syncInputValueWithSelection(value) {
24150
+ var _selectedOption$title;
24151
+ if (!value) {
24152
+ setInputValue('');
24153
+ return;
24154
+ }
24155
+ var selectedOption = options.find(function (option) {
24156
+ return option.value === value;
24157
+ });
24158
+ setInputValue((_selectedOption$title = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.title) !== null && _selectedOption$title !== void 0 ? _selectedOption$title : '');
24159
+ },
24141
24160
  onTriggerKeydown: onTriggerKeydown,
24142
24161
  onInputValueChange: onInputValueChange,
24143
24162
  onTriggerClick: function onTriggerClick(triggerEvent) {