@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/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as reactNative from 'react-native';
2
- import { Dimensions, StyleSheet as StyleSheet$1, Animated, View, Easing, TouchableOpacity, Text as Text$1, Image, Platform, TouchableWithoutFeedback, Pressable, SafeAreaView, TouchableHighlight, Modal, TextInput as TextInput$1, InteractionManager, FlatList, Keyboard, LayoutAnimation } from 'react-native';
2
+ import { Dimensions, StyleSheet as StyleSheet$1, Animated, View, Easing, TouchableOpacity, Text as Text$1, Image, Platform, TouchableWithoutFeedback, Pressable, SafeAreaView, TouchableHighlight, Modal, TextInput as TextInput$1, InteractionManager, Keyboard, SectionList, FlatList, LayoutAnimation } from 'react-native';
3
3
  import React, { useContext, createContext, createElement, forwardRef, useEffect, useCallback, useRef, useMemo, useState, useLayoutEffect, useImperativeHandle } from 'react';
4
4
  import { createIconSetFromIcoMoon } from 'react-native-vector-icons';
5
5
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -3459,9 +3459,9 @@ var getSelectTheme = function getSelectTheme(theme) {
3459
3459
  };
3460
3460
  var space = {
3461
3461
  minimumOptionListHeight: theme.space.xxxxlarge * 5,
3462
- optionPadding: theme.space.medium,
3463
- optionListPadding: theme.space.medium,
3464
- optionListSpacing: theme.space.xsmall,
3462
+ sectionSpacing: theme.space.smallMedium,
3463
+ optionSpacing: theme.space.xsmall,
3464
+ optionHorizontalMargin: theme.space.smallMedium,
3465
3465
  searchBarMarginTopSpacing: theme.space.small,
3466
3466
  searchBarHorizontalSpacing: theme.space.medium,
3467
3467
  searchBarBottomSpacing: theme.space.small
@@ -18840,11 +18840,12 @@ var StyledErrorAndMaxLengthContainer = index$6(View)(function () {
18840
18840
  };
18841
18841
  });
18842
18842
 
18843
- var _excluded$5 = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy", "error", "required", "editable", "disabled", "maxLength", "helpText", "value", "defaultValue"];
18843
+ var _excluded$5 = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy", "error", "required", "editable", "disabled", "loading", "maxLength", "helpText", "value", "defaultValue"];
18844
18844
  var getVariant = function getVariant(_ref) {
18845
18845
  var disabled = _ref.disabled,
18846
18846
  error = _ref.error,
18847
18847
  editable = _ref.editable,
18848
+ loading = _ref.loading,
18848
18849
  isFocused = _ref.isFocused,
18849
18850
  isEmptyValue = _ref.isEmptyValue;
18850
18851
 
@@ -18856,7 +18857,7 @@ var getVariant = function getVariant(_ref) {
18856
18857
  return 'error';
18857
18858
  }
18858
18859
 
18859
- if (!editable) {
18860
+ if (!editable || loading) {
18860
18861
  return 'readonly';
18861
18862
  }
18862
18863
 
@@ -18887,6 +18888,8 @@ var TextInput = function TextInput(_ref2) {
18887
18888
  editable = _ref2$editable === void 0 ? true : _ref2$editable,
18888
18889
  _ref2$disabled = _ref2.disabled,
18889
18890
  disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
18891
+ _ref2$loading = _ref2.loading,
18892
+ loading = _ref2$loading === void 0 ? false : _ref2$loading,
18890
18893
  maxLength = _ref2.maxLength,
18891
18894
  helpText = _ref2.helpText,
18892
18895
  value = _ref2.value,
@@ -18896,6 +18899,7 @@ var TextInput = function TextInput(_ref2) {
18896
18899
  var textInputReference = useRef(null);
18897
18900
  var displayText = (_ref3 = value !== undefined ? value : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
18898
18901
  var isEmptyValue = displayText.length === 0;
18902
+ var actualSuffix = loading ? 'loading' : suffix;
18899
18903
 
18900
18904
  var _React$useState = React.useState(false),
18901
18905
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -18906,6 +18910,7 @@ var TextInput = function TextInput(_ref2) {
18906
18910
  disabled: disabled,
18907
18911
  error: error,
18908
18912
  editable: editable,
18913
+ loading: loading,
18909
18914
  isFocused: isFocused,
18910
18915
  isEmptyValue: isEmptyValue
18911
18916
  });
@@ -18928,7 +18933,7 @@ var TextInput = function TextInput(_ref2) {
18928
18933
  fontSize: "small",
18929
18934
  themeVariant: variant
18930
18935
  }, label)), typeof prefix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
18931
- intent: disabled ? 'disabled-text' : 'text',
18936
+ intent: variant === 'disabled' ? 'disabled-text' : 'text',
18932
18937
  testID: "input-prefix",
18933
18938
  icon: prefix,
18934
18939
  size: "xsmall"
@@ -18949,7 +18954,7 @@ var TextInput = function TextInput(_ref2) {
18949
18954
  }, textStyle]),
18950
18955
  testID: "text-input",
18951
18956
  accessibilityState: {
18952
- disabled: disabled
18957
+ disabled: variant === 'disabled' || variant === 'readonly'
18953
18958
  } // @ts-ignore
18954
18959
  ,
18955
18960
  accessibilityLabelledBy: accessibilityLabelledBy
@@ -18977,10 +18982,11 @@ var TextInput = function TextInput(_ref2) {
18977
18982
  },
18978
18983
  defaultValue: defaultValue,
18979
18984
  placeholder: variant === 'focused' ? nativeProps.placeholder : undefined
18980
- }))), typeof suffix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
18981
- intent: disabled ? 'disabled-text' : 'text',
18985
+ }))), typeof actualSuffix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
18986
+ intent: variant === 'disabled' ? 'disabled-text' : 'text',
18982
18987
  testID: "input-suffix",
18983
- icon: suffix,
18988
+ icon: actualSuffix,
18989
+ spin: actualSuffix === 'loading',
18984
18990
  size: "xsmall"
18985
18991
  }) : suffix), /*#__PURE__*/React.createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React.createElement(StyledErrorAndMaxLengthContainer, null, error && /*#__PURE__*/React.createElement(StyledErrorContainer$1, null, /*#__PURE__*/React.createElement(Icon, {
18986
18992
  testID: "input-error-icon",
@@ -19763,10 +19769,10 @@ var BasicListItem = function BasicListItem(_ref) {
19763
19769
  underlayColor: theme.__hd__.list.colors.highlightedListItemContainerBackground
19764
19770
  }, /*#__PURE__*/React.createElement(React.Fragment, null, prefix && /*#__PURE__*/React.createElement(StyledPrefixContainer, null, typeof prefix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
19765
19771
  icon: prefix
19766
- }) : prefix), /*#__PURE__*/React.createElement(StyledTitleContainer, null, /*#__PURE__*/React.createElement(Typography.Text, {
19772
+ }) : prefix), /*#__PURE__*/React.createElement(StyledTitleContainer, null, typeof title === 'string' ? /*#__PURE__*/React.createElement(Typography.Text, {
19767
19773
  intent: "body",
19768
19774
  fontSize: "large"
19769
- }, title), subtitle && /*#__PURE__*/React.createElement(Typography.Text, {
19775
+ }, title) : title, subtitle && /*#__PURE__*/React.createElement(Typography.Text, {
19770
19776
  intent: "subdued",
19771
19777
  fontSize: "small"
19772
19778
  }, subtitle)), suffix && /*#__PURE__*/React.createElement(StyledSuffixContainer, null, typeof suffix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
@@ -20425,7 +20431,7 @@ var Radio = function Radio(_ref) {
20425
20431
  })));
20426
20432
  };
20427
20433
 
20428
- function getKey$1(option, index, keyExtractor) {
20434
+ function getKey(option, index, keyExtractor) {
20429
20435
  var key = '';
20430
20436
 
20431
20437
  if (keyExtractor !== undefined) {
@@ -20451,7 +20457,7 @@ var RadioGroup = function RadioGroup(_ref) {
20451
20457
  testID: testID
20452
20458
  }, options.map(function (option, index) {
20453
20459
  return /*#__PURE__*/React.createElement(React.Fragment, {
20454
- key: getKey$1(option, index, keyExtractor)
20460
+ key: getKey(option, index, keyExtractor)
20455
20461
  }, index !== 0 && /*#__PURE__*/React.createElement(Spacer, null), /*#__PURE__*/React.createElement(Radio, {
20456
20462
  text: option.text,
20457
20463
  checked: option.value === value,
@@ -20533,20 +20539,26 @@ var SectionHeading = function SectionHeading(_ref) {
20533
20539
  }, text)), rightChildren);
20534
20540
  };
20535
20541
 
20536
- index$6(View)(function (_ref) {
20542
+ var SectionSpacer = index$6(View)(function (_ref) {
20537
20543
  var theme = _ref.theme;
20538
20544
  return {
20539
- marginTop: theme.__hd__.select.space.optionListSpacing
20545
+ marginTop: theme.__hd__.select.space.sectionSpacing
20540
20546
  };
20541
20547
  });
20542
- var FooterText = index$6(Typography.Text)(function (_ref2) {
20548
+ var OptionSpacer = index$6(View)(function (_ref2) {
20543
20549
  var theme = _ref2.theme;
20544
20550
  return {
20545
- color: theme.__hd__.select.colors.footerText
20551
+ marginTop: theme.__hd__.select.space.optionSpacing
20546
20552
  };
20547
20553
  });
20548
- var StyledSearchBar = index$6(View)(function (_ref3) {
20554
+ var FooterText = index$6(Typography.Text)(function (_ref3) {
20549
20555
  var theme = _ref3.theme;
20556
+ return {
20557
+ color: theme.__hd__.select.colors.footerText
20558
+ };
20559
+ });
20560
+ var StyledSearchBar = index$6(View)(function (_ref4) {
20561
+ var theme = _ref4.theme;
20550
20562
  return {
20551
20563
  marginTop: theme.__hd__.select.space.searchBarMarginTopSpacing,
20552
20564
  paddingHorizontal: theme.__hd__.select.space.searchBarHorizontalSpacing,
@@ -20565,18 +20577,70 @@ var Footer = function Footer(_ref) {
20565
20577
  }, label));
20566
20578
  };
20567
20579
 
20568
- var getKey = function getKey(option, index, keyExtractor) {
20569
- var key = '';
20580
+ var isSections = function isSections(options) {
20581
+ var firstOption = options[0];
20582
+ return firstOption !== undefined && firstOption.category !== undefined;
20583
+ };
20584
+ var toSections = function toSections(options) {
20585
+ if (isSections(options)) {
20586
+ return options;
20587
+ }
20570
20588
 
20571
- if (keyExtractor !== undefined) {
20572
- key = keyExtractor(option, index);
20573
- } else if (option.key !== undefined) {
20574
- key = option.key;
20575
- } else {
20576
- key = index;
20589
+ return [{
20590
+ category: '',
20591
+ data: options
20592
+ }];
20593
+ };
20594
+ var toFlatOptions = function toFlatOptions(options) {
20595
+ if (isSections(options)) {
20596
+ return options.flatMap(function (opt) {
20597
+ return opt.data;
20598
+ });
20577
20599
  }
20578
20600
 
20579
- return key;
20601
+ return options;
20602
+ };
20603
+ var getScrollParams = function getScrollParams(value, sections) {
20604
+ var itemIndex = -1;
20605
+ var sectionIndex = sections.findIndex(function (section) {
20606
+ itemIndex = section.data.findIndex(function (opt) {
20607
+ return opt.value === value;
20608
+ });
20609
+ return itemIndex !== -1;
20610
+ });
20611
+ return {
20612
+ sectionIndex: sectionIndex < 0 ? 0 : sectionIndex,
20613
+ itemIndex: itemIndex < 0 ? 0 : itemIndex
20614
+ };
20615
+ };
20616
+ var useKeyboard = function useKeyboard() {
20617
+ var _useState = useState(false),
20618
+ _useState2 = _slicedToArray(_useState, 2),
20619
+ isKeyboardVisible = _useState2[0],
20620
+ setKeyboardVisible = _useState2[1];
20621
+
20622
+ var _useState3 = useState(0),
20623
+ _useState4 = _slicedToArray(_useState3, 2),
20624
+ keyboardHeight = _useState4[0],
20625
+ setKeyboardHeight = _useState4[1];
20626
+
20627
+ useEffect(function () {
20628
+ var keyboardWillShowListener = Keyboard.addListener('keyboardWillShow', function (e) {
20629
+ setKeyboardVisible(true);
20630
+ setKeyboardHeight(e.endCoordinates.height);
20631
+ });
20632
+ var keyboardWillHideListener = Keyboard.addListener('keyboardWillHide', function () {
20633
+ setKeyboardVisible(false);
20634
+ });
20635
+ return function () {
20636
+ keyboardWillShowListener.remove();
20637
+ keyboardWillHideListener.remove();
20638
+ };
20639
+ }, []);
20640
+ return {
20641
+ isKeyboardVisible: isKeyboardVisible,
20642
+ keyboardHeight: keyboardHeight
20643
+ };
20580
20644
  };
20581
20645
 
20582
20646
  var StyledOptionList = function StyledOptionList(_ref) {
@@ -20584,26 +20648,23 @@ var StyledOptionList = function StyledOptionList(_ref) {
20584
20648
  loading = _ref.loading,
20585
20649
  onEndReached = _ref.onEndReached,
20586
20650
  onQueryChange = _ref.onQueryChange,
20587
- options = _ref.options,
20588
- RenderItem = _ref.RenderItem,
20589
- _ref$scrollIndex = _ref.scrollIndex,
20590
- scrollIndex = _ref$scrollIndex === void 0 ? 0 : _ref$scrollIndex;
20651
+ sections = _ref.sections,
20652
+ renderItem = _ref.renderItem,
20653
+ scrollParams = _ref.scrollParams;
20591
20654
  var theme = useTheme$1();
20592
- var flatListRef = useRef(null);
20655
+ var sectionListRef = useRef(null);
20593
20656
 
20594
20657
  var _useState = useState(false),
20595
20658
  _useState2 = _slicedToArray(_useState, 2),
20596
20659
  onEndReachedCalled = _useState2[0],
20597
20660
  setOnEndReachedCalled = _useState2[1];
20598
20661
 
20599
- return /*#__PURE__*/React.createElement(FlatList, {
20600
- ref: flatListRef,
20601
- style: _objectSpread2({
20602
- paddingHorizontal: theme.__hd__.select.space.optionListPadding
20603
- }, onQueryChange ? {
20662
+ return /*#__PURE__*/React.createElement(SectionList, {
20663
+ ref: sectionListRef,
20664
+ style: _objectSpread2({}, onQueryChange ? {
20604
20665
  height: Dimensions.get('screen').height
20605
20666
  } : {}),
20606
- data: options,
20667
+ sections: sections,
20607
20668
  keyExtractor: keyExtractor,
20608
20669
  onEndReachedThreshold: 0.1,
20609
20670
  onEndReached: function onEndReached() {
@@ -20611,11 +20672,9 @@ var StyledOptionList = function StyledOptionList(_ref) {
20611
20672
  },
20612
20673
  onScrollToIndexFailed: function onScrollToIndexFailed() {},
20613
20674
  onContentSizeChange: function onContentSizeChange() {
20614
- var _flatListRef$current;
20675
+ var _sectionListRef$curre;
20615
20676
 
20616
- return options.length && ((_flatListRef$current = flatListRef.current) === null || _flatListRef$current === void 0 ? void 0 : _flatListRef$current.scrollToIndex({
20617
- index: scrollIndex
20618
- }));
20677
+ return sections.length && ((_sectionListRef$curre = sectionListRef.current) === null || _sectionListRef$curre === void 0 ? void 0 : _sectionListRef$curre.scrollToLocation(scrollParams));
20619
20678
  },
20620
20679
  onMomentumScrollBegin: function onMomentumScrollBegin() {
20621
20680
  if (onEndReached && onEndReachedCalled && !loading) onEndReached();
@@ -20628,30 +20687,37 @@ var StyledOptionList = function StyledOptionList(_ref) {
20628
20687
  height: theme.space.xxxxlarge
20629
20688
  }
20630
20689
  }, /*#__PURE__*/React.createElement(Spinner, null)) : null,
20631
- renderItem: function renderItem(_ref2) {
20632
- var item = _ref2.item,
20633
- index = _ref2.index;
20634
- return /*#__PURE__*/React.createElement(View, {
20635
- key: getKey(item, index, keyExtractor)
20636
- }, /*#__PURE__*/React.createElement(RenderItem, {
20637
- item: item
20638
- }));
20639
- }
20690
+ renderSectionHeader: function renderSectionHeader(_ref2) {
20691
+ var category = _ref2.section.category;
20692
+ return category !== '' ? /*#__PURE__*/React.createElement(SectionHeading, {
20693
+ text: category,
20694
+ style: {
20695
+ marginBottom: 0
20696
+ }
20697
+ }) : null;
20698
+ },
20699
+ renderItem: renderItem,
20700
+ ItemSeparatorComponent: OptionSpacer,
20701
+ SectionSeparatorComponent: SectionSpacer
20640
20702
  });
20641
20703
  };
20642
20704
 
20643
20705
  var Option$1 = function Option(_ref) {
20644
20706
  var text = _ref.text,
20707
+ _ref$disabled = _ref.disabled,
20708
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
20645
20709
  selected = _ref.selected,
20646
20710
  onPress = _ref.onPress;
20711
+ var theme = useTheme();
20647
20712
  return /*#__PURE__*/React.createElement(List.BasicItem, {
20648
20713
  selected: selected,
20714
+ disabled: disabled,
20649
20715
  onPress: onPress,
20650
20716
  title: text,
20651
- suffix: selected ? /*#__PURE__*/React.createElement(Icon, {
20652
- icon: "checkmark",
20653
- size: "small"
20654
- }) : undefined
20717
+ suffix: selected ? 'checkmark' : undefined,
20718
+ style: {
20719
+ marginHorizontal: theme.__hd__.select.space.optionHorizontalMargin
20720
+ }
20655
20721
  });
20656
20722
  };
20657
20723
 
@@ -20659,51 +20725,62 @@ var OptionList$1 = function OptionList(_ref) {
20659
20725
  var keyExtractor = _ref.keyExtractor,
20660
20726
  loading = _ref.loading,
20661
20727
  onEndReached = _ref.onEndReached,
20662
- _onPress = _ref.onPress,
20728
+ onPress = _ref.onPress,
20663
20729
  onQueryChange = _ref.onQueryChange,
20664
- options = _ref.options,
20730
+ sections = _ref.sections,
20731
+ renderOption = _ref.renderOption,
20665
20732
  value = _ref.value;
20666
20733
  var firstValue = value === null || value === void 0 ? void 0 : value[0];
20667
- var rawScrollIndex = firstValue ? options.findIndex(function (option) {
20668
- return option.value === firstValue;
20669
- }) : 0;
20670
- var scrollIndex = rawScrollIndex - 2 >= 0 ? rawScrollIndex - 2 : 0;
20671
- var RenderItem = /*#__PURE__*/React.memo(function (_ref2) {
20672
- var item = _ref2.item;
20673
- return /*#__PURE__*/React.createElement(Option$1, {
20674
- text: item.text,
20675
- selected: value.includes(item.value),
20676
- onPress: function onPress() {
20677
- if (value.includes(item.value)) {
20678
- _onPress(value.filter(function (val) {
20679
- return val !== item.value;
20680
- }));
20681
- } else {
20682
- _onPress([].concat(_toConsumableArray(value), [item.value]));
20683
- }
20734
+ var scrollParams = getScrollParams(firstValue, sections);
20735
+
20736
+ var renderItem = function renderItem(info) {
20737
+ var item = info.item;
20738
+ var selected = value.includes(info.item.value);
20739
+
20740
+ var onItemPress = function onItemPress() {
20741
+ if (value.includes(info.item.value)) {
20742
+ onPress(value.filter(function (val) {
20743
+ return val !== info.item.value;
20744
+ }));
20745
+ } else {
20746
+ onPress([].concat(_toConsumableArray(value), [info.item.value]));
20684
20747
  }
20748
+ };
20749
+
20750
+ return renderOption ? renderOption(_objectSpread2(_objectSpread2({}, info), {}, {
20751
+ selected: selected,
20752
+ onPress: onItemPress
20753
+ })) : /*#__PURE__*/React.createElement(Option$1, {
20754
+ selected: selected,
20755
+ text: item.text,
20756
+ disabled: item.disabled,
20757
+ onPress: onItemPress
20685
20758
  });
20686
- });
20759
+ };
20760
+
20687
20761
  return /*#__PURE__*/React.createElement(StyledOptionList, {
20688
20762
  keyExtractor: keyExtractor,
20689
20763
  loading: loading,
20690
20764
  onEndReached: onEndReached,
20691
20765
  onQueryChange: onQueryChange,
20692
- options: options,
20693
- RenderItem: RenderItem,
20694
- scrollIndex: scrollIndex
20766
+ sections: sections,
20767
+ renderItem: renderItem,
20768
+ scrollParams: scrollParams
20695
20769
  });
20696
20770
  };
20697
20771
 
20698
20772
  function MultiSelect(_ref) {
20699
20773
  var footerLabel = _ref.footerLabel,
20700
20774
  label = _ref.label,
20701
- loading = _ref.loading,
20775
+ _ref$loading = _ref.loading,
20776
+ loading = _ref$loading === void 0 ? false : _ref$loading,
20777
+ inputProps = _ref.inputProps,
20702
20778
  onConfirm = _ref.onConfirm,
20703
20779
  onDimiss = _ref.onDimiss,
20704
20780
  onEndReached = _ref.onEndReached,
20705
20781
  onQueryChange = _ref.onQueryChange,
20706
20782
  options = _ref.options,
20783
+ renderOption = _ref.renderOption,
20707
20784
  query = _ref.query,
20708
20785
  error = _ref.error,
20709
20786
  _ref$editable = _ref.editable,
@@ -20715,6 +20792,10 @@ function MultiSelect(_ref) {
20715
20792
  testID = _ref.testID,
20716
20793
  value = _ref.value;
20717
20794
 
20795
+ var _useKeyboard = useKeyboard(),
20796
+ isKeyboardVisible = _useKeyboard.isKeyboardVisible,
20797
+ keyboardHeight = _useKeyboard.keyboardHeight;
20798
+
20718
20799
  var _useState = useState(false),
20719
20800
  _useState2 = _slicedToArray(_useState, 2),
20720
20801
  open = _useState2[0],
@@ -20725,37 +20806,15 @@ function MultiSelect(_ref) {
20725
20806
  selectingValue = _useState4[0],
20726
20807
  setSelectingValue = _useState4[1];
20727
20808
 
20728
- var displayedValue = options.filter(function (opt) {
20809
+ var sections = toSections(options);
20810
+ var flatOptions = toFlatOptions(options);
20811
+ var displayedValue = flatOptions.filter(function (opt) {
20729
20812
  return value.includes(opt.value);
20730
20813
  }).map(function (opt) {
20731
20814
  return opt.text;
20732
20815
  }).join(', ');
20733
-
20734
- var _useState5 = useState(false),
20735
- _useState6 = _slicedToArray(_useState5, 2),
20736
- isKeyboardVisible = _useState6[0],
20737
- setKeyboardVisible = _useState6[1];
20738
-
20739
- var _useState7 = useState(0),
20740
- _useState8 = _slicedToArray(_useState7, 2),
20741
- keyboardHeight = _useState8[0],
20742
- setKeyboardHeight = _useState8[1];
20743
-
20744
- useEffect(function () {
20745
- var keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', function (e) {
20746
- setKeyboardVisible(true);
20747
- setKeyboardHeight(e.endCoordinates.height);
20748
- });
20749
- var keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', function () {
20750
- setKeyboardVisible(false);
20751
- });
20752
- return function () {
20753
- keyboardDidHideListener.remove();
20754
- keyboardDidShowListener.remove();
20755
- };
20756
- }, []);
20757
20816
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
20758
- pointerEvents: !editable || disabled ? 'none' : 'auto'
20817
+ pointerEvents: !editable || disabled || inputProps !== null && inputProps !== void 0 && inputProps.loading ? 'none' : 'auto'
20759
20818
  }, /*#__PURE__*/React.createElement(TouchableOpacity, {
20760
20819
  onPress: function onPress() {
20761
20820
  return setOpen(true);
@@ -20768,6 +20827,7 @@ function MultiSelect(_ref) {
20768
20827
  error: error,
20769
20828
  editable: editable,
20770
20829
  disabled: disabled,
20830
+ loading: inputProps === null || inputProps === void 0 ? void 0 : inputProps.loading,
20771
20831
  numberOfLines: numberOfLines,
20772
20832
  pointerEvents: "none",
20773
20833
  style: style,
@@ -20799,9 +20859,11 @@ function MultiSelect(_ref) {
20799
20859
  onChangeText: onQueryChange,
20800
20860
  value: query
20801
20861
  })), /*#__PURE__*/React.createElement(OptionList$1, {
20862
+ onQueryChange: onQueryChange,
20802
20863
  onEndReached: onEndReached,
20803
20864
  loading: loading,
20804
- options: options,
20865
+ sections: sections,
20866
+ renderOption: renderOption,
20805
20867
  value: selectingValue,
20806
20868
  onPress: setSelectingValue
20807
20869
  })));
@@ -20809,12 +20871,19 @@ function MultiSelect(_ref) {
20809
20871
 
20810
20872
  var Option = function Option(_ref) {
20811
20873
  var text = _ref.text,
20874
+ _ref$disabled = _ref.disabled,
20875
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
20812
20876
  selected = _ref.selected,
20813
20877
  onPress = _ref.onPress;
20878
+ var theme = useTheme();
20814
20879
  return /*#__PURE__*/React.createElement(List.BasicItem, {
20815
20880
  selected: selected,
20881
+ disabled: disabled,
20816
20882
  onPress: onPress,
20817
- title: text
20883
+ title: text,
20884
+ style: {
20885
+ marginHorizontal: theme.__hd__.select.space.optionHorizontalMargin
20886
+ }
20818
20887
  });
20819
20888
  };
20820
20889
 
@@ -20822,49 +20891,60 @@ var OptionList = function OptionList(_ref) {
20822
20891
  var keyExtractor = _ref.keyExtractor,
20823
20892
  loading = _ref.loading,
20824
20893
  onEndReached = _ref.onEndReached,
20825
- _onPress = _ref.onPress,
20894
+ onPress = _ref.onPress,
20826
20895
  onQueryChange = _ref.onQueryChange,
20827
- options = _ref.options,
20896
+ sections = _ref.sections,
20897
+ renderOption = _ref.renderOption,
20828
20898
  value = _ref.value;
20829
- var rawScrollIndex = options.findIndex(function (option) {
20830
- return option.value === value;
20831
- });
20832
- var scrollIndex = rawScrollIndex - 2 >= 0 ? rawScrollIndex - 2 : 0;
20833
- var RenderItem = /*#__PURE__*/React.memo(function (_ref2) {
20834
- var item = _ref2.item;
20835
- return /*#__PURE__*/React.createElement(Option, {
20836
- selected: value === item.value,
20837
- text: item.text,
20838
- onPress: function onPress() {
20839
- if (value === item.value) {
20840
- _onPress(null);
20841
- } else {
20842
- _onPress(item.value);
20843
- }
20899
+ var scrollParams = getScrollParams(value, sections);
20900
+
20901
+ var renderItem = function renderItem(info) {
20902
+ var item = info.item;
20903
+ var selected = item.value === value;
20904
+
20905
+ var onItemPress = function onItemPress() {
20906
+ if (value === item.value) {
20907
+ onPress(null);
20908
+ } else {
20909
+ onPress(item.value);
20844
20910
  }
20911
+ };
20912
+
20913
+ return renderOption ? renderOption(_objectSpread2(_objectSpread2({}, info), {}, {
20914
+ selected: selected,
20915
+ onPress: onItemPress
20916
+ })) : /*#__PURE__*/React.createElement(Option, {
20917
+ selected: selected,
20918
+ text: item.text,
20919
+ disabled: item.disabled,
20920
+ onPress: onItemPress
20845
20921
  });
20846
- });
20922
+ };
20923
+
20847
20924
  return /*#__PURE__*/React.createElement(StyledOptionList, {
20848
20925
  keyExtractor: keyExtractor,
20849
20926
  loading: loading,
20850
20927
  onEndReached: onEndReached,
20851
20928
  onQueryChange: onQueryChange,
20852
- options: options,
20853
- RenderItem: RenderItem,
20854
- scrollIndex: scrollIndex
20929
+ sections: sections,
20930
+ renderItem: renderItem,
20931
+ scrollParams: scrollParams
20855
20932
  });
20856
20933
  };
20857
20934
 
20858
20935
  var SingleSelect = function SingleSelect(_ref) {
20859
- var _options$find;
20936
+ var _flatOptions$find;
20860
20937
 
20861
20938
  var label = _ref.label,
20862
- loading = _ref.loading,
20939
+ _ref$loading = _ref.loading,
20940
+ loading = _ref$loading === void 0 ? false : _ref$loading,
20941
+ inputProps = _ref.inputProps,
20863
20942
  onConfirm = _ref.onConfirm,
20864
20943
  onDimiss = _ref.onDimiss,
20865
20944
  onEndReached = _ref.onEndReached,
20866
20945
  onQueryChange = _ref.onQueryChange,
20867
20946
  options = _ref.options,
20947
+ renderOption = _ref.renderOption,
20868
20948
  query = _ref.query,
20869
20949
  error = _ref.error,
20870
20950
  _ref$editable = _ref.editable,
@@ -20876,6 +20956,10 @@ var SingleSelect = function SingleSelect(_ref) {
20876
20956
  testID = _ref.testID,
20877
20957
  value = _ref.value;
20878
20958
 
20959
+ var _useKeyboard = useKeyboard(),
20960
+ isKeyboardVisible = _useKeyboard.isKeyboardVisible,
20961
+ keyboardHeight = _useKeyboard.keyboardHeight;
20962
+
20879
20963
  var _useState = useState(false),
20880
20964
  _useState2 = _slicedToArray(_useState, 2),
20881
20965
  open = _useState2[0],
@@ -20886,35 +20970,13 @@ var SingleSelect = function SingleSelect(_ref) {
20886
20970
  selectingValue = _useState4[0],
20887
20971
  setSelectingValue = _useState4[1];
20888
20972
 
20889
- var displayedValue = (_options$find = options.find(function (opt) {
20973
+ var sections = toSections(options);
20974
+ var flatOptions = toFlatOptions(options);
20975
+ var displayedValue = (_flatOptions$find = flatOptions.find(function (opt) {
20890
20976
  return value === opt.value;
20891
- })) === null || _options$find === void 0 ? void 0 : _options$find.text;
20892
-
20893
- var _useState5 = useState(false),
20894
- _useState6 = _slicedToArray(_useState5, 2),
20895
- isKeyboardVisible = _useState6[0],
20896
- setKeyboardVisible = _useState6[1];
20897
-
20898
- var _useState7 = useState(0),
20899
- _useState8 = _slicedToArray(_useState7, 2),
20900
- keyboardHeight = _useState8[0],
20901
- setKeyboardHeight = _useState8[1];
20902
-
20903
- useEffect(function () {
20904
- var keyboardDidShowListener = Keyboard.addListener('keyboardWillShow', function (e) {
20905
- setKeyboardVisible(true);
20906
- setKeyboardHeight(e.endCoordinates.height);
20907
- });
20908
- var keyboardDidHideListener = Keyboard.addListener('keyboardWillHide', function () {
20909
- setKeyboardVisible(false);
20910
- });
20911
- return function () {
20912
- keyboardDidHideListener.remove();
20913
- keyboardDidShowListener.remove();
20914
- };
20915
- }, []);
20977
+ })) === null || _flatOptions$find === void 0 ? void 0 : _flatOptions$find.text;
20916
20978
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
20917
- pointerEvents: !editable || disabled ? 'none' : 'auto'
20979
+ pointerEvents: !editable || disabled || inputProps !== null && inputProps !== void 0 && inputProps.loading ? 'none' : 'auto'
20918
20980
  }, /*#__PURE__*/React.createElement(TouchableOpacity, {
20919
20981
  onPress: function onPress() {
20920
20982
  return setOpen(true);
@@ -20927,6 +20989,7 @@ var SingleSelect = function SingleSelect(_ref) {
20927
20989
  error: error,
20928
20990
  editable: editable,
20929
20991
  disabled: disabled,
20992
+ loading: inputProps === null || inputProps === void 0 ? void 0 : inputProps.loading,
20930
20993
  numberOfLines: numberOfLines,
20931
20994
  pointerEvents: "none",
20932
20995
  style: style,
@@ -20954,7 +21017,8 @@ var SingleSelect = function SingleSelect(_ref) {
20954
21017
  onQueryChange: onQueryChange,
20955
21018
  onEndReached: onEndReached,
20956
21019
  loading: loading,
20957
- options: options,
21020
+ sections: sections,
21021
+ renderOption: renderOption,
20958
21022
  value: selectingValue,
20959
21023
  onPress: function onPress(selectedValue) {
20960
21024
  setOpen(false);