@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.
- package/.turbo/turbo-build.log +2 -2
- package/es/index.js +228 -187
- package/lib/index.js +227 -186
- package/package.json +2 -2
- package/src/components/DatePicker/DatePickerIOS.tsx +2 -2
- package/src/components/List/BasicListItem.tsx +8 -4
- package/src/components/List/StyledBasicListItem.tsx +2 -2
- package/src/components/Select/MultiSelect/Option.tsx +21 -15
- package/src/components/Select/MultiSelect/OptionList.tsx +47 -41
- package/src/components/Select/MultiSelect/__tests__/OptionList.spec.tsx +25 -14
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +41 -21
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1995 -352
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5611 -523
- package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +122 -1
- package/src/components/Select/MultiSelect/index.tsx +26 -36
- package/src/components/Select/SingleSelect/Option.tsx +20 -13
- package/src/components/Select/SingleSelect/OptionList.tsx +47 -39
- package/src/components/Select/SingleSelect/__tests__/OptionList.spec.tsx +23 -12
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +23 -14
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1846 -258
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +5140 -412
- package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +117 -1
- package/src/components/Select/SingleSelect/index.tsx +26 -37
- package/src/components/Select/StyledOptionList.tsx +43 -44
- package/src/components/Select/StyledSelect.tsx +6 -15
- package/src/components/Select/__tests__/StyledSelect.spec.tsx +1 -23
- package/src/components/Select/__tests__/__snapshots__/StyledSelect.spec.tsx.snap +0 -67
- package/src/components/Select/__tests__/helpers.spec.tsx +74 -0
- package/src/components/Select/helpers.tsx +87 -4
- package/src/components/Select/types.ts +99 -0
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +157 -1
- package/src/components/TextInput/__tests__/index.spec.tsx +29 -8
- package/src/components/TextInput/index.tsx +18 -7
- package/src/components/TimePicker/TimePickerIOS.tsx +2 -2
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +3 -5
- package/src/theme/components/select.ts +3 -5
- package/src/types.ts +7 -1
- package/types/components/List/BasicListItem.d.ts +1 -1
- package/types/components/Select/MultiSelect/Option.d.ts +4 -2
- package/types/components/Select/MultiSelect/OptionList.d.ts +6 -7
- package/types/components/Select/MultiSelect/index.d.ts +5 -5
- package/types/components/Select/SingleSelect/Option.d.ts +4 -2
- package/types/components/Select/SingleSelect/OptionList.d.ts +6 -7
- package/types/components/Select/SingleSelect/index.d.ts +5 -5
- package/types/components/Select/StyledOptionList.d.ts +10 -16
- package/types/components/Select/StyledSelect.d.ts +5 -7
- package/types/components/Select/__tests__/helpers.spec.d.ts +1 -0
- package/types/components/Select/helpers.d.ts +14 -2
- package/types/components/Select/index.d.ts +1 -1
- package/types/components/Select/types.d.ts +32 -7
- package/types/components/TextInput/index.d.ts +4 -2
- package/types/theme/components/select.d.ts +3 -5
- package/types/types.d.ts +2 -1
- 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
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
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
|
|
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:
|
|
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
|
|
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__.
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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.
|
|
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
|
|
20611
|
-
var
|
|
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
|
-
|
|
20614
|
-
|
|
20615
|
-
|
|
20616
|
-
|
|
20617
|
-
|
|
20618
|
-
|
|
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
|
|
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
|
-
|
|
20630
|
-
|
|
20631
|
-
|
|
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
|
|
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.
|
|
20642
|
-
ref:
|
|
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
|
-
|
|
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
|
|
20703
|
+
var _sectionListRef$curre;
|
|
20657
20704
|
|
|
20658
|
-
return
|
|
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
|
-
|
|
20674
|
-
var
|
|
20675
|
-
|
|
20676
|
-
|
|
20677
|
-
|
|
20678
|
-
|
|
20679
|
-
|
|
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
|
-
|
|
20690
|
-
|
|
20691
|
-
|
|
20692
|
-
|
|
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
|
-
|
|
20747
|
+
marginHorizontal: theme.__hd__.select.space.optionHorizontalMargin
|
|
20695
20748
|
}
|
|
20696
|
-
}
|
|
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
|
-
|
|
20756
|
+
onPress = _ref.onPress,
|
|
20709
20757
|
onQueryChange = _ref.onQueryChange,
|
|
20710
|
-
|
|
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
|
|
20714
|
-
|
|
20715
|
-
|
|
20716
|
-
|
|
20717
|
-
|
|
20718
|
-
|
|
20719
|
-
|
|
20720
|
-
|
|
20721
|
-
|
|
20722
|
-
|
|
20723
|
-
|
|
20724
|
-
|
|
20725
|
-
|
|
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
|
-
|
|
20739
|
-
|
|
20740
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
20861
|
-
|
|
20862
|
-
|
|
20863
|
-
|
|
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
|
-
|
|
20913
|
+
marginHorizontal: theme.__hd__.select.space.optionHorizontalMargin
|
|
20866
20914
|
}
|
|
20867
|
-
}
|
|
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
|
-
|
|
20922
|
+
onPress = _ref.onPress,
|
|
20877
20923
|
onQueryChange = _ref.onQueryChange,
|
|
20878
|
-
|
|
20924
|
+
sections = _ref.sections,
|
|
20925
|
+
renderOption = _ref.renderOption,
|
|
20879
20926
|
value = _ref.value;
|
|
20880
|
-
var
|
|
20881
|
-
|
|
20882
|
-
|
|
20883
|
-
|
|
20884
|
-
|
|
20885
|
-
|
|
20886
|
-
|
|
20887
|
-
|
|
20888
|
-
|
|
20889
|
-
|
|
20890
|
-
|
|
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
|
-
|
|
20904
|
-
|
|
20905
|
-
|
|
20957
|
+
sections: sections,
|
|
20958
|
+
renderItem: renderItem,
|
|
20959
|
+
scrollParams: scrollParams
|
|
20906
20960
|
});
|
|
20907
20961
|
};
|
|
20908
20962
|
|
|
20909
20963
|
var SingleSelect = function SingleSelect(_ref) {
|
|
20910
|
-
var
|
|
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
|
|
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 ||
|
|
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
|
-
|
|
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
|
|
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
|
,
|