@hero-design/rn 7.16.2 → 7.17.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.
Files changed (51) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/es/index.js +224 -160
  3. package/lib/index.js +223 -159
  4. package/package.json +2 -2
  5. package/src/components/List/BasicListItem.tsx +8 -4
  6. package/src/components/Select/MultiSelect/Option.tsx +20 -11
  7. package/src/components/Select/MultiSelect/OptionList.tsx +47 -41
  8. package/src/components/Select/MultiSelect/__tests__/OptionList.spec.tsx +25 -14
  9. package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +3 -1
  10. package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1612 -108
  11. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5265 -319
  12. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +122 -1
  13. package/src/components/Select/MultiSelect/index.tsx +26 -36
  14. package/src/components/Select/SingleSelect/Option.tsx +19 -3
  15. package/src/components/Select/SingleSelect/OptionList.tsx +47 -39
  16. package/src/components/Select/SingleSelect/__tests__/OptionList.spec.tsx +23 -12
  17. package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +3 -1
  18. package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1612 -108
  19. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +4898 -268
  20. package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +117 -1
  21. package/src/components/Select/SingleSelect/index.tsx +26 -37
  22. package/src/components/Select/StyledOptionList.tsx +43 -44
  23. package/src/components/Select/StyledSelect.tsx +7 -3
  24. package/src/components/Select/__tests__/StyledSelect.spec.tsx +1 -9
  25. package/src/components/Select/__tests__/__snapshots__/StyledSelect.spec.tsx.snap +0 -13
  26. package/src/components/Select/__tests__/helpers.spec.tsx +74 -0
  27. package/src/components/Select/helpers.tsx +87 -4
  28. package/src/components/Select/types.ts +99 -0
  29. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +157 -1
  30. package/src/components/TextInput/__tests__/index.spec.tsx +29 -8
  31. package/src/components/TextInput/index.tsx +18 -7
  32. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +3 -3
  33. package/src/theme/components/select.ts +3 -3
  34. package/src/types.ts +7 -1
  35. package/types/components/List/BasicListItem.d.ts +1 -1
  36. package/types/components/Select/MultiSelect/Option.d.ts +4 -2
  37. package/types/components/Select/MultiSelect/OptionList.d.ts +6 -7
  38. package/types/components/Select/MultiSelect/index.d.ts +5 -5
  39. package/types/components/Select/SingleSelect/Option.d.ts +4 -2
  40. package/types/components/Select/SingleSelect/OptionList.d.ts +6 -7
  41. package/types/components/Select/SingleSelect/index.d.ts +5 -5
  42. package/types/components/Select/StyledOptionList.d.ts +10 -16
  43. package/types/components/Select/StyledSelect.d.ts +8 -2
  44. package/types/components/Select/__tests__/helpers.spec.d.ts +1 -0
  45. package/types/components/Select/helpers.d.ts +14 -2
  46. package/types/components/Select/index.d.ts +1 -1
  47. package/types/components/Select/types.d.ts +32 -7
  48. package/types/components/TextInput/index.d.ts +4 -2
  49. package/types/theme/components/select.d.ts +3 -3
  50. package/types/types.d.ts +2 -1
  51. package/src/components/Select/types.tsx +0 -52
package/lib/index.js CHANGED
@@ -3487,9 +3487,9 @@ var getSelectTheme = function getSelectTheme(theme) {
3487
3487
  };
3488
3488
  var space = {
3489
3489
  minimumOptionListHeight: theme.space.xxxxlarge * 5,
3490
- optionPadding: theme.space.medium,
3491
- optionListPadding: theme.space.medium,
3492
- optionListSpacing: theme.space.xsmall,
3490
+ sectionSpacing: theme.space.smallMedium,
3491
+ optionSpacing: theme.space.xsmall,
3492
+ optionHorizontalMargin: theme.space.smallMedium,
3493
3493
  searchBarMarginTopSpacing: theme.space.small,
3494
3494
  searchBarHorizontalSpacing: theme.space.medium,
3495
3495
  searchBarBottomSpacing: theme.space.small
@@ -18868,11 +18868,12 @@ var StyledErrorAndMaxLengthContainer = index$6(reactNative.View)(function () {
18868
18868
  };
18869
18869
  });
18870
18870
 
18871
- var _excluded$5 = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy", "error", "required", "editable", "disabled", "maxLength", "helpText", "value", "defaultValue"];
18871
+ var _excluded$5 = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy", "error", "required", "editable", "disabled", "loading", "maxLength", "helpText", "value", "defaultValue"];
18872
18872
  var getVariant = function getVariant(_ref) {
18873
18873
  var disabled = _ref.disabled,
18874
18874
  error = _ref.error,
18875
18875
  editable = _ref.editable,
18876
+ loading = _ref.loading,
18876
18877
  isFocused = _ref.isFocused,
18877
18878
  isEmptyValue = _ref.isEmptyValue;
18878
18879
 
@@ -18884,7 +18885,7 @@ var getVariant = function getVariant(_ref) {
18884
18885
  return 'error';
18885
18886
  }
18886
18887
 
18887
- if (!editable) {
18888
+ if (!editable || loading) {
18888
18889
  return 'readonly';
18889
18890
  }
18890
18891
 
@@ -18915,6 +18916,8 @@ var TextInput = function TextInput(_ref2) {
18915
18916
  editable = _ref2$editable === void 0 ? true : _ref2$editable,
18916
18917
  _ref2$disabled = _ref2.disabled,
18917
18918
  disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
18919
+ _ref2$loading = _ref2.loading,
18920
+ loading = _ref2$loading === void 0 ? false : _ref2$loading,
18918
18921
  maxLength = _ref2.maxLength,
18919
18922
  helpText = _ref2.helpText,
18920
18923
  value = _ref2.value,
@@ -18924,6 +18927,7 @@ var TextInput = function TextInput(_ref2) {
18924
18927
  var textInputReference = React.useRef(null);
18925
18928
  var displayText = (_ref3 = value !== undefined ? value : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
18926
18929
  var isEmptyValue = displayText.length === 0;
18930
+ var actualSuffix = loading ? 'loading' : suffix;
18927
18931
 
18928
18932
  var _React$useState = React__default["default"].useState(false),
18929
18933
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -18934,6 +18938,7 @@ var TextInput = function TextInput(_ref2) {
18934
18938
  disabled: disabled,
18935
18939
  error: error,
18936
18940
  editable: editable,
18941
+ loading: loading,
18937
18942
  isFocused: isFocused,
18938
18943
  isEmptyValue: isEmptyValue
18939
18944
  });
@@ -18956,7 +18961,7 @@ var TextInput = function TextInput(_ref2) {
18956
18961
  fontSize: "small",
18957
18962
  themeVariant: variant
18958
18963
  }, label)), typeof prefix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
18959
- intent: disabled ? 'disabled-text' : 'text',
18964
+ intent: variant === 'disabled' ? 'disabled-text' : 'text',
18960
18965
  testID: "input-prefix",
18961
18966
  icon: prefix,
18962
18967
  size: "xsmall"
@@ -18977,7 +18982,7 @@ var TextInput = function TextInput(_ref2) {
18977
18982
  }, textStyle]),
18978
18983
  testID: "text-input",
18979
18984
  accessibilityState: {
18980
- disabled: disabled
18985
+ disabled: variant === 'disabled' || variant === 'readonly'
18981
18986
  } // @ts-ignore
18982
18987
  ,
18983
18988
  accessibilityLabelledBy: accessibilityLabelledBy
@@ -19005,10 +19010,11 @@ var TextInput = function TextInput(_ref2) {
19005
19010
  },
19006
19011
  defaultValue: defaultValue,
19007
19012
  placeholder: variant === 'focused' ? nativeProps.placeholder : undefined
19008
- }))), typeof suffix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
19009
- intent: disabled ? 'disabled-text' : 'text',
19013
+ }))), typeof actualSuffix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
19014
+ intent: variant === 'disabled' ? 'disabled-text' : 'text',
19010
19015
  testID: "input-suffix",
19011
- icon: suffix,
19016
+ icon: actualSuffix,
19017
+ spin: actualSuffix === 'loading',
19012
19018
  size: "xsmall"
19013
19019
  }) : suffix), /*#__PURE__*/React__default["default"].createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React__default["default"].createElement(StyledErrorAndMaxLengthContainer, null, error && /*#__PURE__*/React__default["default"].createElement(StyledErrorContainer$1, null, /*#__PURE__*/React__default["default"].createElement(Icon, {
19014
19020
  testID: "input-error-icon",
@@ -19791,10 +19797,10 @@ var BasicListItem = function BasicListItem(_ref) {
19791
19797
  underlayColor: theme.__hd__.list.colors.highlightedListItemContainerBackground
19792
19798
  }, /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, prefix && /*#__PURE__*/React__default["default"].createElement(StyledPrefixContainer, null, typeof prefix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
19793
19799
  icon: prefix
19794
- }) : prefix), /*#__PURE__*/React__default["default"].createElement(StyledTitleContainer, null, /*#__PURE__*/React__default["default"].createElement(Typography.Text, {
19800
+ }) : prefix), /*#__PURE__*/React__default["default"].createElement(StyledTitleContainer, null, typeof title === 'string' ? /*#__PURE__*/React__default["default"].createElement(Typography.Text, {
19795
19801
  intent: "body",
19796
19802
  fontSize: "large"
19797
- }, title), subtitle && /*#__PURE__*/React__default["default"].createElement(Typography.Text, {
19803
+ }, title) : title, subtitle && /*#__PURE__*/React__default["default"].createElement(Typography.Text, {
19798
19804
  intent: "subdued",
19799
19805
  fontSize: "small"
19800
19806
  }, subtitle)), suffix && /*#__PURE__*/React__default["default"].createElement(StyledSuffixContainer, null, typeof suffix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
@@ -20453,7 +20459,7 @@ var Radio = function Radio(_ref) {
20453
20459
  })));
20454
20460
  };
20455
20461
 
20456
- function getKey$1(option, index, keyExtractor) {
20462
+ function getKey(option, index, keyExtractor) {
20457
20463
  var key = '';
20458
20464
 
20459
20465
  if (keyExtractor !== undefined) {
@@ -20479,7 +20485,7 @@ var RadioGroup = function RadioGroup(_ref) {
20479
20485
  testID: testID
20480
20486
  }, options.map(function (option, index) {
20481
20487
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
20482
- key: getKey$1(option, index, keyExtractor)
20488
+ key: getKey(option, index, keyExtractor)
20483
20489
  }, index !== 0 && /*#__PURE__*/React__default["default"].createElement(Spacer, null), /*#__PURE__*/React__default["default"].createElement(Radio, {
20484
20490
  text: option.text,
20485
20491
  checked: option.value === value,
@@ -20561,20 +20567,26 @@ var SectionHeading = function SectionHeading(_ref) {
20561
20567
  }, text)), rightChildren);
20562
20568
  };
20563
20569
 
20564
- index$6(reactNative.View)(function (_ref) {
20570
+ var SectionSpacer = index$6(reactNative.View)(function (_ref) {
20565
20571
  var theme = _ref.theme;
20566
20572
  return {
20567
- marginTop: theme.__hd__.select.space.optionListSpacing
20573
+ marginTop: theme.__hd__.select.space.sectionSpacing
20568
20574
  };
20569
20575
  });
20570
- var FooterText = index$6(Typography.Text)(function (_ref2) {
20576
+ var OptionSpacer = index$6(reactNative.View)(function (_ref2) {
20571
20577
  var theme = _ref2.theme;
20572
20578
  return {
20573
- color: theme.__hd__.select.colors.footerText
20579
+ marginTop: theme.__hd__.select.space.optionSpacing
20574
20580
  };
20575
20581
  });
20576
- var StyledSearchBar = index$6(reactNative.View)(function (_ref3) {
20582
+ var FooterText = index$6(Typography.Text)(function (_ref3) {
20577
20583
  var theme = _ref3.theme;
20584
+ return {
20585
+ color: theme.__hd__.select.colors.footerText
20586
+ };
20587
+ });
20588
+ var StyledSearchBar = index$6(reactNative.View)(function (_ref4) {
20589
+ var theme = _ref4.theme;
20578
20590
  return {
20579
20591
  marginTop: theme.__hd__.select.space.searchBarMarginTopSpacing,
20580
20592
  paddingHorizontal: theme.__hd__.select.space.searchBarHorizontalSpacing,
@@ -20593,18 +20605,70 @@ var Footer = function Footer(_ref) {
20593
20605
  }, label));
20594
20606
  };
20595
20607
 
20596
- var getKey = function getKey(option, index, keyExtractor) {
20597
- var key = '';
20608
+ var isSections = function isSections(options) {
20609
+ var firstOption = options[0];
20610
+ return firstOption !== undefined && firstOption.category !== undefined;
20611
+ };
20612
+ var toSections = function toSections(options) {
20613
+ if (isSections(options)) {
20614
+ return options;
20615
+ }
20598
20616
 
20599
- if (keyExtractor !== undefined) {
20600
- key = keyExtractor(option, index);
20601
- } else if (option.key !== undefined) {
20602
- key = option.key;
20603
- } else {
20604
- key = index;
20617
+ return [{
20618
+ category: '',
20619
+ data: options
20620
+ }];
20621
+ };
20622
+ var toFlatOptions = function toFlatOptions(options) {
20623
+ if (isSections(options)) {
20624
+ return options.flatMap(function (opt) {
20625
+ return opt.data;
20626
+ });
20605
20627
  }
20606
20628
 
20607
- return key;
20629
+ return options;
20630
+ };
20631
+ var getScrollParams = function getScrollParams(value, sections) {
20632
+ var itemIndex = -1;
20633
+ var sectionIndex = sections.findIndex(function (section) {
20634
+ itemIndex = section.data.findIndex(function (opt) {
20635
+ return opt.value === value;
20636
+ });
20637
+ return itemIndex !== -1;
20638
+ });
20639
+ return {
20640
+ sectionIndex: sectionIndex < 0 ? 0 : sectionIndex,
20641
+ itemIndex: itemIndex < 0 ? 0 : itemIndex
20642
+ };
20643
+ };
20644
+ var useKeyboard = function useKeyboard() {
20645
+ var _useState = React.useState(false),
20646
+ _useState2 = _slicedToArray(_useState, 2),
20647
+ isKeyboardVisible = _useState2[0],
20648
+ setKeyboardVisible = _useState2[1];
20649
+
20650
+ var _useState3 = React.useState(0),
20651
+ _useState4 = _slicedToArray(_useState3, 2),
20652
+ keyboardHeight = _useState4[0],
20653
+ setKeyboardHeight = _useState4[1];
20654
+
20655
+ React.useEffect(function () {
20656
+ var keyboardWillShowListener = reactNative.Keyboard.addListener('keyboardWillShow', function (e) {
20657
+ setKeyboardVisible(true);
20658
+ setKeyboardHeight(e.endCoordinates.height);
20659
+ });
20660
+ var keyboardWillHideListener = reactNative.Keyboard.addListener('keyboardWillHide', function () {
20661
+ setKeyboardVisible(false);
20662
+ });
20663
+ return function () {
20664
+ keyboardWillShowListener.remove();
20665
+ keyboardWillHideListener.remove();
20666
+ };
20667
+ }, []);
20668
+ return {
20669
+ isKeyboardVisible: isKeyboardVisible,
20670
+ keyboardHeight: keyboardHeight
20671
+ };
20608
20672
  };
20609
20673
 
20610
20674
  var StyledOptionList = function StyledOptionList(_ref) {
@@ -20612,26 +20676,23 @@ var StyledOptionList = function StyledOptionList(_ref) {
20612
20676
  loading = _ref.loading,
20613
20677
  onEndReached = _ref.onEndReached,
20614
20678
  onQueryChange = _ref.onQueryChange,
20615
- options = _ref.options,
20616
- RenderItem = _ref.RenderItem,
20617
- _ref$scrollIndex = _ref.scrollIndex,
20618
- scrollIndex = _ref$scrollIndex === void 0 ? 0 : _ref$scrollIndex;
20679
+ sections = _ref.sections,
20680
+ renderItem = _ref.renderItem,
20681
+ scrollParams = _ref.scrollParams;
20619
20682
  var theme = useTheme$1();
20620
- var flatListRef = React.useRef(null);
20683
+ var sectionListRef = React.useRef(null);
20621
20684
 
20622
20685
  var _useState = React.useState(false),
20623
20686
  _useState2 = _slicedToArray(_useState, 2),
20624
20687
  onEndReachedCalled = _useState2[0],
20625
20688
  setOnEndReachedCalled = _useState2[1];
20626
20689
 
20627
- return /*#__PURE__*/React__default["default"].createElement(reactNative.FlatList, {
20628
- ref: flatListRef,
20629
- style: _objectSpread2({
20630
- paddingHorizontal: theme.__hd__.select.space.optionListPadding
20631
- }, onQueryChange ? {
20690
+ return /*#__PURE__*/React__default["default"].createElement(reactNative.SectionList, {
20691
+ ref: sectionListRef,
20692
+ style: _objectSpread2({}, onQueryChange ? {
20632
20693
  height: reactNative.Dimensions.get('screen').height
20633
20694
  } : {}),
20634
- data: options,
20695
+ sections: sections,
20635
20696
  keyExtractor: keyExtractor,
20636
20697
  onEndReachedThreshold: 0.1,
20637
20698
  onEndReached: function onEndReached() {
@@ -20639,11 +20700,9 @@ var StyledOptionList = function StyledOptionList(_ref) {
20639
20700
  },
20640
20701
  onScrollToIndexFailed: function onScrollToIndexFailed() {},
20641
20702
  onContentSizeChange: function onContentSizeChange() {
20642
- var _flatListRef$current;
20703
+ var _sectionListRef$curre;
20643
20704
 
20644
- return options.length && ((_flatListRef$current = flatListRef.current) === null || _flatListRef$current === void 0 ? void 0 : _flatListRef$current.scrollToIndex({
20645
- index: scrollIndex
20646
- }));
20705
+ return sections.length && ((_sectionListRef$curre = sectionListRef.current) === null || _sectionListRef$curre === void 0 ? void 0 : _sectionListRef$curre.scrollToLocation(scrollParams));
20647
20706
  },
20648
20707
  onMomentumScrollBegin: function onMomentumScrollBegin() {
20649
20708
  if (onEndReached && onEndReachedCalled && !loading) onEndReached();
@@ -20656,30 +20715,37 @@ var StyledOptionList = function StyledOptionList(_ref) {
20656
20715
  height: theme.space.xxxxlarge
20657
20716
  }
20658
20717
  }, /*#__PURE__*/React__default["default"].createElement(Spinner, null)) : null,
20659
- renderItem: function renderItem(_ref2) {
20660
- var item = _ref2.item,
20661
- index = _ref2.index;
20662
- return /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
20663
- key: getKey(item, index, keyExtractor)
20664
- }, /*#__PURE__*/React__default["default"].createElement(RenderItem, {
20665
- item: item
20666
- }));
20667
- }
20718
+ renderSectionHeader: function renderSectionHeader(_ref2) {
20719
+ var category = _ref2.section.category;
20720
+ return category !== '' ? /*#__PURE__*/React__default["default"].createElement(SectionHeading, {
20721
+ text: category,
20722
+ style: {
20723
+ marginBottom: 0
20724
+ }
20725
+ }) : null;
20726
+ },
20727
+ renderItem: renderItem,
20728
+ ItemSeparatorComponent: OptionSpacer,
20729
+ SectionSeparatorComponent: SectionSpacer
20668
20730
  });
20669
20731
  };
20670
20732
 
20671
20733
  var Option$1 = function Option(_ref) {
20672
20734
  var text = _ref.text,
20735
+ _ref$disabled = _ref.disabled,
20736
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
20673
20737
  selected = _ref.selected,
20674
20738
  onPress = _ref.onPress;
20739
+ var theme = useTheme();
20675
20740
  return /*#__PURE__*/React__default["default"].createElement(List.BasicItem, {
20676
20741
  selected: selected,
20742
+ disabled: disabled,
20677
20743
  onPress: onPress,
20678
20744
  title: text,
20679
- suffix: selected ? /*#__PURE__*/React__default["default"].createElement(Icon, {
20680
- icon: "checkmark",
20681
- size: "small"
20682
- }) : undefined
20745
+ suffix: selected ? 'checkmark' : undefined,
20746
+ style: {
20747
+ marginHorizontal: theme.__hd__.select.space.optionHorizontalMargin
20748
+ }
20683
20749
  });
20684
20750
  };
20685
20751
 
@@ -20687,51 +20753,62 @@ var OptionList$1 = function OptionList(_ref) {
20687
20753
  var keyExtractor = _ref.keyExtractor,
20688
20754
  loading = _ref.loading,
20689
20755
  onEndReached = _ref.onEndReached,
20690
- _onPress = _ref.onPress,
20756
+ onPress = _ref.onPress,
20691
20757
  onQueryChange = _ref.onQueryChange,
20692
- options = _ref.options,
20758
+ sections = _ref.sections,
20759
+ renderOption = _ref.renderOption,
20693
20760
  value = _ref.value;
20694
20761
  var firstValue = value === null || value === void 0 ? void 0 : value[0];
20695
- var rawScrollIndex = firstValue ? options.findIndex(function (option) {
20696
- return option.value === firstValue;
20697
- }) : 0;
20698
- var scrollIndex = rawScrollIndex - 2 >= 0 ? rawScrollIndex - 2 : 0;
20699
- var RenderItem = /*#__PURE__*/React__default["default"].memo(function (_ref2) {
20700
- var item = _ref2.item;
20701
- return /*#__PURE__*/React__default["default"].createElement(Option$1, {
20702
- text: item.text,
20703
- selected: value.includes(item.value),
20704
- onPress: function onPress() {
20705
- if (value.includes(item.value)) {
20706
- _onPress(value.filter(function (val) {
20707
- return val !== item.value;
20708
- }));
20709
- } else {
20710
- _onPress([].concat(_toConsumableArray(value), [item.value]));
20711
- }
20762
+ var scrollParams = getScrollParams(firstValue, sections);
20763
+
20764
+ var renderItem = function renderItem(info) {
20765
+ var item = info.item;
20766
+ var selected = value.includes(info.item.value);
20767
+
20768
+ var onItemPress = function onItemPress() {
20769
+ if (value.includes(info.item.value)) {
20770
+ onPress(value.filter(function (val) {
20771
+ return val !== info.item.value;
20772
+ }));
20773
+ } else {
20774
+ onPress([].concat(_toConsumableArray(value), [info.item.value]));
20712
20775
  }
20776
+ };
20777
+
20778
+ return renderOption ? renderOption(_objectSpread2(_objectSpread2({}, info), {}, {
20779
+ selected: selected,
20780
+ onPress: onItemPress
20781
+ })) : /*#__PURE__*/React__default["default"].createElement(Option$1, {
20782
+ selected: selected,
20783
+ text: item.text,
20784
+ disabled: item.disabled,
20785
+ onPress: onItemPress
20713
20786
  });
20714
- });
20787
+ };
20788
+
20715
20789
  return /*#__PURE__*/React__default["default"].createElement(StyledOptionList, {
20716
20790
  keyExtractor: keyExtractor,
20717
20791
  loading: loading,
20718
20792
  onEndReached: onEndReached,
20719
20793
  onQueryChange: onQueryChange,
20720
- options: options,
20721
- RenderItem: RenderItem,
20722
- scrollIndex: scrollIndex
20794
+ sections: sections,
20795
+ renderItem: renderItem,
20796
+ scrollParams: scrollParams
20723
20797
  });
20724
20798
  };
20725
20799
 
20726
20800
  function MultiSelect(_ref) {
20727
20801
  var footerLabel = _ref.footerLabel,
20728
20802
  label = _ref.label,
20729
- loading = _ref.loading,
20803
+ _ref$loading = _ref.loading,
20804
+ loading = _ref$loading === void 0 ? false : _ref$loading,
20805
+ inputProps = _ref.inputProps,
20730
20806
  onConfirm = _ref.onConfirm,
20731
20807
  onDimiss = _ref.onDimiss,
20732
20808
  onEndReached = _ref.onEndReached,
20733
20809
  onQueryChange = _ref.onQueryChange,
20734
20810
  options = _ref.options,
20811
+ renderOption = _ref.renderOption,
20735
20812
  query = _ref.query,
20736
20813
  error = _ref.error,
20737
20814
  _ref$editable = _ref.editable,
@@ -20743,6 +20820,10 @@ function MultiSelect(_ref) {
20743
20820
  testID = _ref.testID,
20744
20821
  value = _ref.value;
20745
20822
 
20823
+ var _useKeyboard = useKeyboard(),
20824
+ isKeyboardVisible = _useKeyboard.isKeyboardVisible,
20825
+ keyboardHeight = _useKeyboard.keyboardHeight;
20826
+
20746
20827
  var _useState = React.useState(false),
20747
20828
  _useState2 = _slicedToArray(_useState, 2),
20748
20829
  open = _useState2[0],
@@ -20753,37 +20834,15 @@ function MultiSelect(_ref) {
20753
20834
  selectingValue = _useState4[0],
20754
20835
  setSelectingValue = _useState4[1];
20755
20836
 
20756
- var displayedValue = options.filter(function (opt) {
20837
+ var sections = toSections(options);
20838
+ var flatOptions = toFlatOptions(options);
20839
+ var displayedValue = flatOptions.filter(function (opt) {
20757
20840
  return value.includes(opt.value);
20758
20841
  }).map(function (opt) {
20759
20842
  return opt.text;
20760
20843
  }).join(', ');
20761
-
20762
- var _useState5 = React.useState(false),
20763
- _useState6 = _slicedToArray(_useState5, 2),
20764
- isKeyboardVisible = _useState6[0],
20765
- setKeyboardVisible = _useState6[1];
20766
-
20767
- var _useState7 = React.useState(0),
20768
- _useState8 = _slicedToArray(_useState7, 2),
20769
- keyboardHeight = _useState8[0],
20770
- setKeyboardHeight = _useState8[1];
20771
-
20772
- React.useEffect(function () {
20773
- var keyboardDidShowListener = reactNative.Keyboard.addListener('keyboardDidShow', function (e) {
20774
- setKeyboardVisible(true);
20775
- setKeyboardHeight(e.endCoordinates.height);
20776
- });
20777
- var keyboardDidHideListener = reactNative.Keyboard.addListener('keyboardDidHide', function () {
20778
- setKeyboardVisible(false);
20779
- });
20780
- return function () {
20781
- keyboardDidHideListener.remove();
20782
- keyboardDidShowListener.remove();
20783
- };
20784
- }, []);
20785
20844
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
20786
- pointerEvents: !editable || disabled ? 'none' : 'auto'
20845
+ pointerEvents: !editable || disabled || inputProps !== null && inputProps !== void 0 && inputProps.loading ? 'none' : 'auto'
20787
20846
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.TouchableOpacity, {
20788
20847
  onPress: function onPress() {
20789
20848
  return setOpen(true);
@@ -20796,6 +20855,7 @@ function MultiSelect(_ref) {
20796
20855
  error: error,
20797
20856
  editable: editable,
20798
20857
  disabled: disabled,
20858
+ loading: inputProps === null || inputProps === void 0 ? void 0 : inputProps.loading,
20799
20859
  numberOfLines: numberOfLines,
20800
20860
  pointerEvents: "none",
20801
20861
  style: style,
@@ -20827,9 +20887,11 @@ function MultiSelect(_ref) {
20827
20887
  onChangeText: onQueryChange,
20828
20888
  value: query
20829
20889
  })), /*#__PURE__*/React__default["default"].createElement(OptionList$1, {
20890
+ onQueryChange: onQueryChange,
20830
20891
  onEndReached: onEndReached,
20831
20892
  loading: loading,
20832
- options: options,
20893
+ sections: sections,
20894
+ renderOption: renderOption,
20833
20895
  value: selectingValue,
20834
20896
  onPress: setSelectingValue
20835
20897
  })));
@@ -20837,12 +20899,19 @@ function MultiSelect(_ref) {
20837
20899
 
20838
20900
  var Option = function Option(_ref) {
20839
20901
  var text = _ref.text,
20902
+ _ref$disabled = _ref.disabled,
20903
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
20840
20904
  selected = _ref.selected,
20841
20905
  onPress = _ref.onPress;
20906
+ var theme = useTheme();
20842
20907
  return /*#__PURE__*/React__default["default"].createElement(List.BasicItem, {
20843
20908
  selected: selected,
20909
+ disabled: disabled,
20844
20910
  onPress: onPress,
20845
- title: text
20911
+ title: text,
20912
+ style: {
20913
+ marginHorizontal: theme.__hd__.select.space.optionHorizontalMargin
20914
+ }
20846
20915
  });
20847
20916
  };
20848
20917
 
@@ -20850,49 +20919,60 @@ var OptionList = function OptionList(_ref) {
20850
20919
  var keyExtractor = _ref.keyExtractor,
20851
20920
  loading = _ref.loading,
20852
20921
  onEndReached = _ref.onEndReached,
20853
- _onPress = _ref.onPress,
20922
+ onPress = _ref.onPress,
20854
20923
  onQueryChange = _ref.onQueryChange,
20855
- options = _ref.options,
20924
+ sections = _ref.sections,
20925
+ renderOption = _ref.renderOption,
20856
20926
  value = _ref.value;
20857
- var rawScrollIndex = options.findIndex(function (option) {
20858
- return option.value === value;
20859
- });
20860
- var scrollIndex = rawScrollIndex - 2 >= 0 ? rawScrollIndex - 2 : 0;
20861
- var RenderItem = /*#__PURE__*/React__default["default"].memo(function (_ref2) {
20862
- var item = _ref2.item;
20863
- return /*#__PURE__*/React__default["default"].createElement(Option, {
20864
- selected: value === item.value,
20865
- text: item.text,
20866
- onPress: function onPress() {
20867
- if (value === item.value) {
20868
- _onPress(null);
20869
- } else {
20870
- _onPress(item.value);
20871
- }
20927
+ var scrollParams = getScrollParams(value, sections);
20928
+
20929
+ var renderItem = function renderItem(info) {
20930
+ var item = info.item;
20931
+ var selected = item.value === value;
20932
+
20933
+ var onItemPress = function onItemPress() {
20934
+ if (value === item.value) {
20935
+ onPress(null);
20936
+ } else {
20937
+ onPress(item.value);
20872
20938
  }
20939
+ };
20940
+
20941
+ return renderOption ? renderOption(_objectSpread2(_objectSpread2({}, info), {}, {
20942
+ selected: selected,
20943
+ onPress: onItemPress
20944
+ })) : /*#__PURE__*/React__default["default"].createElement(Option, {
20945
+ selected: selected,
20946
+ text: item.text,
20947
+ disabled: item.disabled,
20948
+ onPress: onItemPress
20873
20949
  });
20874
- });
20950
+ };
20951
+
20875
20952
  return /*#__PURE__*/React__default["default"].createElement(StyledOptionList, {
20876
20953
  keyExtractor: keyExtractor,
20877
20954
  loading: loading,
20878
20955
  onEndReached: onEndReached,
20879
20956
  onQueryChange: onQueryChange,
20880
- options: options,
20881
- RenderItem: RenderItem,
20882
- scrollIndex: scrollIndex
20957
+ sections: sections,
20958
+ renderItem: renderItem,
20959
+ scrollParams: scrollParams
20883
20960
  });
20884
20961
  };
20885
20962
 
20886
20963
  var SingleSelect = function SingleSelect(_ref) {
20887
- var _options$find;
20964
+ var _flatOptions$find;
20888
20965
 
20889
20966
  var label = _ref.label,
20890
- loading = _ref.loading,
20967
+ _ref$loading = _ref.loading,
20968
+ loading = _ref$loading === void 0 ? false : _ref$loading,
20969
+ inputProps = _ref.inputProps,
20891
20970
  onConfirm = _ref.onConfirm,
20892
20971
  onDimiss = _ref.onDimiss,
20893
20972
  onEndReached = _ref.onEndReached,
20894
20973
  onQueryChange = _ref.onQueryChange,
20895
20974
  options = _ref.options,
20975
+ renderOption = _ref.renderOption,
20896
20976
  query = _ref.query,
20897
20977
  error = _ref.error,
20898
20978
  _ref$editable = _ref.editable,
@@ -20904,6 +20984,10 @@ var SingleSelect = function SingleSelect(_ref) {
20904
20984
  testID = _ref.testID,
20905
20985
  value = _ref.value;
20906
20986
 
20987
+ var _useKeyboard = useKeyboard(),
20988
+ isKeyboardVisible = _useKeyboard.isKeyboardVisible,
20989
+ keyboardHeight = _useKeyboard.keyboardHeight;
20990
+
20907
20991
  var _useState = React.useState(false),
20908
20992
  _useState2 = _slicedToArray(_useState, 2),
20909
20993
  open = _useState2[0],
@@ -20914,35 +20998,13 @@ var SingleSelect = function SingleSelect(_ref) {
20914
20998
  selectingValue = _useState4[0],
20915
20999
  setSelectingValue = _useState4[1];
20916
21000
 
20917
- var displayedValue = (_options$find = options.find(function (opt) {
21001
+ var sections = toSections(options);
21002
+ var flatOptions = toFlatOptions(options);
21003
+ var displayedValue = (_flatOptions$find = flatOptions.find(function (opt) {
20918
21004
  return value === opt.value;
20919
- })) === null || _options$find === void 0 ? void 0 : _options$find.text;
20920
-
20921
- var _useState5 = React.useState(false),
20922
- _useState6 = _slicedToArray(_useState5, 2),
20923
- isKeyboardVisible = _useState6[0],
20924
- setKeyboardVisible = _useState6[1];
20925
-
20926
- var _useState7 = React.useState(0),
20927
- _useState8 = _slicedToArray(_useState7, 2),
20928
- keyboardHeight = _useState8[0],
20929
- setKeyboardHeight = _useState8[1];
20930
-
20931
- React.useEffect(function () {
20932
- var keyboardDidShowListener = reactNative.Keyboard.addListener('keyboardWillShow', function (e) {
20933
- setKeyboardVisible(true);
20934
- setKeyboardHeight(e.endCoordinates.height);
20935
- });
20936
- var keyboardDidHideListener = reactNative.Keyboard.addListener('keyboardWillHide', function () {
20937
- setKeyboardVisible(false);
20938
- });
20939
- return function () {
20940
- keyboardDidHideListener.remove();
20941
- keyboardDidShowListener.remove();
20942
- };
20943
- }, []);
21005
+ })) === null || _flatOptions$find === void 0 ? void 0 : _flatOptions$find.text;
20944
21006
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
20945
- pointerEvents: !editable || disabled ? 'none' : 'auto'
21007
+ pointerEvents: !editable || disabled || inputProps !== null && inputProps !== void 0 && inputProps.loading ? 'none' : 'auto'
20946
21008
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.TouchableOpacity, {
20947
21009
  onPress: function onPress() {
20948
21010
  return setOpen(true);
@@ -20955,6 +21017,7 @@ var SingleSelect = function SingleSelect(_ref) {
20955
21017
  error: error,
20956
21018
  editable: editable,
20957
21019
  disabled: disabled,
21020
+ loading: inputProps === null || inputProps === void 0 ? void 0 : inputProps.loading,
20958
21021
  numberOfLines: numberOfLines,
20959
21022
  pointerEvents: "none",
20960
21023
  style: style,
@@ -20982,7 +21045,8 @@ var SingleSelect = function SingleSelect(_ref) {
20982
21045
  onQueryChange: onQueryChange,
20983
21046
  onEndReached: onEndReached,
20984
21047
  loading: loading,
20985
- options: options,
21048
+ sections: sections,
21049
+ renderOption: renderOption,
20986
21050
  value: selectingValue,
20987
21051
  onPress: function onPress(selectedValue) {
20988
21052
  setOpen(false);