@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/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';
@@ -3455,15 +3455,13 @@ var getSectionHeadingTheme = function getSectionHeadingTheme(theme) {
3455
3455
 
3456
3456
  var getSelectTheme = function getSelectTheme(theme) {
3457
3457
  var colors = {
3458
- option: theme.colors.platformBackground,
3459
- checkedOption: theme.colors.primaryBackground,
3460
3458
  footerText: theme.colors.primary
3461
3459
  };
3462
3460
  var space = {
3463
3461
  minimumOptionListHeight: theme.space.xxxxlarge * 5,
3464
- optionPadding: theme.space.medium,
3465
- optionListPadding: theme.space.medium,
3466
- optionListSpacing: theme.space.xsmall,
3462
+ sectionSpacing: theme.space.smallMedium,
3463
+ optionSpacing: theme.space.xsmall,
3464
+ optionHorizontalMargin: theme.space.smallMedium,
3467
3465
  searchBarMarginTopSpacing: theme.space.small,
3468
3466
  searchBarHorizontalSpacing: theme.space.medium,
3469
3467
  searchBarBottomSpacing: theme.space.small
@@ -18842,11 +18840,12 @@ var StyledErrorAndMaxLengthContainer = index$6(View)(function () {
18842
18840
  };
18843
18841
  });
18844
18842
 
18845
- 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"];
18846
18844
  var getVariant = function getVariant(_ref) {
18847
18845
  var disabled = _ref.disabled,
18848
18846
  error = _ref.error,
18849
18847
  editable = _ref.editable,
18848
+ loading = _ref.loading,
18850
18849
  isFocused = _ref.isFocused,
18851
18850
  isEmptyValue = _ref.isEmptyValue;
18852
18851
 
@@ -18858,7 +18857,7 @@ var getVariant = function getVariant(_ref) {
18858
18857
  return 'error';
18859
18858
  }
18860
18859
 
18861
- if (!editable) {
18860
+ if (!editable || loading) {
18862
18861
  return 'readonly';
18863
18862
  }
18864
18863
 
@@ -18889,6 +18888,8 @@ var TextInput = function TextInput(_ref2) {
18889
18888
  editable = _ref2$editable === void 0 ? true : _ref2$editable,
18890
18889
  _ref2$disabled = _ref2.disabled,
18891
18890
  disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
18891
+ _ref2$loading = _ref2.loading,
18892
+ loading = _ref2$loading === void 0 ? false : _ref2$loading,
18892
18893
  maxLength = _ref2.maxLength,
18893
18894
  helpText = _ref2.helpText,
18894
18895
  value = _ref2.value,
@@ -18898,6 +18899,7 @@ var TextInput = function TextInput(_ref2) {
18898
18899
  var textInputReference = useRef(null);
18899
18900
  var displayText = (_ref3 = value !== undefined ? value : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
18900
18901
  var isEmptyValue = displayText.length === 0;
18902
+ var actualSuffix = loading ? 'loading' : suffix;
18901
18903
 
18902
18904
  var _React$useState = React.useState(false),
18903
18905
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -18908,6 +18910,7 @@ var TextInput = function TextInput(_ref2) {
18908
18910
  disabled: disabled,
18909
18911
  error: error,
18910
18912
  editable: editable,
18913
+ loading: loading,
18911
18914
  isFocused: isFocused,
18912
18915
  isEmptyValue: isEmptyValue
18913
18916
  });
@@ -18930,7 +18933,7 @@ var TextInput = function TextInput(_ref2) {
18930
18933
  fontSize: "small",
18931
18934
  themeVariant: variant
18932
18935
  }, label)), typeof prefix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
18933
- intent: disabled ? 'disabled-text' : 'text',
18936
+ intent: variant === 'disabled' ? 'disabled-text' : 'text',
18934
18937
  testID: "input-prefix",
18935
18938
  icon: prefix,
18936
18939
  size: "xsmall"
@@ -18951,7 +18954,7 @@ var TextInput = function TextInput(_ref2) {
18951
18954
  }, textStyle]),
18952
18955
  testID: "text-input",
18953
18956
  accessibilityState: {
18954
- disabled: disabled
18957
+ disabled: variant === 'disabled' || variant === 'readonly'
18955
18958
  } // @ts-ignore
18956
18959
  ,
18957
18960
  accessibilityLabelledBy: accessibilityLabelledBy
@@ -18979,10 +18982,11 @@ var TextInput = function TextInput(_ref2) {
18979
18982
  },
18980
18983
  defaultValue: defaultValue,
18981
18984
  placeholder: variant === 'focused' ? nativeProps.placeholder : undefined
18982
- }))), typeof suffix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
18983
- intent: disabled ? 'disabled-text' : 'text',
18985
+ }))), typeof actualSuffix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
18986
+ intent: variant === 'disabled' ? 'disabled-text' : 'text',
18984
18987
  testID: "input-suffix",
18985
- icon: suffix,
18988
+ icon: actualSuffix,
18989
+ spin: actualSuffix === 'loading',
18986
18990
  size: "xsmall"
18987
18991
  }) : suffix), /*#__PURE__*/React.createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React.createElement(StyledErrorAndMaxLengthContainer, null, error && /*#__PURE__*/React.createElement(StyledErrorContainer$1, null, /*#__PURE__*/React.createElement(Icon, {
18988
18992
  testID: "input-error-icon",
@@ -19076,7 +19080,7 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
19076
19080
  style = _ref.style,
19077
19081
  testID = _ref.testID;
19078
19082
 
19079
- var _useState = useState(value),
19083
+ var _useState = useState(value || new Date()),
19080
19084
  _useState2 = _slicedToArray(_useState, 2),
19081
19085
  selectingDate = _useState2[0],
19082
19086
  setSelectingDate = _useState2[1];
@@ -19127,7 +19131,7 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
19127
19131
  }, confirmLabel))
19128
19132
  }, /*#__PURE__*/React.createElement(StyledPickerWrapper$1, null, /*#__PURE__*/React.createElement(DateTimePicker, {
19129
19133
  testID: "datePickerIOS",
19130
- value: selectingDate || new Date(),
19134
+ value: selectingDate,
19131
19135
  mode: "date",
19132
19136
  onChange: function onChange(_, date) {
19133
19137
  if (date) {
@@ -19736,7 +19740,7 @@ var StyledListItemContainer = index$6(TouchableHighlight)(function (_ref3) {
19736
19740
  return {
19737
19741
  alignItems: 'center',
19738
19742
  flexDirection: 'row',
19739
- backgroundColor: themeSelected ? theme.__hd__.select.colors.checkedOption : theme.__hd__.select.colors.option,
19743
+ backgroundColor: themeSelected ? theme.__hd__.list.colors.checkedListItemContainerBackground : theme.__hd__.list.colors.listItemContainerBackground,
19740
19744
  padding: theme.__hd__.list.space.listItemContainerPadding,
19741
19745
  opacity: themeDisabled ? theme.__hd__.list.opacity.disabled : theme.__hd__.list.opacity.enabled
19742
19746
  };
@@ -19765,10 +19769,10 @@ var BasicListItem = function BasicListItem(_ref) {
19765
19769
  underlayColor: theme.__hd__.list.colors.highlightedListItemContainerBackground
19766
19770
  }, /*#__PURE__*/React.createElement(React.Fragment, null, prefix && /*#__PURE__*/React.createElement(StyledPrefixContainer, null, typeof prefix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
19767
19771
  icon: prefix
19768
- }) : 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, {
19769
19773
  intent: "body",
19770
19774
  fontSize: "large"
19771
- }, title), subtitle && /*#__PURE__*/React.createElement(Typography.Text, {
19775
+ }, title) : title, subtitle && /*#__PURE__*/React.createElement(Typography.Text, {
19772
19776
  intent: "subdued",
19773
19777
  fontSize: "small"
19774
19778
  }, subtitle)), suffix && /*#__PURE__*/React.createElement(StyledSuffixContainer, null, typeof suffix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
@@ -20427,7 +20431,7 @@ var Radio = function Radio(_ref) {
20427
20431
  })));
20428
20432
  };
20429
20433
 
20430
- function getKey$1(option, index, keyExtractor) {
20434
+ function getKey(option, index, keyExtractor) {
20431
20435
  var key = '';
20432
20436
 
20433
20437
  if (keyExtractor !== undefined) {
@@ -20453,7 +20457,7 @@ var RadioGroup = function RadioGroup(_ref) {
20453
20457
  testID: testID
20454
20458
  }, options.map(function (option, index) {
20455
20459
  return /*#__PURE__*/React.createElement(React.Fragment, {
20456
- key: getKey$1(option, index, keyExtractor)
20460
+ key: getKey(option, index, keyExtractor)
20457
20461
  }, index !== 0 && /*#__PURE__*/React.createElement(Spacer, null), /*#__PURE__*/React.createElement(Radio, {
20458
20462
  text: option.text,
20459
20463
  checked: option.value === value,
@@ -20535,22 +20539,16 @@ var SectionHeading = function SectionHeading(_ref) {
20535
20539
  }, text)), rightChildren);
20536
20540
  };
20537
20541
 
20538
- var OptionWrapper = index$6(TouchableOpacity)(function (_ref) {
20539
- var theme = _ref.theme,
20540
- themeSelected = _ref.themeSelected;
20542
+ var SectionSpacer = index$6(View)(function (_ref) {
20543
+ var theme = _ref.theme;
20541
20544
  return {
20542
- flexDirection: 'row',
20543
- justifyContent: 'space-between',
20544
- alignItems: 'center',
20545
- borderRadius: theme.__hd__.select.radii.option,
20546
- padding: theme.__hd__.select.space.optionPadding,
20547
- backgroundColor: themeSelected ? theme.__hd__.select.colors.checkedOption : theme.__hd__.select.colors.option
20545
+ marginTop: theme.__hd__.select.space.sectionSpacing
20548
20546
  };
20549
20547
  });
20550
- index$6(View)(function (_ref2) {
20548
+ var OptionSpacer = index$6(View)(function (_ref2) {
20551
20549
  var theme = _ref2.theme;
20552
20550
  return {
20553
- marginTop: theme.__hd__.select.space.optionListSpacing
20551
+ marginTop: theme.__hd__.select.space.optionSpacing
20554
20552
  };
20555
20553
  });
20556
20554
  var FooterText = index$6(Typography.Text)(function (_ref3) {
@@ -20579,18 +20577,70 @@ var Footer = function Footer(_ref) {
20579
20577
  }, label));
20580
20578
  };
20581
20579
 
20582
- var getKey = function getKey(option, index, keyExtractor) {
20583
- 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
+ }
20584
20588
 
20585
- if (keyExtractor !== undefined) {
20586
- key = keyExtractor(option, index);
20587
- } else if (option.key !== undefined) {
20588
- key = option.key;
20589
- } else {
20590
- 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
+ });
20591
20599
  }
20592
20600
 
20593
- 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
+ };
20594
20644
  };
20595
20645
 
20596
20646
  var StyledOptionList = function StyledOptionList(_ref) {
@@ -20598,26 +20648,23 @@ var StyledOptionList = function StyledOptionList(_ref) {
20598
20648
  loading = _ref.loading,
20599
20649
  onEndReached = _ref.onEndReached,
20600
20650
  onQueryChange = _ref.onQueryChange,
20601
- options = _ref.options,
20602
- RenderItem = _ref.RenderItem,
20603
- _ref$scrollIndex = _ref.scrollIndex,
20604
- scrollIndex = _ref$scrollIndex === void 0 ? 0 : _ref$scrollIndex;
20651
+ sections = _ref.sections,
20652
+ renderItem = _ref.renderItem,
20653
+ scrollParams = _ref.scrollParams;
20605
20654
  var theme = useTheme$1();
20606
- var flatListRef = useRef(null);
20655
+ var sectionListRef = useRef(null);
20607
20656
 
20608
20657
  var _useState = useState(false),
20609
20658
  _useState2 = _slicedToArray(_useState, 2),
20610
20659
  onEndReachedCalled = _useState2[0],
20611
20660
  setOnEndReachedCalled = _useState2[1];
20612
20661
 
20613
- return /*#__PURE__*/React.createElement(FlatList, {
20614
- ref: flatListRef,
20615
- style: _objectSpread2({
20616
- paddingHorizontal: theme.__hd__.select.space.optionListPadding
20617
- }, onQueryChange ? {
20662
+ return /*#__PURE__*/React.createElement(SectionList, {
20663
+ ref: sectionListRef,
20664
+ style: _objectSpread2({}, onQueryChange ? {
20618
20665
  height: Dimensions.get('screen').height
20619
20666
  } : {}),
20620
- data: options,
20667
+ sections: sections,
20621
20668
  keyExtractor: keyExtractor,
20622
20669
  onEndReachedThreshold: 0.1,
20623
20670
  onEndReached: function onEndReached() {
@@ -20625,11 +20672,9 @@ var StyledOptionList = function StyledOptionList(_ref) {
20625
20672
  },
20626
20673
  onScrollToIndexFailed: function onScrollToIndexFailed() {},
20627
20674
  onContentSizeChange: function onContentSizeChange() {
20628
- var _flatListRef$current;
20675
+ var _sectionListRef$curre;
20629
20676
 
20630
- return options.length && ((_flatListRef$current = flatListRef.current) === null || _flatListRef$current === void 0 ? void 0 : _flatListRef$current.scrollToIndex({
20631
- index: scrollIndex
20632
- }));
20677
+ return sections.length && ((_sectionListRef$curre = sectionListRef.current) === null || _sectionListRef$curre === void 0 ? void 0 : _sectionListRef$curre.scrollToLocation(scrollParams));
20633
20678
  },
20634
20679
  onMomentumScrollBegin: function onMomentumScrollBegin() {
20635
20680
  if (onEndReached && onEndReachedCalled && !loading) onEndReached();
@@ -20642,86 +20687,100 @@ var StyledOptionList = function StyledOptionList(_ref) {
20642
20687
  height: theme.space.xxxxlarge
20643
20688
  }
20644
20689
  }, /*#__PURE__*/React.createElement(Spinner, null)) : null,
20645
- renderItem: function renderItem(_ref2) {
20646
- var item = _ref2.item,
20647
- index = _ref2.index;
20648
- return /*#__PURE__*/React.createElement(View, {
20649
- key: getKey(item, index, keyExtractor)
20650
- }, /*#__PURE__*/React.createElement(RenderItem, {
20651
- item: item
20652
- }));
20653
- }
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
20654
20702
  });
20655
20703
  };
20656
20704
 
20657
20705
  var Option$1 = function Option(_ref) {
20658
20706
  var text = _ref.text,
20707
+ _ref$disabled = _ref.disabled,
20708
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
20659
20709
  selected = _ref.selected,
20660
20710
  onPress = _ref.onPress;
20661
- return /*#__PURE__*/React.createElement(OptionWrapper, {
20662
- themeSelected: selected,
20663
- onPress: onPress
20664
- }, /*#__PURE__*/React.createElement(View, {
20711
+ var theme = useTheme();
20712
+ return /*#__PURE__*/React.createElement(List.BasicItem, {
20713
+ selected: selected,
20714
+ disabled: disabled,
20715
+ onPress: onPress,
20716
+ title: text,
20717
+ suffix: selected ? 'checkmark' : undefined,
20665
20718
  style: {
20666
- flex: 1
20719
+ marginHorizontal: theme.__hd__.select.space.optionHorizontalMargin
20667
20720
  }
20668
- }, /*#__PURE__*/React.createElement(Typography.Text, {
20669
- fontSize: "large"
20670
- }, text)), selected && /*#__PURE__*/React.createElement(Icon, {
20671
- icon: "checkmark",
20672
- size: "small"
20673
- }));
20721
+ });
20674
20722
  };
20675
20723
 
20676
20724
  var OptionList$1 = function OptionList(_ref) {
20677
20725
  var keyExtractor = _ref.keyExtractor,
20678
20726
  loading = _ref.loading,
20679
20727
  onEndReached = _ref.onEndReached,
20680
- _onPress = _ref.onPress,
20728
+ onPress = _ref.onPress,
20681
20729
  onQueryChange = _ref.onQueryChange,
20682
- options = _ref.options,
20730
+ sections = _ref.sections,
20731
+ renderOption = _ref.renderOption,
20683
20732
  value = _ref.value;
20684
20733
  var firstValue = value === null || value === void 0 ? void 0 : value[0];
20685
- var rawScrollIndex = firstValue ? options.findIndex(function (option) {
20686
- return option.value === firstValue;
20687
- }) : 0;
20688
- var scrollIndex = rawScrollIndex - 2 >= 0 ? rawScrollIndex - 2 : 0;
20689
- var RenderItem = /*#__PURE__*/React.memo(function (_ref2) {
20690
- var item = _ref2.item;
20691
- return /*#__PURE__*/React.createElement(Option$1, {
20692
- text: item.text,
20693
- selected: value.includes(item.value),
20694
- onPress: function onPress() {
20695
- if (value.includes(item.value)) {
20696
- _onPress(value.filter(function (val) {
20697
- return val !== item.value;
20698
- }));
20699
- } else {
20700
- _onPress([].concat(_toConsumableArray(value), [item.value]));
20701
- }
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]));
20702
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
20703
20758
  });
20704
- });
20759
+ };
20760
+
20705
20761
  return /*#__PURE__*/React.createElement(StyledOptionList, {
20706
20762
  keyExtractor: keyExtractor,
20707
20763
  loading: loading,
20708
20764
  onEndReached: onEndReached,
20709
20765
  onQueryChange: onQueryChange,
20710
- options: options,
20711
- RenderItem: RenderItem,
20712
- scrollIndex: scrollIndex
20766
+ sections: sections,
20767
+ renderItem: renderItem,
20768
+ scrollParams: scrollParams
20713
20769
  });
20714
20770
  };
20715
20771
 
20716
20772
  function MultiSelect(_ref) {
20717
20773
  var footerLabel = _ref.footerLabel,
20718
20774
  label = _ref.label,
20719
- loading = _ref.loading,
20775
+ _ref$loading = _ref.loading,
20776
+ loading = _ref$loading === void 0 ? false : _ref$loading,
20777
+ inputProps = _ref.inputProps,
20720
20778
  onConfirm = _ref.onConfirm,
20721
20779
  onDimiss = _ref.onDimiss,
20722
20780
  onEndReached = _ref.onEndReached,
20723
20781
  onQueryChange = _ref.onQueryChange,
20724
20782
  options = _ref.options,
20783
+ renderOption = _ref.renderOption,
20725
20784
  query = _ref.query,
20726
20785
  error = _ref.error,
20727
20786
  _ref$editable = _ref.editable,
@@ -20733,6 +20792,10 @@ function MultiSelect(_ref) {
20733
20792
  testID = _ref.testID,
20734
20793
  value = _ref.value;
20735
20794
 
20795
+ var _useKeyboard = useKeyboard(),
20796
+ isKeyboardVisible = _useKeyboard.isKeyboardVisible,
20797
+ keyboardHeight = _useKeyboard.keyboardHeight;
20798
+
20736
20799
  var _useState = useState(false),
20737
20800
  _useState2 = _slicedToArray(_useState, 2),
20738
20801
  open = _useState2[0],
@@ -20743,37 +20806,15 @@ function MultiSelect(_ref) {
20743
20806
  selectingValue = _useState4[0],
20744
20807
  setSelectingValue = _useState4[1];
20745
20808
 
20746
- var displayedValue = options.filter(function (opt) {
20809
+ var sections = toSections(options);
20810
+ var flatOptions = toFlatOptions(options);
20811
+ var displayedValue = flatOptions.filter(function (opt) {
20747
20812
  return value.includes(opt.value);
20748
20813
  }).map(function (opt) {
20749
20814
  return opt.text;
20750
20815
  }).join(', ');
20751
-
20752
- var _useState5 = useState(false),
20753
- _useState6 = _slicedToArray(_useState5, 2),
20754
- isKeyboardVisible = _useState6[0],
20755
- setKeyboardVisible = _useState6[1];
20756
-
20757
- var _useState7 = useState(0),
20758
- _useState8 = _slicedToArray(_useState7, 2),
20759
- keyboardHeight = _useState8[0],
20760
- setKeyboardHeight = _useState8[1];
20761
-
20762
- useEffect(function () {
20763
- var keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', function (e) {
20764
- setKeyboardVisible(true);
20765
- setKeyboardHeight(e.endCoordinates.height);
20766
- });
20767
- var keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', function () {
20768
- setKeyboardVisible(false);
20769
- });
20770
- return function () {
20771
- keyboardDidHideListener.remove();
20772
- keyboardDidShowListener.remove();
20773
- };
20774
- }, []);
20775
20816
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
20776
- pointerEvents: !editable || disabled ? 'none' : 'auto'
20817
+ pointerEvents: !editable || disabled || inputProps !== null && inputProps !== void 0 && inputProps.loading ? 'none' : 'auto'
20777
20818
  }, /*#__PURE__*/React.createElement(TouchableOpacity, {
20778
20819
  onPress: function onPress() {
20779
20820
  return setOpen(true);
@@ -20786,6 +20827,7 @@ function MultiSelect(_ref) {
20786
20827
  error: error,
20787
20828
  editable: editable,
20788
20829
  disabled: disabled,
20830
+ loading: inputProps === null || inputProps === void 0 ? void 0 : inputProps.loading,
20789
20831
  numberOfLines: numberOfLines,
20790
20832
  pointerEvents: "none",
20791
20833
  style: style,
@@ -20817,9 +20859,11 @@ function MultiSelect(_ref) {
20817
20859
  onChangeText: onQueryChange,
20818
20860
  value: query
20819
20861
  })), /*#__PURE__*/React.createElement(OptionList$1, {
20862
+ onQueryChange: onQueryChange,
20820
20863
  onEndReached: onEndReached,
20821
20864
  loading: loading,
20822
- options: options,
20865
+ sections: sections,
20866
+ renderOption: renderOption,
20823
20867
  value: selectingValue,
20824
20868
  onPress: setSelectingValue
20825
20869
  })));
@@ -20827,67 +20871,80 @@ function MultiSelect(_ref) {
20827
20871
 
20828
20872
  var Option = function Option(_ref) {
20829
20873
  var text = _ref.text,
20874
+ _ref$disabled = _ref.disabled,
20875
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
20830
20876
  selected = _ref.selected,
20831
20877
  onPress = _ref.onPress;
20832
- return /*#__PURE__*/React.createElement(OptionWrapper, {
20833
- themeSelected: selected,
20834
- onPress: onPress
20835
- }, /*#__PURE__*/React.createElement(View, {
20878
+ var theme = useTheme();
20879
+ return /*#__PURE__*/React.createElement(List.BasicItem, {
20880
+ selected: selected,
20881
+ disabled: disabled,
20882
+ onPress: onPress,
20883
+ title: text,
20836
20884
  style: {
20837
- flex: 1
20885
+ marginHorizontal: theme.__hd__.select.space.optionHorizontalMargin
20838
20886
  }
20839
- }, /*#__PURE__*/React.createElement(Typography.Text, {
20840
- fontSize: "large"
20841
- }, text)));
20887
+ });
20842
20888
  };
20843
20889
 
20844
20890
  var OptionList = function OptionList(_ref) {
20845
20891
  var keyExtractor = _ref.keyExtractor,
20846
20892
  loading = _ref.loading,
20847
20893
  onEndReached = _ref.onEndReached,
20848
- _onPress = _ref.onPress,
20894
+ onPress = _ref.onPress,
20849
20895
  onQueryChange = _ref.onQueryChange,
20850
- options = _ref.options,
20896
+ sections = _ref.sections,
20897
+ renderOption = _ref.renderOption,
20851
20898
  value = _ref.value;
20852
- var rawScrollIndex = options.findIndex(function (option) {
20853
- return option.value === value;
20854
- });
20855
- var scrollIndex = rawScrollIndex - 2 >= 0 ? rawScrollIndex - 2 : 0;
20856
- var RenderItem = /*#__PURE__*/React.memo(function (_ref2) {
20857
- var item = _ref2.item;
20858
- return /*#__PURE__*/React.createElement(Option, {
20859
- selected: value === item.value,
20860
- text: item.text,
20861
- onPress: function onPress() {
20862
- if (value === item.value) {
20863
- _onPress(null);
20864
- } else {
20865
- _onPress(item.value);
20866
- }
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);
20867
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
20868
20921
  });
20869
- });
20922
+ };
20923
+
20870
20924
  return /*#__PURE__*/React.createElement(StyledOptionList, {
20871
20925
  keyExtractor: keyExtractor,
20872
20926
  loading: loading,
20873
20927
  onEndReached: onEndReached,
20874
20928
  onQueryChange: onQueryChange,
20875
- options: options,
20876
- RenderItem: RenderItem,
20877
- scrollIndex: scrollIndex
20929
+ sections: sections,
20930
+ renderItem: renderItem,
20931
+ scrollParams: scrollParams
20878
20932
  });
20879
20933
  };
20880
20934
 
20881
20935
  var SingleSelect = function SingleSelect(_ref) {
20882
- var _options$find;
20936
+ var _flatOptions$find;
20883
20937
 
20884
20938
  var label = _ref.label,
20885
- loading = _ref.loading,
20939
+ _ref$loading = _ref.loading,
20940
+ loading = _ref$loading === void 0 ? false : _ref$loading,
20941
+ inputProps = _ref.inputProps,
20886
20942
  onConfirm = _ref.onConfirm,
20887
20943
  onDimiss = _ref.onDimiss,
20888
20944
  onEndReached = _ref.onEndReached,
20889
20945
  onQueryChange = _ref.onQueryChange,
20890
20946
  options = _ref.options,
20947
+ renderOption = _ref.renderOption,
20891
20948
  query = _ref.query,
20892
20949
  error = _ref.error,
20893
20950
  _ref$editable = _ref.editable,
@@ -20899,6 +20956,10 @@ var SingleSelect = function SingleSelect(_ref) {
20899
20956
  testID = _ref.testID,
20900
20957
  value = _ref.value;
20901
20958
 
20959
+ var _useKeyboard = useKeyboard(),
20960
+ isKeyboardVisible = _useKeyboard.isKeyboardVisible,
20961
+ keyboardHeight = _useKeyboard.keyboardHeight;
20962
+
20902
20963
  var _useState = useState(false),
20903
20964
  _useState2 = _slicedToArray(_useState, 2),
20904
20965
  open = _useState2[0],
@@ -20909,35 +20970,13 @@ var SingleSelect = function SingleSelect(_ref) {
20909
20970
  selectingValue = _useState4[0],
20910
20971
  setSelectingValue = _useState4[1];
20911
20972
 
20912
- 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) {
20913
20976
  return value === opt.value;
20914
- })) === null || _options$find === void 0 ? void 0 : _options$find.text;
20915
-
20916
- var _useState5 = useState(false),
20917
- _useState6 = _slicedToArray(_useState5, 2),
20918
- isKeyboardVisible = _useState6[0],
20919
- setKeyboardVisible = _useState6[1];
20920
-
20921
- var _useState7 = useState(0),
20922
- _useState8 = _slicedToArray(_useState7, 2),
20923
- keyboardHeight = _useState8[0],
20924
- setKeyboardHeight = _useState8[1];
20925
-
20926
- useEffect(function () {
20927
- var keyboardDidShowListener = Keyboard.addListener('keyboardWillShow', function (e) {
20928
- setKeyboardVisible(true);
20929
- setKeyboardHeight(e.endCoordinates.height);
20930
- });
20931
- var keyboardDidHideListener = Keyboard.addListener('keyboardWillHide', function () {
20932
- setKeyboardVisible(false);
20933
- });
20934
- return function () {
20935
- keyboardDidHideListener.remove();
20936
- keyboardDidShowListener.remove();
20937
- };
20938
- }, []);
20977
+ })) === null || _flatOptions$find === void 0 ? void 0 : _flatOptions$find.text;
20939
20978
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
20940
- pointerEvents: !editable || disabled ? 'none' : 'auto'
20979
+ pointerEvents: !editable || disabled || inputProps !== null && inputProps !== void 0 && inputProps.loading ? 'none' : 'auto'
20941
20980
  }, /*#__PURE__*/React.createElement(TouchableOpacity, {
20942
20981
  onPress: function onPress() {
20943
20982
  return setOpen(true);
@@ -20950,6 +20989,7 @@ var SingleSelect = function SingleSelect(_ref) {
20950
20989
  error: error,
20951
20990
  editable: editable,
20952
20991
  disabled: disabled,
20992
+ loading: inputProps === null || inputProps === void 0 ? void 0 : inputProps.loading,
20953
20993
  numberOfLines: numberOfLines,
20954
20994
  pointerEvents: "none",
20955
20995
  style: style,
@@ -20977,7 +21017,8 @@ var SingleSelect = function SingleSelect(_ref) {
20977
21017
  onQueryChange: onQueryChange,
20978
21018
  onEndReached: onEndReached,
20979
21019
  loading: loading,
20980
- options: options,
21020
+ sections: sections,
21021
+ renderOption: renderOption,
20981
21022
  value: selectingValue,
20982
21023
  onPress: function onPress(selectedValue) {
20983
21024
  setOpen(false);
@@ -21636,7 +21677,7 @@ var TimePickerIOS = function TimePickerIOS(_ref) {
21636
21677
  style = _ref.style,
21637
21678
  testID = _ref.testID;
21638
21679
 
21639
- var _useState = useState(value),
21680
+ var _useState = useState(value || new Date()),
21640
21681
  _useState2 = _slicedToArray(_useState, 2),
21641
21682
  selectingDate = _useState2[0],
21642
21683
  setSelectingDate = _useState2[1];
@@ -21688,7 +21729,7 @@ var TimePickerIOS = function TimePickerIOS(_ref) {
21688
21729
  }, confirmLabel))
21689
21730
  }, /*#__PURE__*/React.createElement(StyledPickerWrapper, null, /*#__PURE__*/React.createElement(DateTimePicker, {
21690
21731
  testID: "timePickerIOS",
21691
- value: selectingDate || new Date(),
21732
+ value: selectingDate,
21692
21733
  mode: "time" // Current prop is24Hour config only available for Android.
21693
21734
  // This is a work around to get the picker to display 24 hour format for iOS.
21694
21735
  ,