@razorpay/blade 7.2.2 → 8.0.0
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.
- package/CHANGELOG.md +82 -0
- package/build/components/index.d.ts +36 -9
- package/build/components/index.native.d.ts +36 -9
- package/build/components/index.native.js +17 -17
- package/build/components/index.native.js.map +1 -1
- package/build/components/index.web.js +273 -97
- package/build/components/index.web.js.map +1 -1
- package/build/css/bankingThemeDarkDesktop.css +1 -1
- package/build/css/bankingThemeDarkMobile.css +1 -1
- package/build/css/bankingThemeLightDesktop.css +1 -1
- package/build/css/bankingThemeLightMobile.css +1 -1
- package/build/css/paymentThemeDarkDesktop.css +1 -1
- package/build/css/paymentThemeDarkMobile.css +1 -1
- package/build/css/paymentThemeLightDesktop.css +1 -1
- package/build/css/paymentThemeLightMobile.css +1 -1
- package/package.json +3 -3
|
@@ -3774,7 +3774,6 @@ var assignWithoutSideEffects = function assignWithoutSideEffects(component, sour
|
|
|
3774
3774
|
*/
|
|
3775
3775
|
|
|
3776
3776
|
var isRoleMenu = function isRoleMenu(dropdownTriggerer) {
|
|
3777
|
-
// @TODO: check this logic once we introduce new triggerer. This may not stand true.
|
|
3778
3777
|
return isReactNative$4() || dropdownTriggerer !== 'SelectInput';
|
|
3779
3778
|
};
|
|
3780
3779
|
/**
|
|
@@ -3822,7 +3821,7 @@ var getSeparatorRole = function getSeparatorRole() {
|
|
|
3822
3821
|
};
|
|
3823
3822
|
var getActionListItemWrapperRole = function getActionListItemWrapperRole(hasFooterAction, dropdownTriggerer) {
|
|
3824
3823
|
if (isRoleMenu(dropdownTriggerer)) {
|
|
3825
|
-
return
|
|
3824
|
+
return undefined;
|
|
3826
3825
|
}
|
|
3827
3826
|
|
|
3828
3827
|
if (hasFooterAction) {
|
|
@@ -3894,7 +3893,6 @@ var getActionListProperties = function getActionListProperties(children) {
|
|
|
3894
3893
|
var sectionData = [];
|
|
3895
3894
|
var currentSection = null;
|
|
3896
3895
|
var actionListOptions = [];
|
|
3897
|
-
var defaultSelectedIndices = [];
|
|
3898
3896
|
var actionListHeaderChild = null;
|
|
3899
3897
|
var actionListFooterChild = null;
|
|
3900
3898
|
|
|
@@ -3903,7 +3901,26 @@ var getActionListProperties = function getActionListProperties(children) {
|
|
|
3903
3901
|
actionListOptions.push({
|
|
3904
3902
|
title: child.props.title,
|
|
3905
3903
|
value: child.props.value,
|
|
3906
|
-
|
|
3904
|
+
onClickTrigger: function onClickTrigger(value) {
|
|
3905
|
+
var _child$props$onClick, _child$props, _child$props$isSelect;
|
|
3906
|
+
|
|
3907
|
+
var anchorLink = child.props.href;
|
|
3908
|
+
(_child$props$onClick = (_child$props = child.props).onClick) === null || _child$props$onClick === void 0 ? void 0 : _child$props$onClick.call(_child$props, {
|
|
3909
|
+
name: child.props.value,
|
|
3910
|
+
value: (_child$props$isSelect = child.props.isSelected) !== null && _child$props$isSelect !== void 0 ? _child$props$isSelect : value
|
|
3911
|
+
});
|
|
3912
|
+
|
|
3913
|
+
if (anchorLink && !isReactNative$4()) {
|
|
3914
|
+
var _child$props$target;
|
|
3915
|
+
|
|
3916
|
+
var target = (_child$props$target = child.props.target) !== null && _child$props$target !== void 0 ? _child$props$target : '_self';
|
|
3917
|
+
window.open(anchorLink, target);
|
|
3918
|
+
|
|
3919
|
+
if (window.top) {
|
|
3920
|
+
window.top.open(anchorLink, target);
|
|
3921
|
+
}
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3907
3924
|
});
|
|
3908
3925
|
var currentIndex = actionListOptions.length - 1;
|
|
3909
3926
|
var foundSection = sectionData.find(function (v) {
|
|
@@ -3925,10 +3942,6 @@ var getActionListProperties = function getActionListProperties(children) {
|
|
|
3925
3942
|
});
|
|
3926
3943
|
}
|
|
3927
3944
|
|
|
3928
|
-
if (child.props.isDefaultSelected) {
|
|
3929
|
-
defaultSelectedIndices.push(currentIndex);
|
|
3930
|
-
}
|
|
3931
|
-
|
|
3932
3945
|
var clonedChild = /*#__PURE__*/React__default.cloneElement(child, {
|
|
3933
3946
|
// @ts-expect-error: TS doesn't understand the child's props
|
|
3934
3947
|
_index: currentIndex
|
|
@@ -3998,8 +4011,7 @@ var getActionListProperties = function getActionListProperties(children) {
|
|
|
3998
4011
|
childrenWithId: childrenWithId,
|
|
3999
4012
|
actionListFooterChild: actionListFooterChild,
|
|
4000
4013
|
actionListHeaderChild: actionListHeaderChild,
|
|
4001
|
-
actionListOptions: actionListOptions
|
|
4002
|
-
defaultSelectedIndices: defaultSelectedIndices
|
|
4014
|
+
actionListOptions: actionListOptions
|
|
4003
4015
|
};
|
|
4004
4016
|
};
|
|
4005
4017
|
|
|
@@ -4703,7 +4715,11 @@ var ActionListBox = /*#__PURE__*/assignWithoutSideEffects(_ActionListBox, {
|
|
|
4703
4715
|
*/
|
|
4704
4716
|
var componentIds = {
|
|
4705
4717
|
DropdownOverlay: 'DropdownOverlay',
|
|
4706
|
-
Dropdown: 'Dropdown'
|
|
4718
|
+
Dropdown: 'Dropdown',
|
|
4719
|
+
triggers: {
|
|
4720
|
+
SelectInput: 'SelectInput',
|
|
4721
|
+
DropdownButton: 'DropdownButton'
|
|
4722
|
+
}
|
|
4707
4723
|
}; // Save a list of named combobox actions, for future readability
|
|
4708
4724
|
|
|
4709
4725
|
var SelectActions = {
|
|
@@ -4877,8 +4893,8 @@ function isScrollable(element) {
|
|
|
4877
4893
|
*
|
|
4878
4894
|
* This function handles all the keydown actions.
|
|
4879
4895
|
*/
|
|
4880
|
-
var performAction = function performAction(action,
|
|
4881
|
-
var event =
|
|
4896
|
+
var performAction = function performAction(action, payload, actions) {
|
|
4897
|
+
var event = payload.event;
|
|
4882
4898
|
|
|
4883
4899
|
switch (action) {
|
|
4884
4900
|
case SelectActions.Last: // @ts-expect-error: intentional fallthrough, ignoring the warning
|
|
@@ -4902,7 +4918,7 @@ var performAction = function performAction(action, e, actions) {
|
|
|
4902
4918
|
|
|
4903
4919
|
case SelectActions.Close:
|
|
4904
4920
|
event.preventDefault();
|
|
4905
|
-
actions.
|
|
4921
|
+
actions.close();
|
|
4906
4922
|
return true;
|
|
4907
4923
|
|
|
4908
4924
|
case SelectActions.Type:
|
|
@@ -4982,20 +4998,22 @@ var makeInputDisplayValue = function makeInputDisplayValue(selectedIndices, opti
|
|
|
4982
4998
|
return "".concat(selectedIndices.length, " items selected");
|
|
4983
4999
|
};
|
|
4984
5000
|
|
|
4985
|
-
var _excluded$4N = ["isOpen", "setIsOpen", "selectedIndices", "setSelectedIndices", "activeIndex", "setActiveIndex", "shouldIgnoreBlur", "setShouldIgnoreBlur", "isKeydownPressed", "setIsKeydownPressed", "options", "selectionType"];
|
|
5001
|
+
var _excluded$4N = ["isOpen", "setIsOpen", "close", "selectedIndices", "setSelectedIndices", "activeIndex", "setActiveIndex", "shouldIgnoreBlur", "setShouldIgnoreBlur", "isKeydownPressed", "setIsKeydownPressed", "options", "selectionType", "changeCallbackTriggerer", "setChangeCallbackTriggerer", "isControlled", "setControlledValueIndices"];
|
|
4986
5002
|
|
|
4987
5003
|
function ownKeys$5m(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4988
5004
|
|
|
4989
5005
|
function _objectSpread$5l(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5m(Object(source), !0).forEach(function (key) { _defineProperty$2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5m(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4990
5006
|
|
|
4991
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
4992
5007
|
var noop$1 = function noop() {};
|
|
4993
5008
|
|
|
4994
5009
|
var DropdownContext = /*#__PURE__*/React__default.createContext({
|
|
4995
5010
|
isOpen: false,
|
|
4996
5011
|
setIsOpen: noop$1,
|
|
5012
|
+
close: noop$1,
|
|
4997
5013
|
selectedIndices: [],
|
|
4998
5014
|
setSelectedIndices: noop$1,
|
|
5015
|
+
controlledValueIndices: [],
|
|
5016
|
+
setControlledValueIndices: noop$1,
|
|
4999
5017
|
options: [],
|
|
5000
5018
|
setOptions: noop$1,
|
|
5001
5019
|
activeIndex: -1,
|
|
@@ -5010,6 +5028,10 @@ var DropdownContext = /*#__PURE__*/React__default.createContext({
|
|
|
5010
5028
|
setHasLabelOnLeft: noop$1,
|
|
5011
5029
|
isKeydownPressed: false,
|
|
5012
5030
|
setIsKeydownPressed: noop$1,
|
|
5031
|
+
changeCallbackTriggerer: 0,
|
|
5032
|
+
setChangeCallbackTriggerer: noop$1,
|
|
5033
|
+
isControlled: false,
|
|
5034
|
+
setIsControlled: noop$1,
|
|
5013
5035
|
dropdownBaseId: '',
|
|
5014
5036
|
actionListItemRef: {
|
|
5015
5037
|
current: null
|
|
@@ -5031,6 +5053,7 @@ var useDropdown = function useDropdown() {
|
|
|
5031
5053
|
var _React$useContext = React__default.useContext(DropdownContext),
|
|
5032
5054
|
isOpen = _React$useContext.isOpen,
|
|
5033
5055
|
setIsOpen = _React$useContext.setIsOpen,
|
|
5056
|
+
close = _React$useContext.close,
|
|
5034
5057
|
selectedIndices = _React$useContext.selectedIndices,
|
|
5035
5058
|
setSelectedIndices = _React$useContext.setSelectedIndices,
|
|
5036
5059
|
activeIndex = _React$useContext.activeIndex,
|
|
@@ -5041,44 +5064,66 @@ var useDropdown = function useDropdown() {
|
|
|
5041
5064
|
setIsKeydownPressed = _React$useContext.setIsKeydownPressed,
|
|
5042
5065
|
options = _React$useContext.options,
|
|
5043
5066
|
selectionType = _React$useContext.selectionType,
|
|
5067
|
+
changeCallbackTriggerer = _React$useContext.changeCallbackTriggerer,
|
|
5068
|
+
setChangeCallbackTriggerer = _React$useContext.setChangeCallbackTriggerer,
|
|
5069
|
+
isControlled = _React$useContext.isControlled,
|
|
5070
|
+
setControlledValueIndices = _React$useContext.setControlledValueIndices,
|
|
5044
5071
|
rest = _objectWithoutProperties$1(_React$useContext, _excluded$4N);
|
|
5045
5072
|
|
|
5046
5073
|
var bottomSheetAndDropdownGlue = useBottomSheetAndDropdownGlue();
|
|
5047
5074
|
|
|
5075
|
+
var setIndices = function setIndices(indices) {
|
|
5076
|
+
if (isControlled) {
|
|
5077
|
+
setControlledValueIndices(indices);
|
|
5078
|
+
} else {
|
|
5079
|
+
setSelectedIndices(indices);
|
|
5080
|
+
}
|
|
5081
|
+
};
|
|
5048
5082
|
/**
|
|
5049
5083
|
* Marks the given index as selected.
|
|
5050
5084
|
*
|
|
5051
5085
|
* In single select, it also closes the menu.
|
|
5052
5086
|
* In multiselect, it keeps the menu open for more selections
|
|
5053
5087
|
*/
|
|
5088
|
+
|
|
5089
|
+
|
|
5054
5090
|
var selectOption = function selectOption(index) {
|
|
5055
5091
|
var properties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
5056
5092
|
closeOnSelection: true
|
|
5057
5093
|
};
|
|
5094
|
+
var isSelected = false;
|
|
5058
5095
|
|
|
5059
5096
|
if (index < 0 || index > options.length - 1) {
|
|
5060
|
-
return;
|
|
5097
|
+
return isSelected;
|
|
5061
5098
|
}
|
|
5062
5099
|
|
|
5063
5100
|
if (selectionType === 'multiple') {
|
|
5064
5101
|
if (selectedIndices.includes(index)) {
|
|
5065
5102
|
// remove existing item
|
|
5066
5103
|
var existingItemIndex = selectedIndices.indexOf(index);
|
|
5067
|
-
|
|
5104
|
+
setIndices([].concat(_toConsumableArray$1(selectedIndices.slice(0, existingItemIndex)), _toConsumableArray$1(selectedIndices.slice(existingItemIndex + 1))));
|
|
5105
|
+
isSelected = false;
|
|
5068
5106
|
} else {
|
|
5069
|
-
|
|
5107
|
+
setIndices([].concat(_toConsumableArray$1(selectedIndices), [index]));
|
|
5108
|
+
isSelected = true;
|
|
5070
5109
|
}
|
|
5071
5110
|
} else {
|
|
5072
|
-
|
|
5073
|
-
|
|
5111
|
+
setIndices([index]);
|
|
5112
|
+
isSelected = true;
|
|
5113
|
+
} // Triggers `onChange` on SelectInput
|
|
5114
|
+
|
|
5115
|
+
|
|
5116
|
+
setChangeCallbackTriggerer(changeCallbackTriggerer + 1);
|
|
5074
5117
|
|
|
5075
5118
|
if (activeIndex !== index) {
|
|
5076
5119
|
setActiveIndex(index);
|
|
5077
5120
|
}
|
|
5078
5121
|
|
|
5079
5122
|
if (properties !== null && properties !== void 0 && properties.closeOnSelection && selectionType !== 'multiple') {
|
|
5080
|
-
|
|
5123
|
+
close();
|
|
5081
5124
|
}
|
|
5125
|
+
|
|
5126
|
+
return isSelected;
|
|
5082
5127
|
};
|
|
5083
5128
|
/**
|
|
5084
5129
|
* Click listener for combobox (or any triggerer of the dropdown)
|
|
@@ -5086,7 +5131,11 @@ var useDropdown = function useDropdown() {
|
|
|
5086
5131
|
|
|
5087
5132
|
|
|
5088
5133
|
var onTriggerClick = function onTriggerClick() {
|
|
5089
|
-
|
|
5134
|
+
if (isOpen) {
|
|
5135
|
+
close();
|
|
5136
|
+
} else {
|
|
5137
|
+
setIsOpen(true);
|
|
5138
|
+
}
|
|
5090
5139
|
};
|
|
5091
5140
|
/**
|
|
5092
5141
|
* Blur handler on combobox. Also handles the selection logic when user moves focus
|
|
@@ -5125,7 +5174,7 @@ var useDropdown = function useDropdown() {
|
|
|
5125
5174
|
}
|
|
5126
5175
|
|
|
5127
5176
|
if (!(bottomSheetAndDropdownGlue !== null && bottomSheetAndDropdownGlue !== void 0 && bottomSheetAndDropdownGlue.dropdownHasBottomSheet)) {
|
|
5128
|
-
|
|
5177
|
+
close();
|
|
5129
5178
|
}
|
|
5130
5179
|
}
|
|
5131
5180
|
};
|
|
@@ -5229,12 +5278,13 @@ var useDropdown = function useDropdown() {
|
|
|
5229
5278
|
if (actionType) {
|
|
5230
5279
|
performAction(actionType, e, {
|
|
5231
5280
|
setIsOpen: setIsOpen,
|
|
5281
|
+
close: close,
|
|
5232
5282
|
onOptionChange: onOptionChange,
|
|
5233
5283
|
onComboType: onComboType,
|
|
5234
5284
|
selectCurrentOption: function selectCurrentOption() {
|
|
5235
|
-
var _options$activeIndex;
|
|
5285
|
+
var _options$activeIndex$, _options$activeIndex;
|
|
5236
5286
|
|
|
5237
|
-
selectOption(activeIndex);
|
|
5287
|
+
var isSelected = selectOption(activeIndex);
|
|
5238
5288
|
|
|
5239
5289
|
if (rest.hasFooterAction && !isReactNative$4()) {
|
|
5240
5290
|
var _rest$triggererRef$cu2;
|
|
@@ -5242,15 +5292,7 @@ var useDropdown = function useDropdown() {
|
|
|
5242
5292
|
(_rest$triggererRef$cu2 = rest.triggererRef.current) === null || _rest$triggererRef$cu2 === void 0 ? void 0 : _rest$triggererRef$cu2.focus();
|
|
5243
5293
|
}
|
|
5244
5294
|
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
if (anchorLink) {
|
|
5248
|
-
window.location.href = anchorLink;
|
|
5249
|
-
|
|
5250
|
-
if (window.top) {
|
|
5251
|
-
window.top.location.href = anchorLink;
|
|
5252
|
-
}
|
|
5253
|
-
}
|
|
5295
|
+
(_options$activeIndex$ = (_options$activeIndex = options[activeIndex]).onClickTrigger) === null || _options$activeIndex$ === void 0 ? void 0 : _options$activeIndex$.call(_options$activeIndex, isSelected);
|
|
5254
5296
|
}
|
|
5255
5297
|
});
|
|
5256
5298
|
}
|
|
@@ -5259,8 +5301,10 @@ var useDropdown = function useDropdown() {
|
|
|
5259
5301
|
return _objectSpread$5l({
|
|
5260
5302
|
isOpen: isOpen,
|
|
5261
5303
|
setIsOpen: setIsOpen,
|
|
5304
|
+
close: close,
|
|
5262
5305
|
selectedIndices: selectedIndices,
|
|
5263
5306
|
setSelectedIndices: setSelectedIndices,
|
|
5307
|
+
setControlledValueIndices: setControlledValueIndices,
|
|
5264
5308
|
onTriggerClick: onTriggerClick,
|
|
5265
5309
|
onTriggerKeydown: onTriggerKeydown,
|
|
5266
5310
|
onTriggerBlur: onTriggerBlur,
|
|
@@ -5271,6 +5315,9 @@ var useDropdown = function useDropdown() {
|
|
|
5271
5315
|
setShouldIgnoreBlur: setShouldIgnoreBlur,
|
|
5272
5316
|
isKeydownPressed: isKeydownPressed,
|
|
5273
5317
|
setIsKeydownPressed: setIsKeydownPressed,
|
|
5318
|
+
changeCallbackTriggerer: changeCallbackTriggerer,
|
|
5319
|
+
setChangeCallbackTriggerer: setChangeCallbackTriggerer,
|
|
5320
|
+
isControlled: isControlled,
|
|
5274
5321
|
options: options,
|
|
5275
5322
|
value: makeInputValue(selectedIndices, options),
|
|
5276
5323
|
displayValue: makeInputDisplayValue(selectedIndices, options),
|
|
@@ -5350,7 +5397,6 @@ var _ActionList = function _ActionList(_ref) {
|
|
|
5350
5397
|
actionListItemRef = _useDropdown.actionListItemRef,
|
|
5351
5398
|
selectionType = _useDropdown.selectionType,
|
|
5352
5399
|
dropdownBaseId = _useDropdown.dropdownBaseId,
|
|
5353
|
-
setSelectedIndices = _useDropdown.setSelectedIndices,
|
|
5354
5400
|
dropdownTriggerer = _useDropdown.dropdownTriggerer,
|
|
5355
5401
|
hasFooterAction = _useDropdown.hasFooterAction;
|
|
5356
5402
|
|
|
@@ -5366,16 +5412,12 @@ var _ActionList = function _ActionList(_ref) {
|
|
|
5366
5412
|
sectionData = _React$useMemo.sectionData,
|
|
5367
5413
|
childrenWithId = _React$useMemo.childrenWithId,
|
|
5368
5414
|
actionListOptions = _React$useMemo.actionListOptions,
|
|
5369
|
-
defaultSelectedIndices = _React$useMemo.defaultSelectedIndices,
|
|
5370
5415
|
actionListHeaderChild = _React$useMemo.actionListHeaderChild,
|
|
5371
5416
|
actionListFooterChild = _React$useMemo.actionListFooterChild;
|
|
5372
5417
|
|
|
5373
5418
|
React__default.useEffect(function () {
|
|
5374
5419
|
setOptions(actionListOptions); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5375
5420
|
}, [actionListOptions]);
|
|
5376
|
-
React__default.useEffect(function () {
|
|
5377
|
-
setSelectedIndices(defaultSelectedIndices); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5378
|
-
}, []);
|
|
5379
5421
|
var actionListContainerRole = getActionListContainerRole(hasFooterAction, dropdownTriggerer);
|
|
5380
5422
|
var actionListItemWrapperRole = getActionListItemWrapperRole(hasFooterAction, dropdownTriggerer);
|
|
5381
5423
|
var isMultiSelectable = selectionType === 'multiple';
|
|
@@ -17928,7 +17970,26 @@ var _ActionListItem = function _ActionListItem(props) {
|
|
|
17928
17970
|
|
|
17929
17971
|
var isMobile = platform === 'onMobile';
|
|
17930
17972
|
var renderOnWebAs = props.href ? 'a' : 'button';
|
|
17931
|
-
|
|
17973
|
+
/**
|
|
17974
|
+
* In SelectInput, returns the isSelected according to selected indexes in the state
|
|
17975
|
+
*
|
|
17976
|
+
* In Other Triggers (Menu Usecase), returns `props.isSelected` since passing the
|
|
17977
|
+
* isSelected prop explicitly is the only way to select item in menu
|
|
17978
|
+
*/
|
|
17979
|
+
|
|
17980
|
+
var getIsSelected = function getIsSelected() {
|
|
17981
|
+
if (dropdownTriggerer === 'SelectInput') {
|
|
17982
|
+
if (typeof props._index === 'number') {
|
|
17983
|
+
return selectedIndices.includes(props._index);
|
|
17984
|
+
}
|
|
17985
|
+
|
|
17986
|
+
return undefined;
|
|
17987
|
+
}
|
|
17988
|
+
|
|
17989
|
+
return props.isSelected;
|
|
17990
|
+
};
|
|
17991
|
+
|
|
17992
|
+
var isSelected = getIsSelected();
|
|
17932
17993
|
React__default.useEffect(function () {
|
|
17933
17994
|
validateActionListItemProps({
|
|
17934
17995
|
leading: props.leading,
|
|
@@ -17951,6 +18012,7 @@ var _ActionListItem = function _ActionListItem(props) {
|
|
|
17951
18012
|
type: "button",
|
|
17952
18013
|
tabIndex: -1,
|
|
17953
18014
|
href: props.href,
|
|
18015
|
+
target: props.target,
|
|
17954
18016
|
className: activeIndex === props._index ? 'active-focus' : ''
|
|
17955
18017
|
}, makeAccessible({
|
|
17956
18018
|
selected: isSelected,
|
|
@@ -17958,16 +18020,15 @@ var _ActionListItem = function _ActionListItem(props) {
|
|
|
17958
18020
|
role: getActionListItemRole(dropdownTriggerer, props.href),
|
|
17959
18021
|
disabled: props.isDisabled
|
|
17960
18022
|
})), makeActionListItemClickable(function (e) {
|
|
17961
|
-
var _props$onClick;
|
|
17962
|
-
|
|
17963
18023
|
if (typeof props._index === 'number') {
|
|
18024
|
+
var _props$onClick;
|
|
18025
|
+
|
|
17964
18026
|
onOptionClick(e, props._index);
|
|
18027
|
+
(_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props, {
|
|
18028
|
+
name: props.value,
|
|
18029
|
+
value: isSelected
|
|
18030
|
+
});
|
|
17965
18031
|
}
|
|
17966
|
-
|
|
17967
|
-
(_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props, {
|
|
17968
|
-
name: props.value,
|
|
17969
|
-
value: isSelected
|
|
17970
|
-
});
|
|
17971
18032
|
})), metaAttribute({
|
|
17972
18033
|
name: MetaConstants.ActionListItem,
|
|
17973
18034
|
testID: props.testID
|
|
@@ -18006,7 +18067,8 @@ var _ActionListItem = function _ActionListItem(props) {
|
|
|
18006
18067
|
};
|
|
18007
18068
|
|
|
18008
18069
|
var ActionListItem = /*#__PURE__*/assignWithoutSideEffects( /*#__PURE__*/React__default.memo(_ActionListItem), {
|
|
18009
|
-
componentId: componentIds$1.ActionListItem
|
|
18070
|
+
componentId: componentIds$1.ActionListItem,
|
|
18071
|
+
displayName: componentIds$1.ActionListItem
|
|
18010
18072
|
});
|
|
18011
18073
|
|
|
18012
18074
|
function ownKeys$Q(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -18132,7 +18194,7 @@ var _ActionListFooter = function _ActionListFooter(props) {
|
|
|
18132
18194
|
setHasFooterAction = _useDropdown.setHasFooterAction,
|
|
18133
18195
|
onTriggerKeydown = _useDropdown.onTriggerKeydown,
|
|
18134
18196
|
activeIndex = _useDropdown.activeIndex,
|
|
18135
|
-
|
|
18197
|
+
close = _useDropdown.close,
|
|
18136
18198
|
selectionType = _useDropdown.selectionType;
|
|
18137
18199
|
|
|
18138
18200
|
var bottomSheetAndDropdownGlue = useBottomSheetAndDropdownGlue();
|
|
@@ -18169,7 +18231,7 @@ var _ActionListFooter = function _ActionListFooter(props) {
|
|
|
18169
18231
|
if (shouldIgnoreDropdownKeydown) {
|
|
18170
18232
|
if (selectionType === 'single' && !(bottomSheetAndDropdownGlue !== null && bottomSheetAndDropdownGlue !== void 0 && bottomSheetAndDropdownGlue.dropdownHasBottomSheet)) {
|
|
18171
18233
|
// We close the dropdown on clicks in single select
|
|
18172
|
-
|
|
18234
|
+
close();
|
|
18173
18235
|
}
|
|
18174
18236
|
|
|
18175
18237
|
return;
|
|
@@ -18186,7 +18248,7 @@ var _ActionListFooter = function _ActionListFooter(props) {
|
|
|
18186
18248
|
var nextItemRole = nextItem === null || nextItem === void 0 ? void 0 : nextItem.getAttribute('role');
|
|
18187
18249
|
|
|
18188
18250
|
if (nextItemRole !== 'combobox' && nextItemRole !== 'option' && !(bottomSheetAndDropdownGlue !== null && bottomSheetAndDropdownGlue !== void 0 && bottomSheetAndDropdownGlue.dropdownHasBottomSheet)) {
|
|
18189
|
-
|
|
18251
|
+
close();
|
|
18190
18252
|
}
|
|
18191
18253
|
}
|
|
18192
18254
|
}, makeAccessible({
|
|
@@ -18774,7 +18836,7 @@ var getStringFromReactText = function getStringFromReactText(childReactText) {
|
|
|
18774
18836
|
return String(childReactText);
|
|
18775
18837
|
};
|
|
18776
18838
|
|
|
18777
|
-
var _excluded$o = ["variant", "intent", "contrast", "size", "icon", "iconPosition", "isDisabled", "isFullWidth", "isLoading", "onClick", "type", "children", "accessibilityLabel", "testID"];
|
|
18839
|
+
var _excluded$o = ["variant", "intent", "contrast", "size", "icon", "iconPosition", "isDisabled", "isFullWidth", "isLoading", "onClick", "onBlur", "onKeyDown", "type", "children", "accessibilityLabel", "testID"];
|
|
18778
18840
|
|
|
18779
18841
|
function ownKeys$L(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18780
18842
|
|
|
@@ -18965,6 +19027,8 @@ var _BaseButton = function _BaseButton(_ref4, ref) {
|
|
|
18965
19027
|
_ref4$isLoading = _ref4.isLoading,
|
|
18966
19028
|
isLoading = _ref4$isLoading === void 0 ? false : _ref4$isLoading,
|
|
18967
19029
|
onClick = _ref4.onClick,
|
|
19030
|
+
onBlur = _ref4.onBlur,
|
|
19031
|
+
onKeyDown = _ref4.onKeyDown,
|
|
18968
19032
|
_ref4$type = _ref4.type,
|
|
18969
19033
|
type = _ref4$type === void 0 ? 'button' : _ref4$type,
|
|
18970
19034
|
children = _ref4.children,
|
|
@@ -19051,6 +19115,8 @@ var _BaseButton = function _BaseButton(_ref4, ref) {
|
|
|
19051
19115
|
hoverBackgroundColor: hoverBackgroundColor,
|
|
19052
19116
|
isFullWidth: isFullWidth,
|
|
19053
19117
|
onClick: onClick,
|
|
19118
|
+
onBlur: onBlur,
|
|
19119
|
+
onKeyDown: onKeyDown,
|
|
19054
19120
|
type: type,
|
|
19055
19121
|
borderWidth: borderWidth,
|
|
19056
19122
|
borderRadius: borderRadius,
|
|
@@ -20146,7 +20212,8 @@ function ownKeys$C(object, enumerableOnly) { var keys = Object.keys(object); if
|
|
|
20146
20212
|
|
|
20147
20213
|
function _objectSpread$B(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$C(Object(source), !0).forEach(function (key) { _defineProperty$2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$C(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20148
20214
|
|
|
20149
|
-
var _Button = function _Button(
|
|
20215
|
+
var _Button = function _Button( // While adding any prop here, make sure to handle it in DropdownButton as well
|
|
20216
|
+
_ref, ref) {
|
|
20150
20217
|
var children = _ref.children,
|
|
20151
20218
|
icon = _ref.icon,
|
|
20152
20219
|
_ref$iconPosition = _ref.iconPosition,
|
|
@@ -20632,7 +20699,7 @@ var ComponentIds$1 = {
|
|
|
20632
20699
|
BottomSheetGrabHandle: 'BottomSheetGrabHandle'
|
|
20633
20700
|
};
|
|
20634
20701
|
|
|
20635
|
-
var _excluded$g = ["children", "selectionType"];
|
|
20702
|
+
var _excluded$g = ["children", "selectionType", "onDismiss"];
|
|
20636
20703
|
|
|
20637
20704
|
function ownKeys$x(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20638
20705
|
|
|
@@ -20668,6 +20735,7 @@ var _Dropdown = function _Dropdown(_ref) {
|
|
|
20668
20735
|
var children = _ref.children,
|
|
20669
20736
|
_ref$selectionType = _ref.selectionType,
|
|
20670
20737
|
selectionType = _ref$selectionType === void 0 ? 'single' : _ref$selectionType,
|
|
20738
|
+
onDismiss = _ref.onDismiss,
|
|
20671
20739
|
styledProps = _objectWithoutProperties$1(_ref, _excluded$g);
|
|
20672
20740
|
|
|
20673
20741
|
var _React$useState = React__default.useState(false),
|
|
@@ -20685,64 +20753,90 @@ var _Dropdown = function _Dropdown(_ref) {
|
|
|
20685
20753
|
selectedIndices = _React$useState6[0],
|
|
20686
20754
|
setSelectedIndices = _React$useState6[1];
|
|
20687
20755
|
|
|
20688
|
-
var _React$useState7 = React__default.useState(
|
|
20756
|
+
var _React$useState7 = React__default.useState([]),
|
|
20689
20757
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
20690
|
-
|
|
20691
|
-
|
|
20758
|
+
controlledValueIndices = _React$useState8[0],
|
|
20759
|
+
setControlledValueIndices = _React$useState8[1];
|
|
20692
20760
|
|
|
20693
|
-
var _React$useState9 = React__default.useState(
|
|
20761
|
+
var _React$useState9 = React__default.useState(-1),
|
|
20694
20762
|
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
20695
|
-
|
|
20696
|
-
|
|
20763
|
+
activeIndex = _React$useState10[0],
|
|
20764
|
+
setActiveIndex = _React$useState10[1];
|
|
20697
20765
|
|
|
20698
20766
|
var _React$useState11 = React__default.useState(false),
|
|
20699
20767
|
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
20700
|
-
|
|
20701
|
-
|
|
20702
|
-
|
|
20703
|
-
var triggererRef = React__default.useRef(null);
|
|
20704
|
-
var actionListItemRef = React__default.useRef(null);
|
|
20768
|
+
shouldIgnoreBlur = _React$useState12[0],
|
|
20769
|
+
setShouldIgnoreBlur = _React$useState12[1];
|
|
20705
20770
|
|
|
20706
20771
|
var _React$useState13 = React__default.useState(false),
|
|
20707
20772
|
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
20708
|
-
|
|
20709
|
-
|
|
20773
|
+
shouldIgnoreBlurAnimation = _React$useState14[0],
|
|
20774
|
+
setShouldIgnoreBlurAnimation = _React$useState14[1];
|
|
20775
|
+
|
|
20776
|
+
var triggererRef = React__default.useRef(null);
|
|
20777
|
+
var actionListItemRef = React__default.useRef(null);
|
|
20710
20778
|
|
|
20711
20779
|
var _React$useState15 = React__default.useState(false),
|
|
20712
20780
|
_React$useState16 = _slicedToArray(_React$useState15, 2),
|
|
20713
|
-
|
|
20714
|
-
|
|
20781
|
+
hasFooterAction = _React$useState16[0],
|
|
20782
|
+
setHasFooterAction = _React$useState16[1];
|
|
20715
20783
|
|
|
20716
20784
|
var _React$useState17 = React__default.useState(false),
|
|
20717
20785
|
_React$useState18 = _slicedToArray(_React$useState17, 2),
|
|
20718
|
-
|
|
20719
|
-
|
|
20720
|
-
|
|
20786
|
+
hasLabelOnLeft = _React$useState18[0],
|
|
20787
|
+
setHasLabelOnLeft = _React$useState18[1];
|
|
20721
20788
|
|
|
20722
20789
|
var _React$useState19 = React__default.useState(false),
|
|
20723
20790
|
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
20724
|
-
|
|
20725
|
-
|
|
20791
|
+
isKeydownPressed = _React$useState20[0],
|
|
20792
|
+
setIsKeydownPressed = _React$useState20[1];
|
|
20793
|
+
|
|
20794
|
+
var _React$useState21 = React__default.useState(0),
|
|
20795
|
+
_React$useState22 = _slicedToArray(_React$useState21, 2),
|
|
20796
|
+
changeCallbackTriggerer = _React$useState22[0],
|
|
20797
|
+
setChangeCallbackTriggerer = _React$useState22[1];
|
|
20798
|
+
|
|
20799
|
+
var _React$useState23 = React__default.useState(false),
|
|
20800
|
+
_React$useState24 = _slicedToArray(_React$useState23, 2),
|
|
20801
|
+
isControlled = _React$useState24[0],
|
|
20802
|
+
setIsControlled = _React$useState24[1]; // keep track if dropdown contains bottomsheet
|
|
20803
|
+
|
|
20804
|
+
|
|
20805
|
+
var _React$useState25 = React__default.useState(false),
|
|
20806
|
+
_React$useState26 = _slicedToArray(_React$useState25, 2),
|
|
20807
|
+
dropdownHasBottomSheet = _React$useState26[0],
|
|
20808
|
+
setDropdownHasBottomSheet = _React$useState26[1];
|
|
20726
20809
|
|
|
20727
20810
|
var dropdownBaseId = useId('dropdown');
|
|
20728
20811
|
var dropdownTriggerer = React__default.useRef();
|
|
20812
|
+
var close = React__default.useCallback(function () {
|
|
20813
|
+
setIsOpen(false);
|
|
20814
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
20815
|
+
}, [onDismiss]);
|
|
20729
20816
|
React__default.Children.map(children, function (child) {
|
|
20730
20817
|
if ( /*#__PURE__*/React__default.isValidElement(child)) {
|
|
20731
|
-
if (!isValidAllowedChildren(child,
|
|
20818
|
+
if (!isValidAllowedChildren(child, componentIds.triggers.SelectInput) && !isValidAllowedChildren(child, componentIds.triggers.DropdownButton) && !isValidAllowedChildren(child, componentIds.DropdownOverlay) && !isValidAllowedChildren(child, ComponentIds$1.BottomSheet)) {
|
|
20732
20819
|
throw new Error("[Dropdown]: Dropdown can only have `SelectInput` and `DropdownOverlay` as children\n\n Check out: https://blade.razorpay.com/?path=/story/components-dropdown");
|
|
20733
20820
|
}
|
|
20734
20821
|
|
|
20735
|
-
if (isValidAllowedChildren(child,
|
|
20822
|
+
if (isValidAllowedChildren(child, componentIds.triggers.SelectInput)) {
|
|
20736
20823
|
dropdownTriggerer.current = 'SelectInput';
|
|
20737
20824
|
}
|
|
20825
|
+
|
|
20826
|
+
if (isValidAllowedChildren(child, componentIds.triggers.DropdownButton)) {
|
|
20827
|
+
dropdownTriggerer.current = 'DropdownButton';
|
|
20828
|
+
}
|
|
20738
20829
|
}
|
|
20739
20830
|
});
|
|
20740
20831
|
var contextValue = React__default.useMemo(function () {
|
|
20741
20832
|
return {
|
|
20742
20833
|
isOpen: isOpen,
|
|
20743
20834
|
setIsOpen: setIsOpen,
|
|
20835
|
+
close: close,
|
|
20744
20836
|
selectedIndices: selectedIndices,
|
|
20745
20837
|
setSelectedIndices: setSelectedIndices,
|
|
20838
|
+
controlledValueIndices: controlledValueIndices,
|
|
20839
|
+
setControlledValueIndices: setControlledValueIndices,
|
|
20746
20840
|
options: options,
|
|
20747
20841
|
setOptions: setOptions,
|
|
20748
20842
|
activeIndex: activeIndex,
|
|
@@ -20761,23 +20855,24 @@ var _Dropdown = function _Dropdown(_ref) {
|
|
|
20761
20855
|
setHasFooterAction: setHasFooterAction,
|
|
20762
20856
|
hasLabelOnLeft: hasLabelOnLeft,
|
|
20763
20857
|
setHasLabelOnLeft: setHasLabelOnLeft,
|
|
20764
|
-
dropdownTriggerer: dropdownTriggerer.current
|
|
20858
|
+
dropdownTriggerer: dropdownTriggerer.current,
|
|
20859
|
+
changeCallbackTriggerer: changeCallbackTriggerer,
|
|
20860
|
+
setChangeCallbackTriggerer: setChangeCallbackTriggerer,
|
|
20861
|
+
isControlled: isControlled,
|
|
20862
|
+
setIsControlled: setIsControlled
|
|
20765
20863
|
};
|
|
20766
20864
|
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20767
|
-
[isOpen, selectedIndices, options, activeIndex, shouldIgnoreBlur, shouldIgnoreBlurAnimation, selectionType, hasFooterAction, hasLabelOnLeft, isKeydownPressed]);
|
|
20768
|
-
// Basically <BottomSheet onDismiss={onBottomSheetDismiss} />
|
|
20769
|
-
|
|
20770
|
-
var onBottomSheetDismiss = React__default.useCallback(function () {
|
|
20771
|
-
setIsOpen(false);
|
|
20772
|
-
}, []);
|
|
20865
|
+
[isOpen, selectedIndices, controlledValueIndices, options, activeIndex, shouldIgnoreBlur, shouldIgnoreBlurAnimation, selectionType, hasFooterAction, hasLabelOnLeft, isKeydownPressed, changeCallbackTriggerer, isControlled]);
|
|
20773
20866
|
var BottomSheetAndDropdownGlueContextValue = React__default.useMemo(function () {
|
|
20774
20867
|
return {
|
|
20775
20868
|
isOpen: isOpen,
|
|
20776
20869
|
dropdownHasBottomSheet: dropdownHasBottomSheet,
|
|
20777
20870
|
setDropdownHasBottomSheet: setDropdownHasBottomSheet,
|
|
20778
|
-
|
|
20871
|
+
// This is the dismiss function which will be injected into the BottomSheet
|
|
20872
|
+
// Basically <BottomSheet onDismiss={onBottomSheetDismiss} />
|
|
20873
|
+
onBottomSheetDismiss: close
|
|
20779
20874
|
};
|
|
20780
|
-
}, [dropdownHasBottomSheet, isOpen,
|
|
20875
|
+
}, [dropdownHasBottomSheet, isOpen, close]);
|
|
20781
20876
|
return /*#__PURE__*/jsx(BottomSheetAndDropdownGlueContext.Provider, {
|
|
20782
20877
|
value: BottomSheetAndDropdownGlueContextValue,
|
|
20783
20878
|
children: /*#__PURE__*/jsx(DropdownContext.Provider, {
|
|
@@ -23231,7 +23326,7 @@ var SelectChevronIcon = function SelectChevronIcon(props) {
|
|
|
23231
23326
|
});
|
|
23232
23327
|
};
|
|
23233
23328
|
|
|
23234
|
-
var _excluded$7 = ["icon", "onChange", "placeholder", "onBlur"];
|
|
23329
|
+
var _excluded$7 = ["icon", "onChange", "defaultValue", "placeholder", "onBlur"];
|
|
23235
23330
|
|
|
23236
23331
|
function ownKeys$k(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23237
23332
|
|
|
@@ -23253,7 +23348,15 @@ var _SelectInput = function _SelectInput(props, ref) {
|
|
|
23253
23348
|
hasFooterAction = _useDropdown.hasFooterAction,
|
|
23254
23349
|
dropdownTriggerer = _useDropdown.dropdownTriggerer,
|
|
23255
23350
|
shouldIgnoreBlurAnimation = _useDropdown.shouldIgnoreBlurAnimation,
|
|
23256
|
-
setHasLabelOnLeft = _useDropdown.setHasLabelOnLeft
|
|
23351
|
+
setHasLabelOnLeft = _useDropdown.setHasLabelOnLeft,
|
|
23352
|
+
setSelectedIndices = _useDropdown.setSelectedIndices,
|
|
23353
|
+
controlledValueIndices = _useDropdown.controlledValueIndices,
|
|
23354
|
+
options = _useDropdown.options,
|
|
23355
|
+
changeCallbackTriggerer = _useDropdown.changeCallbackTriggerer,
|
|
23356
|
+
isControlled = _useDropdown.isControlled,
|
|
23357
|
+
setIsControlled = _useDropdown.setIsControlled,
|
|
23358
|
+
selectionType = _useDropdown.selectionType,
|
|
23359
|
+
selectedIndices = _useDropdown.selectedIndices;
|
|
23257
23360
|
|
|
23258
23361
|
var inputRef = useBladeInnerRef(ref, {
|
|
23259
23362
|
onFocus: function onFocus(opts) {
|
|
@@ -23263,19 +23366,92 @@ var _SelectInput = function _SelectInput(props, ref) {
|
|
|
23263
23366
|
}
|
|
23264
23367
|
});
|
|
23265
23368
|
|
|
23266
|
-
var icon = props.icon
|
|
23267
|
-
|
|
23268
|
-
|
|
23369
|
+
var icon = props.icon;
|
|
23370
|
+
props.onChange;
|
|
23371
|
+
props.defaultValue;
|
|
23372
|
+
var _props$placeholder = props.placeholder,
|
|
23269
23373
|
placeholder = _props$placeholder === void 0 ? 'Select Option' : _props$placeholder,
|
|
23270
23374
|
_onBlur = props.onBlur,
|
|
23271
23375
|
baseInputProps = _objectWithoutProperties$1(props, _excluded$7);
|
|
23272
23376
|
|
|
23377
|
+
var getValuesArrayFromIndices = function getValuesArrayFromIndices() {
|
|
23378
|
+
var indices = [];
|
|
23379
|
+
|
|
23380
|
+
if (isControlled) {
|
|
23381
|
+
indices = controlledValueIndices;
|
|
23382
|
+
} else {
|
|
23383
|
+
indices = selectedIndices;
|
|
23384
|
+
}
|
|
23385
|
+
|
|
23386
|
+
return indices.map(function (selectionIndex) {
|
|
23387
|
+
return options[selectionIndex].value;
|
|
23388
|
+
});
|
|
23389
|
+
};
|
|
23390
|
+
|
|
23391
|
+
var isFirstRenderRef = React__default.useRef(true);
|
|
23392
|
+
|
|
23393
|
+
var selectValues = function selectValues(valuesToSelect) {
|
|
23394
|
+
if (options.length > 0) {
|
|
23395
|
+
if (typeof valuesToSelect === 'string') {
|
|
23396
|
+
// single select control
|
|
23397
|
+
var selectedItemIndex = options.findIndex(function (option) {
|
|
23398
|
+
return option.value === valuesToSelect;
|
|
23399
|
+
});
|
|
23400
|
+
|
|
23401
|
+
if (selectedItemIndex >= 0) {
|
|
23402
|
+
setSelectedIndices([selectedItemIndex]);
|
|
23403
|
+
}
|
|
23404
|
+
} else {
|
|
23405
|
+
// multiselect control
|
|
23406
|
+
// Handles repeated values in user state
|
|
23407
|
+
var uniqueValues = Array.from(new Set(valuesToSelect)); // Handle selectionType single with multiselect values
|
|
23408
|
+
|
|
23409
|
+
var userValues = selectionType === 'single' ? [valuesToSelect === null || valuesToSelect === void 0 ? void 0 : valuesToSelect[0]] : uniqueValues;
|
|
23410
|
+
var selectedItemIndices = userValues.map(function (optionValue) {
|
|
23411
|
+
return options.findIndex(function (option) {
|
|
23412
|
+
return option.value === optionValue;
|
|
23413
|
+
});
|
|
23414
|
+
}).filter(function (value) {
|
|
23415
|
+
return value >= 0;
|
|
23416
|
+
});
|
|
23417
|
+
setSelectedIndices(selectedItemIndices);
|
|
23418
|
+
}
|
|
23419
|
+
}
|
|
23420
|
+
}; // Handles `defaultValue` prop
|
|
23421
|
+
|
|
23422
|
+
|
|
23273
23423
|
React__default.useEffect(function () {
|
|
23274
|
-
|
|
23275
|
-
|
|
23276
|
-
|
|
23277
|
-
|
|
23278
|
-
}, [
|
|
23424
|
+
if (options.length > 0 && props.defaultValue) {
|
|
23425
|
+
selectValues(props.defaultValue);
|
|
23426
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23427
|
+
|
|
23428
|
+
}, [options.length]); // Handles `value` prop
|
|
23429
|
+
|
|
23430
|
+
React__default.useEffect(function () {
|
|
23431
|
+
if (options.length > 0 && props.value) {
|
|
23432
|
+
if (!isControlled) {
|
|
23433
|
+
setIsControlled(true);
|
|
23434
|
+
}
|
|
23435
|
+
|
|
23436
|
+
selectValues(props.value);
|
|
23437
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23438
|
+
|
|
23439
|
+
}, [props.value, options]);
|
|
23440
|
+
React__default.useEffect(function () {
|
|
23441
|
+
// Ignore calling onChange on mount
|
|
23442
|
+
if (isFirstRenderRef.current) {
|
|
23443
|
+
isFirstRenderRef.current = false;
|
|
23444
|
+
return;
|
|
23445
|
+
}
|
|
23446
|
+
|
|
23447
|
+
if (props.onChange && !isFirstRenderRef.current) {
|
|
23448
|
+
props.onChange({
|
|
23449
|
+
name: props.name,
|
|
23450
|
+
values: getValuesArrayFromIndices()
|
|
23451
|
+
});
|
|
23452
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23453
|
+
|
|
23454
|
+
}, [changeCallbackTriggerer]);
|
|
23279
23455
|
React__default.useEffect(function () {
|
|
23280
23456
|
setHasLabelOnLeft(props.labelPosition === 'left');
|
|
23281
23457
|
}, [props.labelPosition, setHasLabelOnLeft]);
|
|
@@ -23372,7 +23548,7 @@ var _SelectInput = function _SelectInput(props, ref) {
|
|
|
23372
23548
|
|
|
23373
23549
|
|
|
23374
23550
|
var SelectInput = /*#__PURE__*/assignWithoutSideEffects( /*#__PURE__*/React__default.forwardRef(_SelectInput), {
|
|
23375
|
-
componentId:
|
|
23551
|
+
componentId: componentIds.triggers.SelectInput
|
|
23376
23552
|
});
|
|
23377
23553
|
|
|
23378
23554
|
var _excluded$6 = ["accessibilityLabel", "children", "size", "intent", "testID"];
|