UNPKG

@wordpress/components

Version:
81 lines (70 loc) 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports.KeyboardAwareFlatList = void 0; var _element = require("@wordpress/element"); var _reactNativeKeyboardAwareScrollView = require("react-native-keyboard-aware-scroll-view"); var _reactNative = require("react-native"); var _lodash = require("lodash"); /** * External dependencies */ /** * WordPress dependencies */ const List = (0, _element.memo)(_reactNative.FlatList, _lodash.isEqual); const KeyboardAwareFlatList = ({ extraScrollHeight, shouldPreventAutomaticScroll, innerRef, autoScroll, scrollViewStyle, inputAccessoryViewHeight, ...listProps }) => (0, _element.createElement)(_reactNativeKeyboardAwareScrollView.KeyboardAwareScrollView, { style: [{ flex: 1 }, scrollViewStyle], keyboardDismissMode: "none", enableResetScrollToCoords: false, keyboardShouldPersistTaps: "handled", extraScrollHeight: extraScrollHeight, extraHeight: 0, inputAccessoryViewHeight: inputAccessoryViewHeight, enableAutomaticScroll: autoScroll === undefined ? false : autoScroll, innerRef: ref => { (void 0).scrollViewRef = ref; innerRef(ref); }, onKeyboardWillHide: () => { (void 0).keyboardWillShowIndicator = false; }, onKeyboardDidHide: () => { setTimeout(() => { if (!(void 0).keyboardWillShowIndicator && (void 0).latestContentOffsetY !== undefined && !shouldPreventAutomaticScroll()) { // Reset the content position if keyboard is still closed if ((void 0).scrollViewRef) { (void 0).scrollViewRef.props.scrollToPosition(0, (void 0).latestContentOffsetY, true); } } }, 50); }, onKeyboardWillShow: () => { (void 0).keyboardWillShowIndicator = true; }, scrollEnabled: listProps.scrollEnabled, onScroll: event => { (void 0).latestContentOffsetY = event.nativeEvent.contentOffset.y; } }, (0, _element.createElement)(List, listProps)); exports.KeyboardAwareFlatList = KeyboardAwareFlatList; KeyboardAwareFlatList.handleCaretVerticalPositionChange = (scrollView, targetId, caretY, previousCaretY) => { if (previousCaretY) { //if this is not the first tap scrollView.props.refreshScrollForField(targetId); } }; var _default = KeyboardAwareFlatList; exports.default = _default; //# sourceMappingURL=index.ios.js.map