@hero-design/rn 7.16.1 → 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 (54) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/es/index.js +228 -187
  3. package/lib/index.js +227 -186
  4. package/package.json +2 -2
  5. package/src/components/DatePicker/DatePickerIOS.tsx +2 -2
  6. package/src/components/List/BasicListItem.tsx +8 -4
  7. package/src/components/List/StyledBasicListItem.tsx +2 -2
  8. package/src/components/Select/MultiSelect/Option.tsx +21 -15
  9. package/src/components/Select/MultiSelect/OptionList.tsx +47 -41
  10. package/src/components/Select/MultiSelect/__tests__/OptionList.spec.tsx +25 -14
  11. package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +41 -21
  12. package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1995 -352
  13. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5611 -523
  14. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +122 -1
  15. package/src/components/Select/MultiSelect/index.tsx +26 -36
  16. package/src/components/Select/SingleSelect/Option.tsx +20 -13
  17. package/src/components/Select/SingleSelect/OptionList.tsx +47 -39
  18. package/src/components/Select/SingleSelect/__tests__/OptionList.spec.tsx +23 -12
  19. package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +23 -14
  20. package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1846 -258
  21. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +5140 -412
  22. package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +117 -1
  23. package/src/components/Select/SingleSelect/index.tsx +26 -37
  24. package/src/components/Select/StyledOptionList.tsx +43 -44
  25. package/src/components/Select/StyledSelect.tsx +6 -15
  26. package/src/components/Select/__tests__/StyledSelect.spec.tsx +1 -23
  27. package/src/components/Select/__tests__/__snapshots__/StyledSelect.spec.tsx.snap +0 -67
  28. package/src/components/Select/__tests__/helpers.spec.tsx +74 -0
  29. package/src/components/Select/helpers.tsx +87 -4
  30. package/src/components/Select/types.ts +99 -0
  31. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +157 -1
  32. package/src/components/TextInput/__tests__/index.spec.tsx +29 -8
  33. package/src/components/TextInput/index.tsx +18 -7
  34. package/src/components/TimePicker/TimePickerIOS.tsx +2 -2
  35. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +3 -5
  36. package/src/theme/components/select.ts +3 -5
  37. package/src/types.ts +7 -1
  38. package/types/components/List/BasicListItem.d.ts +1 -1
  39. package/types/components/Select/MultiSelect/Option.d.ts +4 -2
  40. package/types/components/Select/MultiSelect/OptionList.d.ts +6 -7
  41. package/types/components/Select/MultiSelect/index.d.ts +5 -5
  42. package/types/components/Select/SingleSelect/Option.d.ts +4 -2
  43. package/types/components/Select/SingleSelect/OptionList.d.ts +6 -7
  44. package/types/components/Select/SingleSelect/index.d.ts +5 -5
  45. package/types/components/Select/StyledOptionList.d.ts +10 -16
  46. package/types/components/Select/StyledSelect.d.ts +5 -7
  47. package/types/components/Select/__tests__/helpers.spec.d.ts +1 -0
  48. package/types/components/Select/helpers.d.ts +14 -2
  49. package/types/components/Select/index.d.ts +1 -1
  50. package/types/components/Select/types.d.ts +32 -7
  51. package/types/components/TextInput/index.d.ts +4 -2
  52. package/types/theme/components/select.d.ts +3 -5
  53. package/types/types.d.ts +2 -1
  54. package/src/components/Select/types.tsx +0 -52
package/lib/index.js CHANGED
@@ -3483,15 +3483,13 @@ var getSectionHeadingTheme = function getSectionHeadingTheme(theme) {
3483
3483
 
3484
3484
  var getSelectTheme = function getSelectTheme(theme) {
3485
3485
  var colors = {
3486
- option: theme.colors.platformBackground,
3487
- checkedOption: theme.colors.primaryBackground,
3488
3486
  footerText: theme.colors.primary
3489
3487
  };
3490
3488
  var space = {
3491
3489
  minimumOptionListHeight: theme.space.xxxxlarge * 5,
3492
- optionPadding: theme.space.medium,
3493
- optionListPadding: theme.space.medium,
3494
- optionListSpacing: theme.space.xsmall,
3490
+ sectionSpacing: theme.space.smallMedium,
3491
+ optionSpacing: theme.space.xsmall,
3492
+ optionHorizontalMargin: theme.space.smallMedium,
3495
3493
  searchBarMarginTopSpacing: theme.space.small,
3496
3494
  searchBarHorizontalSpacing: theme.space.medium,
3497
3495
  searchBarBottomSpacing: theme.space.small
@@ -18870,11 +18868,12 @@ var StyledErrorAndMaxLengthContainer = index$6(reactNative.View)(function () {
18870
18868
  };
18871
18869
  });
18872
18870
 
18873
- 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"];
18874
18872
  var getVariant = function getVariant(_ref) {
18875
18873
  var disabled = _ref.disabled,
18876
18874
  error = _ref.error,
18877
18875
  editable = _ref.editable,
18876
+ loading = _ref.loading,
18878
18877
  isFocused = _ref.isFocused,
18879
18878
  isEmptyValue = _ref.isEmptyValue;
18880
18879
 
@@ -18886,7 +18885,7 @@ var getVariant = function getVariant(_ref) {
18886
18885
  return 'error';
18887
18886
  }
18888
18887
 
18889
- if (!editable) {
18888
+ if (!editable || loading) {
18890
18889
  return 'readonly';
18891
18890
  }
18892
18891
 
@@ -18917,6 +18916,8 @@ var TextInput = function TextInput(_ref2) {
18917
18916
  editable = _ref2$editable === void 0 ? true : _ref2$editable,
18918
18917
  _ref2$disabled = _ref2.disabled,
18919
18918
  disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
18919
+ _ref2$loading = _ref2.loading,
18920
+ loading = _ref2$loading === void 0 ? false : _ref2$loading,
18920
18921
  maxLength = _ref2.maxLength,
18921
18922
  helpText = _ref2.helpText,
18922
18923
  value = _ref2.value,
@@ -18926,6 +18927,7 @@ var TextInput = function TextInput(_ref2) {
18926
18927
  var textInputReference = React.useRef(null);
18927
18928
  var displayText = (_ref3 = value !== undefined ? value : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
18928
18929
  var isEmptyValue = displayText.length === 0;
18930
+ var actualSuffix = loading ? 'loading' : suffix;
18929
18931
 
18930
18932
  var _React$useState = React__default["default"].useState(false),
18931
18933
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -18936,6 +18938,7 @@ var TextInput = function TextInput(_ref2) {
18936
18938
  disabled: disabled,
18937
18939
  error: error,
18938
18940
  editable: editable,
18941
+ loading: loading,
18939
18942
  isFocused: isFocused,
18940
18943
  isEmptyValue: isEmptyValue
18941
18944
  });
@@ -18958,7 +18961,7 @@ var TextInput = function TextInput(_ref2) {
18958
18961
  fontSize: "small",
18959
18962
  themeVariant: variant
18960
18963
  }, label)), typeof prefix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
18961
- intent: disabled ? 'disabled-text' : 'text',
18964
+ intent: variant === 'disabled' ? 'disabled-text' : 'text',
18962
18965
  testID: "input-prefix",
18963
18966
  icon: prefix,
18964
18967
  size: "xsmall"
@@ -18979,7 +18982,7 @@ var TextInput = function TextInput(_ref2) {
18979
18982
  }, textStyle]),
18980
18983
  testID: "text-input",
18981
18984
  accessibilityState: {
18982
- disabled: disabled
18985
+ disabled: variant === 'disabled' || variant === 'readonly'
18983
18986
  } // @ts-ignore
18984
18987
  ,
18985
18988
  accessibilityLabelledBy: accessibilityLabelledBy
@@ -19007,10 +19010,11 @@ var TextInput = function TextInput(_ref2) {
19007
19010
  },
19008
19011
  defaultValue: defaultValue,
19009
19012
  placeholder: variant === 'focused' ? nativeProps.placeholder : undefined
19010
- }))), typeof suffix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
19011
- intent: disabled ? 'disabled-text' : 'text',
19013
+ }))), typeof actualSuffix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
19014
+ intent: variant === 'disabled' ? 'disabled-text' : 'text',
19012
19015
  testID: "input-suffix",
19013
- icon: suffix,
19016
+ icon: actualSuffix,
19017
+ spin: actualSuffix === 'loading',
19014
19018
  size: "xsmall"
19015
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, {
19016
19020
  testID: "input-error-icon",
@@ -19104,7 +19108,7 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
19104
19108
  style = _ref.style,
19105
19109
  testID = _ref.testID;
19106
19110
 
19107
- var _useState = React.useState(value),
19111
+ var _useState = React.useState(value || new Date()),
19108
19112
  _useState2 = _slicedToArray(_useState, 2),
19109
19113
  selectingDate = _useState2[0],
19110
19114
  setSelectingDate = _useState2[1];
@@ -19155,7 +19159,7 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
19155
19159
  }, confirmLabel))
19156
19160
  }, /*#__PURE__*/React__default["default"].createElement(StyledPickerWrapper$1, null, /*#__PURE__*/React__default["default"].createElement(DateTimePicker__default["default"], {
19157
19161
  testID: "datePickerIOS",
19158
- value: selectingDate || new Date(),
19162
+ value: selectingDate,
19159
19163
  mode: "date",
19160
19164
  onChange: function onChange(_, date) {
19161
19165
  if (date) {
@@ -19764,7 +19768,7 @@ var StyledListItemContainer = index$6(reactNative.TouchableHighlight)(function (
19764
19768
  return {
19765
19769
  alignItems: 'center',
19766
19770
  flexDirection: 'row',
19767
- backgroundColor: themeSelected ? theme.__hd__.select.colors.checkedOption : theme.__hd__.select.colors.option,
19771
+ backgroundColor: themeSelected ? theme.__hd__.list.colors.checkedListItemContainerBackground : theme.__hd__.list.colors.listItemContainerBackground,
19768
19772
  padding: theme.__hd__.list.space.listItemContainerPadding,
19769
19773
  opacity: themeDisabled ? theme.__hd__.list.opacity.disabled : theme.__hd__.list.opacity.enabled
19770
19774
  };
@@ -19793,10 +19797,10 @@ var BasicListItem = function BasicListItem(_ref) {
19793
19797
  underlayColor: theme.__hd__.list.colors.highlightedListItemContainerBackground
19794
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, {
19795
19799
  icon: prefix
19796
- }) : 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, {
19797
19801
  intent: "body",
19798
19802
  fontSize: "large"
19799
- }, title), subtitle && /*#__PURE__*/React__default["default"].createElement(Typography.Text, {
19803
+ }, title) : title, subtitle && /*#__PURE__*/React__default["default"].createElement(Typography.Text, {
19800
19804
  intent: "subdued",
19801
19805
  fontSize: "small"
19802
19806
  }, subtitle)), suffix && /*#__PURE__*/React__default["default"].createElement(StyledSuffixContainer, null, typeof suffix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
@@ -20455,7 +20459,7 @@ var Radio = function Radio(_ref) {
20455
20459
  })));
20456
20460
  };
20457
20461
 
20458
- function getKey$1(option, index, keyExtractor) {
20462
+ function getKey(option, index, keyExtractor) {
20459
20463
  var key = '';
20460
20464
 
20461
20465
  if (keyExtractor !== undefined) {
@@ -20481,7 +20485,7 @@ var RadioGroup = function RadioGroup(_ref) {
20481
20485
  testID: testID
20482
20486
  }, options.map(function (option, index) {
20483
20487
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
20484
- key: getKey$1(option, index, keyExtractor)
20488
+ key: getKey(option, index, keyExtractor)
20485
20489
  }, index !== 0 && /*#__PURE__*/React__default["default"].createElement(Spacer, null), /*#__PURE__*/React__default["default"].createElement(Radio, {
20486
20490
  text: option.text,
20487
20491
  checked: option.value === value,
@@ -20563,22 +20567,16 @@ var SectionHeading = function SectionHeading(_ref) {
20563
20567
  }, text)), rightChildren);
20564
20568
  };
20565
20569
 
20566
- var OptionWrapper = index$6(reactNative.TouchableOpacity)(function (_ref) {
20567
- var theme = _ref.theme,
20568
- themeSelected = _ref.themeSelected;
20570
+ var SectionSpacer = index$6(reactNative.View)(function (_ref) {
20571
+ var theme = _ref.theme;
20569
20572
  return {
20570
- flexDirection: 'row',
20571
- justifyContent: 'space-between',
20572
- alignItems: 'center',
20573
- borderRadius: theme.__hd__.select.radii.option,
20574
- padding: theme.__hd__.select.space.optionPadding,
20575
- backgroundColor: themeSelected ? theme.__hd__.select.colors.checkedOption : theme.__hd__.select.colors.option
20573
+ marginTop: theme.__hd__.select.space.sectionSpacing
20576
20574
  };
20577
20575
  });
20578
- index$6(reactNative.View)(function (_ref2) {
20576
+ var OptionSpacer = index$6(reactNative.View)(function (_ref2) {
20579
20577
  var theme = _ref2.theme;
20580
20578
  return {
20581
- marginTop: theme.__hd__.select.space.optionListSpacing
20579
+ marginTop: theme.__hd__.select.space.optionSpacing
20582
20580
  };
20583
20581
  });
20584
20582
  var FooterText = index$6(Typography.Text)(function (_ref3) {
@@ -20607,18 +20605,70 @@ var Footer = function Footer(_ref) {
20607
20605
  }, label));
20608
20606
  };
20609
20607
 
20610
- var getKey = function getKey(option, index, keyExtractor) {
20611
- 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
+ }
20612
20616
 
20613
- if (keyExtractor !== undefined) {
20614
- key = keyExtractor(option, index);
20615
- } else if (option.key !== undefined) {
20616
- key = option.key;
20617
- } else {
20618
- 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
+ });
20619
20627
  }
20620
20628
 
20621
- 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
+ };
20622
20672
  };
20623
20673
 
20624
20674
  var StyledOptionList = function StyledOptionList(_ref) {
@@ -20626,26 +20676,23 @@ var StyledOptionList = function StyledOptionList(_ref) {
20626
20676
  loading = _ref.loading,
20627
20677
  onEndReached = _ref.onEndReached,
20628
20678
  onQueryChange = _ref.onQueryChange,
20629
- options = _ref.options,
20630
- RenderItem = _ref.RenderItem,
20631
- _ref$scrollIndex = _ref.scrollIndex,
20632
- scrollIndex = _ref$scrollIndex === void 0 ? 0 : _ref$scrollIndex;
20679
+ sections = _ref.sections,
20680
+ renderItem = _ref.renderItem,
20681
+ scrollParams = _ref.scrollParams;
20633
20682
  var theme = useTheme$1();
20634
- var flatListRef = React.useRef(null);
20683
+ var sectionListRef = React.useRef(null);
20635
20684
 
20636
20685
  var _useState = React.useState(false),
20637
20686
  _useState2 = _slicedToArray(_useState, 2),
20638
20687
  onEndReachedCalled = _useState2[0],
20639
20688
  setOnEndReachedCalled = _useState2[1];
20640
20689
 
20641
- return /*#__PURE__*/React__default["default"].createElement(reactNative.FlatList, {
20642
- ref: flatListRef,
20643
- style: _objectSpread2({
20644
- paddingHorizontal: theme.__hd__.select.space.optionListPadding
20645
- }, onQueryChange ? {
20690
+ return /*#__PURE__*/React__default["default"].createElement(reactNative.SectionList, {
20691
+ ref: sectionListRef,
20692
+ style: _objectSpread2({}, onQueryChange ? {
20646
20693
  height: reactNative.Dimensions.get('screen').height
20647
20694
  } : {}),
20648
- data: options,
20695
+ sections: sections,
20649
20696
  keyExtractor: keyExtractor,
20650
20697
  onEndReachedThreshold: 0.1,
20651
20698
  onEndReached: function onEndReached() {
@@ -20653,11 +20700,9 @@ var StyledOptionList = function StyledOptionList(_ref) {
20653
20700
  },
20654
20701
  onScrollToIndexFailed: function onScrollToIndexFailed() {},
20655
20702
  onContentSizeChange: function onContentSizeChange() {
20656
- var _flatListRef$current;
20703
+ var _sectionListRef$curre;
20657
20704
 
20658
- return options.length && ((_flatListRef$current = flatListRef.current) === null || _flatListRef$current === void 0 ? void 0 : _flatListRef$current.scrollToIndex({
20659
- index: scrollIndex
20660
- }));
20705
+ return sections.length && ((_sectionListRef$curre = sectionListRef.current) === null || _sectionListRef$curre === void 0 ? void 0 : _sectionListRef$curre.scrollToLocation(scrollParams));
20661
20706
  },
20662
20707
  onMomentumScrollBegin: function onMomentumScrollBegin() {
20663
20708
  if (onEndReached && onEndReachedCalled && !loading) onEndReached();
@@ -20670,86 +20715,100 @@ var StyledOptionList = function StyledOptionList(_ref) {
20670
20715
  height: theme.space.xxxxlarge
20671
20716
  }
20672
20717
  }, /*#__PURE__*/React__default["default"].createElement(Spinner, null)) : null,
20673
- renderItem: function renderItem(_ref2) {
20674
- var item = _ref2.item,
20675
- index = _ref2.index;
20676
- return /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
20677
- key: getKey(item, index, keyExtractor)
20678
- }, /*#__PURE__*/React__default["default"].createElement(RenderItem, {
20679
- item: item
20680
- }));
20681
- }
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
20682
20730
  });
20683
20731
  };
20684
20732
 
20685
20733
  var Option$1 = function Option(_ref) {
20686
20734
  var text = _ref.text,
20735
+ _ref$disabled = _ref.disabled,
20736
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
20687
20737
  selected = _ref.selected,
20688
20738
  onPress = _ref.onPress;
20689
- return /*#__PURE__*/React__default["default"].createElement(OptionWrapper, {
20690
- themeSelected: selected,
20691
- onPress: onPress
20692
- }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
20739
+ var theme = useTheme();
20740
+ return /*#__PURE__*/React__default["default"].createElement(List.BasicItem, {
20741
+ selected: selected,
20742
+ disabled: disabled,
20743
+ onPress: onPress,
20744
+ title: text,
20745
+ suffix: selected ? 'checkmark' : undefined,
20693
20746
  style: {
20694
- flex: 1
20747
+ marginHorizontal: theme.__hd__.select.space.optionHorizontalMargin
20695
20748
  }
20696
- }, /*#__PURE__*/React__default["default"].createElement(Typography.Text, {
20697
- fontSize: "large"
20698
- }, text)), selected && /*#__PURE__*/React__default["default"].createElement(Icon, {
20699
- icon: "checkmark",
20700
- size: "small"
20701
- }));
20749
+ });
20702
20750
  };
20703
20751
 
20704
20752
  var OptionList$1 = function OptionList(_ref) {
20705
20753
  var keyExtractor = _ref.keyExtractor,
20706
20754
  loading = _ref.loading,
20707
20755
  onEndReached = _ref.onEndReached,
20708
- _onPress = _ref.onPress,
20756
+ onPress = _ref.onPress,
20709
20757
  onQueryChange = _ref.onQueryChange,
20710
- options = _ref.options,
20758
+ sections = _ref.sections,
20759
+ renderOption = _ref.renderOption,
20711
20760
  value = _ref.value;
20712
20761
  var firstValue = value === null || value === void 0 ? void 0 : value[0];
20713
- var rawScrollIndex = firstValue ? options.findIndex(function (option) {
20714
- return option.value === firstValue;
20715
- }) : 0;
20716
- var scrollIndex = rawScrollIndex - 2 >= 0 ? rawScrollIndex - 2 : 0;
20717
- var RenderItem = /*#__PURE__*/React__default["default"].memo(function (_ref2) {
20718
- var item = _ref2.item;
20719
- return /*#__PURE__*/React__default["default"].createElement(Option$1, {
20720
- text: item.text,
20721
- selected: value.includes(item.value),
20722
- onPress: function onPress() {
20723
- if (value.includes(item.value)) {
20724
- _onPress(value.filter(function (val) {
20725
- return val !== item.value;
20726
- }));
20727
- } else {
20728
- _onPress([].concat(_toConsumableArray(value), [item.value]));
20729
- }
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]));
20730
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
20731
20786
  });
20732
- });
20787
+ };
20788
+
20733
20789
  return /*#__PURE__*/React__default["default"].createElement(StyledOptionList, {
20734
20790
  keyExtractor: keyExtractor,
20735
20791
  loading: loading,
20736
20792
  onEndReached: onEndReached,
20737
20793
  onQueryChange: onQueryChange,
20738
- options: options,
20739
- RenderItem: RenderItem,
20740
- scrollIndex: scrollIndex
20794
+ sections: sections,
20795
+ renderItem: renderItem,
20796
+ scrollParams: scrollParams
20741
20797
  });
20742
20798
  };
20743
20799
 
20744
20800
  function MultiSelect(_ref) {
20745
20801
  var footerLabel = _ref.footerLabel,
20746
20802
  label = _ref.label,
20747
- loading = _ref.loading,
20803
+ _ref$loading = _ref.loading,
20804
+ loading = _ref$loading === void 0 ? false : _ref$loading,
20805
+ inputProps = _ref.inputProps,
20748
20806
  onConfirm = _ref.onConfirm,
20749
20807
  onDimiss = _ref.onDimiss,
20750
20808
  onEndReached = _ref.onEndReached,
20751
20809
  onQueryChange = _ref.onQueryChange,
20752
20810
  options = _ref.options,
20811
+ renderOption = _ref.renderOption,
20753
20812
  query = _ref.query,
20754
20813
  error = _ref.error,
20755
20814
  _ref$editable = _ref.editable,
@@ -20761,6 +20820,10 @@ function MultiSelect(_ref) {
20761
20820
  testID = _ref.testID,
20762
20821
  value = _ref.value;
20763
20822
 
20823
+ var _useKeyboard = useKeyboard(),
20824
+ isKeyboardVisible = _useKeyboard.isKeyboardVisible,
20825
+ keyboardHeight = _useKeyboard.keyboardHeight;
20826
+
20764
20827
  var _useState = React.useState(false),
20765
20828
  _useState2 = _slicedToArray(_useState, 2),
20766
20829
  open = _useState2[0],
@@ -20771,37 +20834,15 @@ function MultiSelect(_ref) {
20771
20834
  selectingValue = _useState4[0],
20772
20835
  setSelectingValue = _useState4[1];
20773
20836
 
20774
- var displayedValue = options.filter(function (opt) {
20837
+ var sections = toSections(options);
20838
+ var flatOptions = toFlatOptions(options);
20839
+ var displayedValue = flatOptions.filter(function (opt) {
20775
20840
  return value.includes(opt.value);
20776
20841
  }).map(function (opt) {
20777
20842
  return opt.text;
20778
20843
  }).join(', ');
20779
-
20780
- var _useState5 = React.useState(false),
20781
- _useState6 = _slicedToArray(_useState5, 2),
20782
- isKeyboardVisible = _useState6[0],
20783
- setKeyboardVisible = _useState6[1];
20784
-
20785
- var _useState7 = React.useState(0),
20786
- _useState8 = _slicedToArray(_useState7, 2),
20787
- keyboardHeight = _useState8[0],
20788
- setKeyboardHeight = _useState8[1];
20789
-
20790
- React.useEffect(function () {
20791
- var keyboardDidShowListener = reactNative.Keyboard.addListener('keyboardDidShow', function (e) {
20792
- setKeyboardVisible(true);
20793
- setKeyboardHeight(e.endCoordinates.height);
20794
- });
20795
- var keyboardDidHideListener = reactNative.Keyboard.addListener('keyboardDidHide', function () {
20796
- setKeyboardVisible(false);
20797
- });
20798
- return function () {
20799
- keyboardDidHideListener.remove();
20800
- keyboardDidShowListener.remove();
20801
- };
20802
- }, []);
20803
20844
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
20804
- pointerEvents: !editable || disabled ? 'none' : 'auto'
20845
+ pointerEvents: !editable || disabled || inputProps !== null && inputProps !== void 0 && inputProps.loading ? 'none' : 'auto'
20805
20846
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.TouchableOpacity, {
20806
20847
  onPress: function onPress() {
20807
20848
  return setOpen(true);
@@ -20814,6 +20855,7 @@ function MultiSelect(_ref) {
20814
20855
  error: error,
20815
20856
  editable: editable,
20816
20857
  disabled: disabled,
20858
+ loading: inputProps === null || inputProps === void 0 ? void 0 : inputProps.loading,
20817
20859
  numberOfLines: numberOfLines,
20818
20860
  pointerEvents: "none",
20819
20861
  style: style,
@@ -20845,9 +20887,11 @@ function MultiSelect(_ref) {
20845
20887
  onChangeText: onQueryChange,
20846
20888
  value: query
20847
20889
  })), /*#__PURE__*/React__default["default"].createElement(OptionList$1, {
20890
+ onQueryChange: onQueryChange,
20848
20891
  onEndReached: onEndReached,
20849
20892
  loading: loading,
20850
- options: options,
20893
+ sections: sections,
20894
+ renderOption: renderOption,
20851
20895
  value: selectingValue,
20852
20896
  onPress: setSelectingValue
20853
20897
  })));
@@ -20855,67 +20899,80 @@ function MultiSelect(_ref) {
20855
20899
 
20856
20900
  var Option = function Option(_ref) {
20857
20901
  var text = _ref.text,
20902
+ _ref$disabled = _ref.disabled,
20903
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
20858
20904
  selected = _ref.selected,
20859
20905
  onPress = _ref.onPress;
20860
- return /*#__PURE__*/React__default["default"].createElement(OptionWrapper, {
20861
- themeSelected: selected,
20862
- onPress: onPress
20863
- }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
20906
+ var theme = useTheme();
20907
+ return /*#__PURE__*/React__default["default"].createElement(List.BasicItem, {
20908
+ selected: selected,
20909
+ disabled: disabled,
20910
+ onPress: onPress,
20911
+ title: text,
20864
20912
  style: {
20865
- flex: 1
20913
+ marginHorizontal: theme.__hd__.select.space.optionHorizontalMargin
20866
20914
  }
20867
- }, /*#__PURE__*/React__default["default"].createElement(Typography.Text, {
20868
- fontSize: "large"
20869
- }, text)));
20915
+ });
20870
20916
  };
20871
20917
 
20872
20918
  var OptionList = function OptionList(_ref) {
20873
20919
  var keyExtractor = _ref.keyExtractor,
20874
20920
  loading = _ref.loading,
20875
20921
  onEndReached = _ref.onEndReached,
20876
- _onPress = _ref.onPress,
20922
+ onPress = _ref.onPress,
20877
20923
  onQueryChange = _ref.onQueryChange,
20878
- options = _ref.options,
20924
+ sections = _ref.sections,
20925
+ renderOption = _ref.renderOption,
20879
20926
  value = _ref.value;
20880
- var rawScrollIndex = options.findIndex(function (option) {
20881
- return option.value === value;
20882
- });
20883
- var scrollIndex = rawScrollIndex - 2 >= 0 ? rawScrollIndex - 2 : 0;
20884
- var RenderItem = /*#__PURE__*/React__default["default"].memo(function (_ref2) {
20885
- var item = _ref2.item;
20886
- return /*#__PURE__*/React__default["default"].createElement(Option, {
20887
- selected: value === item.value,
20888
- text: item.text,
20889
- onPress: function onPress() {
20890
- if (value === item.value) {
20891
- _onPress(null);
20892
- } else {
20893
- _onPress(item.value);
20894
- }
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);
20895
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
20896
20949
  });
20897
- });
20950
+ };
20951
+
20898
20952
  return /*#__PURE__*/React__default["default"].createElement(StyledOptionList, {
20899
20953
  keyExtractor: keyExtractor,
20900
20954
  loading: loading,
20901
20955
  onEndReached: onEndReached,
20902
20956
  onQueryChange: onQueryChange,
20903
- options: options,
20904
- RenderItem: RenderItem,
20905
- scrollIndex: scrollIndex
20957
+ sections: sections,
20958
+ renderItem: renderItem,
20959
+ scrollParams: scrollParams
20906
20960
  });
20907
20961
  };
20908
20962
 
20909
20963
  var SingleSelect = function SingleSelect(_ref) {
20910
- var _options$find;
20964
+ var _flatOptions$find;
20911
20965
 
20912
20966
  var label = _ref.label,
20913
- loading = _ref.loading,
20967
+ _ref$loading = _ref.loading,
20968
+ loading = _ref$loading === void 0 ? false : _ref$loading,
20969
+ inputProps = _ref.inputProps,
20914
20970
  onConfirm = _ref.onConfirm,
20915
20971
  onDimiss = _ref.onDimiss,
20916
20972
  onEndReached = _ref.onEndReached,
20917
20973
  onQueryChange = _ref.onQueryChange,
20918
20974
  options = _ref.options,
20975
+ renderOption = _ref.renderOption,
20919
20976
  query = _ref.query,
20920
20977
  error = _ref.error,
20921
20978
  _ref$editable = _ref.editable,
@@ -20927,6 +20984,10 @@ var SingleSelect = function SingleSelect(_ref) {
20927
20984
  testID = _ref.testID,
20928
20985
  value = _ref.value;
20929
20986
 
20987
+ var _useKeyboard = useKeyboard(),
20988
+ isKeyboardVisible = _useKeyboard.isKeyboardVisible,
20989
+ keyboardHeight = _useKeyboard.keyboardHeight;
20990
+
20930
20991
  var _useState = React.useState(false),
20931
20992
  _useState2 = _slicedToArray(_useState, 2),
20932
20993
  open = _useState2[0],
@@ -20937,35 +20998,13 @@ var SingleSelect = function SingleSelect(_ref) {
20937
20998
  selectingValue = _useState4[0],
20938
20999
  setSelectingValue = _useState4[1];
20939
21000
 
20940
- 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) {
20941
21004
  return value === opt.value;
20942
- })) === null || _options$find === void 0 ? void 0 : _options$find.text;
20943
-
20944
- var _useState5 = React.useState(false),
20945
- _useState6 = _slicedToArray(_useState5, 2),
20946
- isKeyboardVisible = _useState6[0],
20947
- setKeyboardVisible = _useState6[1];
20948
-
20949
- var _useState7 = React.useState(0),
20950
- _useState8 = _slicedToArray(_useState7, 2),
20951
- keyboardHeight = _useState8[0],
20952
- setKeyboardHeight = _useState8[1];
20953
-
20954
- React.useEffect(function () {
20955
- var keyboardDidShowListener = reactNative.Keyboard.addListener('keyboardWillShow', function (e) {
20956
- setKeyboardVisible(true);
20957
- setKeyboardHeight(e.endCoordinates.height);
20958
- });
20959
- var keyboardDidHideListener = reactNative.Keyboard.addListener('keyboardWillHide', function () {
20960
- setKeyboardVisible(false);
20961
- });
20962
- return function () {
20963
- keyboardDidHideListener.remove();
20964
- keyboardDidShowListener.remove();
20965
- };
20966
- }, []);
21005
+ })) === null || _flatOptions$find === void 0 ? void 0 : _flatOptions$find.text;
20967
21006
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
20968
- pointerEvents: !editable || disabled ? 'none' : 'auto'
21007
+ pointerEvents: !editable || disabled || inputProps !== null && inputProps !== void 0 && inputProps.loading ? 'none' : 'auto'
20969
21008
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.TouchableOpacity, {
20970
21009
  onPress: function onPress() {
20971
21010
  return setOpen(true);
@@ -20978,6 +21017,7 @@ var SingleSelect = function SingleSelect(_ref) {
20978
21017
  error: error,
20979
21018
  editable: editable,
20980
21019
  disabled: disabled,
21020
+ loading: inputProps === null || inputProps === void 0 ? void 0 : inputProps.loading,
20981
21021
  numberOfLines: numberOfLines,
20982
21022
  pointerEvents: "none",
20983
21023
  style: style,
@@ -21005,7 +21045,8 @@ var SingleSelect = function SingleSelect(_ref) {
21005
21045
  onQueryChange: onQueryChange,
21006
21046
  onEndReached: onEndReached,
21007
21047
  loading: loading,
21008
- options: options,
21048
+ sections: sections,
21049
+ renderOption: renderOption,
21009
21050
  value: selectingValue,
21010
21051
  onPress: function onPress(selectedValue) {
21011
21052
  setOpen(false);
@@ -21664,7 +21705,7 @@ var TimePickerIOS = function TimePickerIOS(_ref) {
21664
21705
  style = _ref.style,
21665
21706
  testID = _ref.testID;
21666
21707
 
21667
- var _useState = React.useState(value),
21708
+ var _useState = React.useState(value || new Date()),
21668
21709
  _useState2 = _slicedToArray(_useState, 2),
21669
21710
  selectingDate = _useState2[0],
21670
21711
  setSelectingDate = _useState2[1];
@@ -21716,7 +21757,7 @@ var TimePickerIOS = function TimePickerIOS(_ref) {
21716
21757
  }, confirmLabel))
21717
21758
  }, /*#__PURE__*/React__default["default"].createElement(StyledPickerWrapper, null, /*#__PURE__*/React__default["default"].createElement(DateTimePicker__default["default"], {
21718
21759
  testID: "timePickerIOS",
21719
- value: selectingDate || new Date(),
21760
+ value: selectingDate,
21720
21761
  mode: "time" // Current prop is24Hour config only available for Android.
21721
21762
  // This is a work around to get the picker to display 24 hour format for iOS.
21722
21763
  ,