@codeleap/mobile 2.3.7 → 2.3.8
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/CodeLeap-Mobile-Packages.code-workspace +7 -7
- package/dist/components/ActionIcon/index.d.ts +13 -13
- package/dist/components/ActionIcon/index.js +54 -54
- package/dist/components/ActionIcon/styles.d.ts +65 -65
- package/dist/components/ActionIcon/styles.js +60 -60
- package/dist/components/ActivityIndicator/index.d.ts +15 -15
- package/dist/components/ActivityIndicator/index.js +58 -58
- package/dist/components/ActivityIndicator/styles.d.ts +59 -59
- package/dist/components/ActivityIndicator/styles.js +51 -51
- package/dist/components/Animated.d.ts +124 -124
- package/dist/components/Animated.js +58 -58
- package/dist/components/AutoComplete/index.d.ts +33 -33
- package/dist/components/AutoComplete/index.js +128 -128
- package/dist/components/AutoComplete/styles.d.ts +57 -57
- package/dist/components/AutoComplete/styles.js +24 -24
- package/dist/components/Backdrop/index.d.ts +14 -14
- package/dist/components/Backdrop/index.js +62 -62
- package/dist/components/Backdrop/styles.d.ts +53 -53
- package/dist/components/Backdrop/styles.js +27 -27
- package/dist/components/Button/index.d.ts +246 -246
- package/dist/components/Button/index.js +118 -118
- package/dist/components/Button/styles.d.ts +65 -65
- package/dist/components/Button/styles.js +60 -60
- package/dist/components/Calendar/index.d.ts +15 -15
- package/dist/components/Calendar/index.js +79 -79
- package/dist/components/Calendar/style.d.ts +4 -4
- package/dist/components/Calendar/style.js +35 -35
- package/dist/components/Calendar/types.d.ts +95 -95
- package/dist/components/Calendar/types.js +2 -2
- package/dist/components/Checkbox/index.d.ts +15 -15
- package/dist/components/Checkbox/index.js +84 -84
- package/dist/components/Checkbox/styles.d.ts +56 -56
- package/dist/components/Checkbox/styles.js +52 -52
- package/dist/components/ContentView/index.d.ts +12 -12
- package/dist/components/ContentView/index.js +65 -65
- package/dist/components/ContentView/styles.d.ts +53 -53
- package/dist/components/ContentView/styles.js +25 -25
- package/dist/components/Drawer/index.d.ts +7 -7
- package/dist/components/Drawer/index.js +69 -69
- package/dist/components/Drawer/styles.d.ts +56 -56
- package/dist/components/Drawer/styles.js +38 -38
- package/dist/components/EmptyPlaceholder/index.d.ts +22 -22
- package/dist/components/EmptyPlaceholder/index.js +77 -77
- package/dist/components/EmptyPlaceholder/styles.d.ts +55 -55
- package/dist/components/EmptyPlaceholder/styles.js +31 -31
- package/dist/components/FileInput/index.d.ts +24 -24
- package/dist/components/FileInput/index.js +182 -182
- package/dist/components/FileInput/styles.d.ts +53 -53
- package/dist/components/FileInput/styles.js +18 -18
- package/dist/components/Grid/index.d.ts +32 -32
- package/dist/components/Grid/index.js +83 -83
- package/dist/components/Grid/styles.d.ts +5 -5
- package/dist/components/Grid/styles.js +18 -18
- package/dist/components/Icon/index.d.ts +14 -14
- package/dist/components/Icon/index.js +78 -78
- package/dist/components/Icon/styles.d.ts +61 -61
- package/dist/components/Icon/styles.js +48 -48
- package/dist/components/Image/index.d.ts +20 -20
- package/dist/components/Image/index.js +90 -90
- package/dist/components/Image/styles.d.ts +54 -54
- package/dist/components/Image/styles.js +24 -24
- package/dist/components/ImageView/Spotlight.d.ts +25 -25
- package/dist/components/ImageView/Spotlight.js +153 -153
- package/dist/components/ImageView/component.d.ts +5 -5
- package/dist/components/ImageView/component.js +53 -53
- package/dist/components/ImageView/index.d.ts +2 -2
- package/dist/components/ImageView/index.js +18 -18
- package/dist/components/InputLabel/index.d.ts +12 -12
- package/dist/components/InputLabel/index.js +61 -61
- package/dist/components/InputLabel/styles.d.ts +4 -4
- package/dist/components/InputLabel/styles.js +25 -25
- package/dist/components/List/PaginationIndicator.d.ts +67 -67
- package/dist/components/List/PaginationIndicator.js +50 -50
- package/dist/components/List/index.d.ts +31 -31
- package/dist/components/List/index.js +80 -80
- package/dist/components/List/styles.d.ts +5 -5
- package/dist/components/List/styles.js +26 -26
- package/dist/components/Modal/index.d.ts +41 -41
- package/dist/components/Modal/index.js +143 -143
- package/dist/components/Modal/styles.d.ts +58 -58
- package/dist/components/Modal/styles.js +74 -74
- package/dist/components/MultiSelect/index.d.ts +6 -6
- package/dist/components/MultiSelect/index.js +117 -117
- package/dist/components/MultiSelect/styles.d.ts +58 -58
- package/dist/components/MultiSelect/styles.js +21 -21
- package/dist/components/MultiSelect/types.d.ts +35 -35
- package/dist/components/MultiSelect/types.js +2 -2
- package/dist/components/Navigation/Navigation.d.ts +3 -3
- package/dist/components/Navigation/Navigation.js +83 -83
- package/dist/components/Navigation/constants.d.ts +5 -5
- package/dist/components/Navigation/constants.js +10 -10
- package/dist/components/Navigation/index.d.ts +3 -3
- package/dist/components/Navigation/index.js +19 -19
- package/dist/components/Navigation/types.d.ts +26 -26
- package/dist/components/Navigation/types.js +7 -7
- package/dist/components/Navigation/utils.d.ts +3 -3
- package/dist/components/Navigation/utils.js +68 -68
- package/dist/components/Pager/index.d.ts +26 -26
- package/dist/components/Pager/index.js +87 -87
- package/dist/components/Pager/styles.d.ts +87 -87
- package/dist/components/Pager/styles.js +71 -71
- package/dist/components/RadioInput/index.d.ts +27 -27
- package/dist/components/RadioInput/index.js +75 -75
- package/dist/components/RadioInput/styles.d.ts +58 -58
- package/dist/components/RadioInput/styles.js +49 -49
- package/dist/components/Scroll/index.d.ts +20 -20
- package/dist/components/Scroll/index.js +100 -100
- package/dist/components/Scroll/styles.d.ts +4 -4
- package/dist/components/Scroll/styles.js +26 -26
- package/dist/components/Sections/index.d.ts +11 -11
- package/dist/components/Sections/index.js +79 -79
- package/dist/components/SegmentedControl/index.d.ts +52 -52
- package/dist/components/SegmentedControl/index.js +132 -132
- package/dist/components/SegmentedControl/styles.d.ts +60 -60
- package/dist/components/SegmentedControl/styles.js +42 -42
- package/dist/components/Select/index.d.ts +13 -13
- package/dist/components/Select/index.js +130 -130
- package/dist/components/Select/styles.d.ts +59 -59
- package/dist/components/Select/styles.js +31 -31
- package/dist/components/Select/types.d.ts +36 -36
- package/dist/components/Select/types.js +2 -2
- package/dist/components/Slider/Mark.d.ts +3 -3
- package/dist/components/Slider/Mark.js +31 -31
- package/dist/components/Slider/Thumb.d.ts +7 -7
- package/dist/components/Slider/Thumb.js +29 -29
- package/dist/components/Slider/index.d.ts +4 -4
- package/dist/components/Slider/index.js +102 -102
- package/dist/components/Slider/styles.d.ts +54 -54
- package/dist/components/Slider/styles.js +60 -60
- package/dist/components/Slider/types.d.ts +26 -26
- package/dist/components/Slider/types.js +2 -2
- package/dist/components/Switch/index.d.ts +14 -14
- package/dist/components/Switch/index.js +84 -84
- package/dist/components/Switch/styles.d.ts +55 -55
- package/dist/components/Switch/styles.js +33 -33
- package/dist/components/Text/index.d.ts +23 -23
- package/dist/components/Text/index.js +124 -124
- package/dist/components/Text/styles.d.ts +70 -70
- package/dist/components/Text/styles.js +30 -30
- package/dist/components/TextInput/index.d.ts +181 -181
- package/dist/components/TextInput/index.js +213 -213
- package/dist/components/TextInput/styles.d.ts +63 -63
- package/dist/components/TextInput/styles.js +64 -64
- package/dist/components/Touchable/index.d.ts +21 -21
- package/dist/components/Touchable/index.js +157 -157
- package/dist/components/Touchable/styles.d.ts +58 -58
- package/dist/components/Touchable/styles.js +23 -23
- package/dist/components/View/index.d.ts +132 -132
- package/dist/components/View/index.js +101 -101
- package/dist/components/View/styles.d.ts +54 -54
- package/dist/components/View/styles.js +28 -28
- package/dist/components/components.d.ts +38 -38
- package/dist/components/components.js +67 -67
- package/dist/components/defaultStyles.d.ts +1369 -1369
- package/dist/components/defaultStyles.js +64 -64
- package/dist/components/legacy/Modal/index.d.ts +28 -28
- package/dist/components/legacy/Modal/index.js +113 -113
- package/dist/components/legacy/Modal/styles.d.ts +64 -64
- package/dist/components/legacy/Modal/styles.js +59 -59
- package/dist/components/legacy/Pager/index.d.ts +20 -20
- package/dist/components/legacy/Pager/index.js +167 -167
- package/dist/components/legacy/Pager/styles.d.ts +54 -54
- package/dist/components/legacy/Pager/styles.js +43 -43
- package/dist/components/legacy/index.d.ts +2 -2
- package/dist/components/legacy/index.js +18 -18
- package/dist/index.d.ts +7 -7
- package/dist/index.js +42 -42
- package/dist/modules/documentPicker.d.ts +3 -3
- package/dist/modules/documentPicker.js +11 -11
- package/dist/modules/fastImage.d.ts +1 -1
- package/dist/modules/fastImage.js +9 -9
- package/dist/modules/reactNavigation.d.ts +5 -5
- package/dist/modules/reactNavigation.js +25 -25
- package/dist/modules/textInputMask.d.ts +10 -10
- package/dist/modules/textInputMask.js +22 -22
- package/dist/modules/types/fileTypes.d.ts +138 -138
- package/dist/modules/types/fileTypes.js +2 -2
- package/dist/modules/types/textInputMask.d.ts +7 -7
- package/dist/modules/types/textInputMask.js +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +17 -17
- package/dist/types/utility.d.ts +8 -8
- package/dist/types/utility.js +2 -2
- package/dist/utils/KeyboardAware/context.d.ts +13 -13
- package/dist/utils/KeyboardAware/context.js +67 -67
- package/dist/utils/KeyboardAware/index.d.ts +8 -8
- package/dist/utils/KeyboardAware/index.js +32 -32
- package/dist/utils/KeyboardAware/keyboardHooks.d.ts +26 -26
- package/dist/utils/KeyboardAware/keyboardHooks.js +89 -89
- package/dist/utils/KeyboardAware/lib/KeyboardAwareFlatList.d.ts +3 -3
- package/dist/utils/KeyboardAware/lib/KeyboardAwareFlatList.js +8 -8
- package/dist/utils/KeyboardAware/lib/KeyboardAwareHOC.d.ts +67 -67
- package/dist/utils/KeyboardAware/lib/KeyboardAwareHOC.js +450 -450
- package/dist/utils/KeyboardAware/lib/KeyboardAwareInterface.d.ts +7 -7
- package/dist/utils/KeyboardAware/lib/KeyboardAwareInterface.js +3 -3
- package/dist/utils/KeyboardAware/lib/KeyboardAwareScrollView.d.ts +3 -3
- package/dist/utils/KeyboardAware/lib/KeyboardAwareScrollView.js +9 -9
- package/dist/utils/KeyboardAware/lib/KeyboardAwareSectionList.d.ts +3 -3
- package/dist/utils/KeyboardAware/lib/KeyboardAwareSectionList.js +9 -9
- package/dist/utils/KeyboardAware/types.d.ts +1 -1
- package/dist/utils/KeyboardAware/types.js +6 -6
- package/dist/utils/ModalManager/components.d.ts +20 -20
- package/dist/utils/ModalManager/components.js +117 -117
- package/dist/utils/ModalManager/context.d.ts +48 -48
- package/dist/utils/ModalManager/context.js +204 -204
- package/dist/utils/ModalManager/index.d.ts +11 -11
- package/dist/utils/ModalManager/index.js +12 -12
- package/dist/utils/OSAlert.d.ts +32 -32
- package/dist/utils/OSAlert.js +142 -142
- package/dist/utils/PermissionManager/context.d.ts +52 -52
- package/dist/utils/PermissionManager/context.js +315 -315
- package/dist/utils/PermissionManager/index.d.ts +4 -4
- package/dist/utils/PermissionManager/index.js +8 -8
- package/dist/utils/PermissionManager/types.d.ts +13 -13
- package/dist/utils/PermissionManager/types.js +2 -2
- package/dist/utils/hooks.d.ts +40 -40
- package/dist/utils/hooks.js +130 -130
- package/dist/utils/index.d.ts +10 -10
- package/dist/utils/index.js +39 -39
- package/dist/utils/input.d.ts +35 -35
- package/dist/utils/input.js +48 -48
- package/dist/utils/misc.d.ts +6 -6
- package/dist/utils/misc.js +86 -86
- package/dist/utils/notifications.d.ts +34 -34
- package/dist/utils/notifications.js +267 -267
- package/dist/utils/theme.d.ts +42 -42
- package/dist/utils/theme.js +52 -52
- package/package.json +54 -54
- package/src/index.ts +7 -7
|
@@ -1,451 +1,451 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable max-lines */
|
|
3
|
-
/* @flow */
|
|
4
|
-
var __extends = (this && this.__extends) || (function () {
|
|
5
|
-
var extendStatics = function (d, b) {
|
|
6
|
-
extendStatics = Object.setPrototypeOf ||
|
|
7
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
9
|
-
return extendStatics(d, b);
|
|
10
|
-
};
|
|
11
|
-
return function (d, b) {
|
|
12
|
-
if (typeof b !== "function" && b !== null)
|
|
13
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
14
|
-
extendStatics(d, b);
|
|
15
|
-
function __() { this.constructor = d; }
|
|
16
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
17
|
-
};
|
|
18
|
-
})();
|
|
19
|
-
var __assign = (this && this.__assign) || function () {
|
|
20
|
-
__assign = Object.assign || function(t) {
|
|
21
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
22
|
-
s = arguments[i];
|
|
23
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
24
|
-
t[p] = s[p];
|
|
25
|
-
}
|
|
26
|
-
return t;
|
|
27
|
-
};
|
|
28
|
-
return __assign.apply(this, arguments);
|
|
29
|
-
};
|
|
30
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
31
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
32
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
33
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
34
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
35
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
36
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
40
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
41
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
42
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
43
|
-
function step(op) {
|
|
44
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
45
|
-
while (_) try {
|
|
46
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
47
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
48
|
-
switch (op[0]) {
|
|
49
|
-
case 0: case 1: t = op; break;
|
|
50
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
51
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
52
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
53
|
-
default:
|
|
54
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
55
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
56
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
57
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
58
|
-
if (t[2]) _.ops.pop();
|
|
59
|
-
_.trys.pop(); continue;
|
|
60
|
-
}
|
|
61
|
-
op = body.call(thisArg, _);
|
|
62
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
63
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
67
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
68
|
-
};
|
|
69
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
-
exports.isIphoneX = void 0;
|
|
71
|
-
var react_1 = __importDefault(require("react"));
|
|
72
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
73
|
-
var react_native_1 = require("react-native");
|
|
74
|
-
function isIphoneX() {
|
|
75
|
-
var dimen = react_native_1.Dimensions.get('window');
|
|
76
|
-
return (react_native_1.Platform.OS === 'ios' &&
|
|
77
|
-
!react_native_1.Platform.isPad &&
|
|
78
|
-
!react_native_1.Platform.isTVOS &&
|
|
79
|
-
((dimen.height === 780 || dimen.width === 780)
|
|
80
|
-
|| (dimen.height === 812 || dimen.width === 812)
|
|
81
|
-
|| (dimen.height === 844 || dimen.width === 844)
|
|
82
|
-
|| (dimen.height === 896 || dimen.width === 896)
|
|
83
|
-
|| (dimen.height === 926 || dimen.width === 926)));
|
|
84
|
-
}
|
|
85
|
-
exports.isIphoneX = isIphoneX;
|
|
86
|
-
var _KAM_DEFAULT_TAB_BAR_HEIGHT = isIphoneX() ? 83 : 49;
|
|
87
|
-
var _KAM_KEYBOARD_OPENING_TIME = 250;
|
|
88
|
-
var _KAM_EXTRA_HEIGHT = 75;
|
|
89
|
-
var supportedKeyboardEvents = [
|
|
90
|
-
'keyboardWillShow',
|
|
91
|
-
'keyboardDidShow',
|
|
92
|
-
'keyboardWillHide',
|
|
93
|
-
'keyboardDidHide',
|
|
94
|
-
'keyboardWillChangeFrame',
|
|
95
|
-
'keyboardDidChangeFrame',
|
|
96
|
-
];
|
|
97
|
-
var keyboardEventToCallbackName = function (eventName) { return 'on' + eventName[0].toUpperCase() + eventName.substring(1); };
|
|
98
|
-
var keyboardEventPropTypes = supportedKeyboardEvents.reduce(function (acc, eventName) {
|
|
99
|
-
var _a;
|
|
100
|
-
return (__assign(__assign({}, acc), (_a = {}, _a[keyboardEventToCallbackName(eventName)] = prop_types_1.default.func, _a)));
|
|
101
|
-
}, {});
|
|
102
|
-
var keyboardAwareHOCTypeEvents = supportedKeyboardEvents.reduce(function (acc, eventName) {
|
|
103
|
-
var _a;
|
|
104
|
-
return (__assign(__assign({}, acc), (_a = {}, _a[keyboardEventToCallbackName(eventName)] = Function, _a)));
|
|
105
|
-
}, {});
|
|
106
|
-
function getDisplayName(WrappedComponent) {
|
|
107
|
-
return ((WrappedComponent &&
|
|
108
|
-
(WrappedComponent.displayName || WrappedComponent.name)) ||
|
|
109
|
-
'Component');
|
|
110
|
-
}
|
|
111
|
-
var ScrollIntoViewDefaultOptions = {
|
|
112
|
-
enableOnAndroid: false,
|
|
113
|
-
contentContainerStyle: undefined,
|
|
114
|
-
enableAutomaticScroll: true,
|
|
115
|
-
extraHeight: _KAM_EXTRA_HEIGHT,
|
|
116
|
-
extraScrollHeight: 0,
|
|
117
|
-
enableResetScrollToCoords: true,
|
|
118
|
-
keyboardOpeningTime: _KAM_KEYBOARD_OPENING_TIME,
|
|
119
|
-
viewIsInsideTabBar: false,
|
|
120
|
-
// The ref prop name that will be passed to the wrapped component to obtain a ref
|
|
121
|
-
// If your ScrollView is already wrapped, maybe the wrapper permit to get a ref
|
|
122
|
-
// For example, with glamorous-native ScrollView, you should use "innerRef"
|
|
123
|
-
refPropName: 'ref',
|
|
124
|
-
// Sometimes the ref you get is a ref to a wrapped view (ex: Animated.ScrollView)
|
|
125
|
-
// We need access to the imperative API of a real native ScrollView so we need extraction logic
|
|
126
|
-
extractNativeRef: function (ref) {
|
|
127
|
-
// getNode() permit to support Animated.ScrollView automatically, but is deprecated since RN 0.62
|
|
128
|
-
// see https://github.com/facebook/react-native/issues/19650
|
|
129
|
-
// see https://stackoverflow.com/questions/42051368/scrollto-is-undefined-on-animated-scrollview/48786374
|
|
130
|
-
// see https://github.com/facebook/react-native/commit/66e72bb4e00aafbcb9f450ed5db261d98f99f82a
|
|
131
|
-
var shouldCallGetNode = !react_native_1.Platform.constants || (react_native_1.Platform.constants.reactNativeVersion.major === 0 && react_native_1.Platform.constants.reactNativeVersion.minor < 62);
|
|
132
|
-
if (ref.getNode && shouldCallGetNode) {
|
|
133
|
-
return ref.getNode();
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
return ref;
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
var KeyboardAwareScrollable = /** @class */ (function (_super) {
|
|
141
|
-
__extends(KeyboardAwareScrollable, _super);
|
|
142
|
-
function KeyboardAwareScrollable(props) {
|
|
143
|
-
var _this = _super.call(this, props) || this;
|
|
144
|
-
_this.getScrollResponder = function () {
|
|
145
|
-
return (_this._rnkasv_keyboardView &&
|
|
146
|
-
_this._rnkasv_keyboardView.getScrollResponder &&
|
|
147
|
-
_this._rnkasv_keyboardView.getScrollResponder());
|
|
148
|
-
};
|
|
149
|
-
_this.scrollToPosition = function (x, y, animated) {
|
|
150
|
-
if (animated === void 0) { animated = true; }
|
|
151
|
-
var responder = _this.getScrollResponder();
|
|
152
|
-
if (!responder) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (responder.scrollResponderScrollTo) {
|
|
156
|
-
// React Native < 0.65
|
|
157
|
-
responder.scrollResponderScrollTo({ x: x, y: y, animated: animated });
|
|
158
|
-
}
|
|
159
|
-
else if (responder.scrollTo) {
|
|
160
|
-
// React Native >= 0.65
|
|
161
|
-
responder.scrollTo({ x: x, y: y, animated: animated });
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
_this.scrollToEnd = function (animated) {
|
|
165
|
-
if (animated === void 0) { animated = true; }
|
|
166
|
-
var responder = _this.getScrollResponder();
|
|
167
|
-
if (!responder) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
if (responder.scrollResponderScrollToEnd) {
|
|
171
|
-
// React Native < 0.65
|
|
172
|
-
responder.scrollResponderScrollToEnd({ animated: animated });
|
|
173
|
-
}
|
|
174
|
-
else if (responder.scrollToEnd) {
|
|
175
|
-
// React Native >= 0.65
|
|
176
|
-
responder.scrollToEnd({ animated: animated });
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
_this.scrollForExtraHeightOnAndroid = function (extraHeight) {
|
|
180
|
-
_this.scrollToPosition(0, _this.position.y + extraHeight, true);
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* @param keyboardOpeningTime: takes a different keyboardOpeningTime in consideration.
|
|
184
|
-
* @param extraHeight: takes an extra height in consideration.
|
|
185
|
-
*/
|
|
186
|
-
_this.scrollToFocusedInput = function (reactNode, extraHeight, keyboardOpeningTime) {
|
|
187
|
-
if (extraHeight === undefined) {
|
|
188
|
-
extraHeight = _this.props.extraHeight || 0;
|
|
189
|
-
}
|
|
190
|
-
if (keyboardOpeningTime === undefined) {
|
|
191
|
-
keyboardOpeningTime = _this.props.keyboardOpeningTime || 0;
|
|
192
|
-
}
|
|
193
|
-
setTimeout(function () {
|
|
194
|
-
if (!_this.mountedComponent) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
var responder = _this.getScrollResponder();
|
|
198
|
-
responder &&
|
|
199
|
-
responder.scrollResponderScrollNativeHandleToKeyboard(reactNode, extraHeight, true);
|
|
200
|
-
}, keyboardOpeningTime);
|
|
201
|
-
};
|
|
202
|
-
_this.scrollIntoView = function (element, options) {
|
|
203
|
-
if (options === void 0) { options = {}; }
|
|
204
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
205
|
-
var _a, parentLayout, childLayout, getScrollPosition, _b, x, y, animated;
|
|
206
|
-
return __generator(this, function (_c) {
|
|
207
|
-
switch (_c.label) {
|
|
208
|
-
case 0:
|
|
209
|
-
if (!this._rnkasv_keyboardView || !element) {
|
|
210
|
-
return [2 /*return*/];
|
|
211
|
-
}
|
|
212
|
-
return [4 /*yield*/, Promise.all([
|
|
213
|
-
this._measureElement(this._rnkasv_keyboardView),
|
|
214
|
-
this._measureElement(element),
|
|
215
|
-
])];
|
|
216
|
-
case 1:
|
|
217
|
-
_a = _c.sent(), parentLayout = _a[0], childLayout = _a[1];
|
|
218
|
-
getScrollPosition = options.getScrollPosition || this._defaultGetScrollPosition;
|
|
219
|
-
_b = getScrollPosition(parentLayout, childLayout, this.position), x = _b.x, y = _b.y, animated = _b.animated;
|
|
220
|
-
this.scrollToPosition(x, y, animated);
|
|
221
|
-
return [2 /*return*/];
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
_this._defaultGetScrollPosition = function (parentLayout, childLayout, contentOffset) {
|
|
227
|
-
return {
|
|
228
|
-
x: 0,
|
|
229
|
-
y: Math.max(0, childLayout.y - parentLayout.y + contentOffset.y),
|
|
230
|
-
animated: true,
|
|
231
|
-
};
|
|
232
|
-
};
|
|
233
|
-
_this._measureElement = function (element) {
|
|
234
|
-
var node = (0, react_native_1.findNodeHandle)(element);
|
|
235
|
-
return new Promise(function (resolve) {
|
|
236
|
-
react_native_1.UIManager.measureInWindow(node, function (x, y, width, height) {
|
|
237
|
-
resolve({ x: x, y: y, width: width, height: height });
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
};
|
|
241
|
-
// Keyboard actions
|
|
242
|
-
_this._updateKeyboardSpace = function (frames) {
|
|
243
|
-
// Automatically scroll to focused TextInput
|
|
244
|
-
if (_this.props.enableAutomaticScroll) {
|
|
245
|
-
var keyboardSpace_1 = frames.endCoordinates.height + _this.props.extraScrollHeight;
|
|
246
|
-
if (_this.props.viewIsInsideTabBar) {
|
|
247
|
-
keyboardSpace_1 -= _KAM_DEFAULT_TAB_BAR_HEIGHT;
|
|
248
|
-
}
|
|
249
|
-
_this.setState({ keyboardSpace: keyboardSpace_1 });
|
|
250
|
-
var currentlyFocusedField_1 = react_native_1.TextInput.State.currentlyFocusedInput ?
|
|
251
|
-
(0, react_native_1.findNodeHandle)(react_native_1.TextInput.State.currentlyFocusedInput()) : react_native_1.TextInput.State.currentlyFocusedField();
|
|
252
|
-
var responder = _this.getScrollResponder();
|
|
253
|
-
if (!currentlyFocusedField_1 || !responder) {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
// @ts-ignore
|
|
257
|
-
react_native_1.UIManager.viewIsDescendantOf(currentlyFocusedField_1, responder.getInnerViewNode(), function (isAncestor) {
|
|
258
|
-
if (isAncestor) {
|
|
259
|
-
// Check if the TextInput will be hidden by the keyboard
|
|
260
|
-
react_native_1.UIManager.measureInWindow(currentlyFocusedField_1, function (x, y, width, height) {
|
|
261
|
-
var textInputBottomPosition = y + height;
|
|
262
|
-
var keyboardPosition = frames.endCoordinates.screenY;
|
|
263
|
-
var totalExtraHeight = _this.props.extraScrollHeight + _this.props.extraHeight;
|
|
264
|
-
if (react_native_1.Platform.OS === 'ios') {
|
|
265
|
-
if (textInputBottomPosition >
|
|
266
|
-
keyboardPosition - totalExtraHeight) {
|
|
267
|
-
_this._scrollToFocusedInputWithNodeHandle(currentlyFocusedField_1);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
// On android, the system would scroll the text input just
|
|
272
|
-
// above the keyboard so we just neet to scroll the extra
|
|
273
|
-
// height part
|
|
274
|
-
if (textInputBottomPosition > keyboardPosition) {
|
|
275
|
-
// Since the system already scrolled the whole view up
|
|
276
|
-
// we should reduce that amount
|
|
277
|
-
keyboardSpace_1 =
|
|
278
|
-
keyboardSpace_1 -
|
|
279
|
-
(textInputBottomPosition - keyboardPosition);
|
|
280
|
-
_this.setState({ keyboardSpace: keyboardSpace_1 });
|
|
281
|
-
_this.scrollForExtraHeightOnAndroid(totalExtraHeight);
|
|
282
|
-
}
|
|
283
|
-
else if (textInputBottomPosition >
|
|
284
|
-
keyboardPosition - totalExtraHeight) {
|
|
285
|
-
_this.scrollForExtraHeightOnAndroid(totalExtraHeight -
|
|
286
|
-
(keyboardPosition - textInputBottomPosition));
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
if (!_this.props.resetScrollToCoords) {
|
|
294
|
-
if (!_this.defaultResetScrollToCoords) {
|
|
295
|
-
_this.defaultResetScrollToCoords = _this.position;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
_this._resetKeyboardSpace = function () {
|
|
300
|
-
var keyboardSpace = _this.props.viewIsInsideTabBar
|
|
301
|
-
? _KAM_DEFAULT_TAB_BAR_HEIGHT
|
|
302
|
-
: 0;
|
|
303
|
-
_this.setState({ keyboardSpace: keyboardSpace });
|
|
304
|
-
// Reset scroll position after keyboard dismissal
|
|
305
|
-
if (_this.props.enableResetScrollToCoords === false) {
|
|
306
|
-
_this.defaultResetScrollToCoords = null;
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
else if (_this.props.resetScrollToCoords) {
|
|
310
|
-
_this.scrollToPosition(_this.props.resetScrollToCoords.x, _this.props.resetScrollToCoords.y, true);
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
if (_this.defaultResetScrollToCoords) {
|
|
314
|
-
_this.scrollToPosition(_this.defaultResetScrollToCoords.x, _this.defaultResetScrollToCoords.y, true);
|
|
315
|
-
_this.defaultResetScrollToCoords = null;
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
_this.scrollToPosition(0, 0, true);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
_this._scrollToFocusedInputWithNodeHandle = function (nodeID, extraHeight, keyboardOpeningTime) {
|
|
323
|
-
if (extraHeight === undefined) {
|
|
324
|
-
extraHeight = _this.props.extraHeight;
|
|
325
|
-
}
|
|
326
|
-
var reactNode = (0, react_native_1.findNodeHandle)(nodeID);
|
|
327
|
-
_this.scrollToFocusedInput(reactNode, extraHeight + _this.props.extraScrollHeight, keyboardOpeningTime !== undefined
|
|
328
|
-
? keyboardOpeningTime
|
|
329
|
-
: _this.props.keyboardOpeningTime || 0);
|
|
330
|
-
};
|
|
331
|
-
_this._handleOnScroll = function (e) {
|
|
332
|
-
_this.position = e.nativeEvent.contentOffset;
|
|
333
|
-
};
|
|
334
|
-
_this._handleRef = function (ref) {
|
|
335
|
-
_this._rnkasv_keyboardView = ref ? _this.props.hocOptions.extractNativeRef(ref) : ref;
|
|
336
|
-
if (_this.props.innerRef) {
|
|
337
|
-
_this.props.innerRef(_this._rnkasv_keyboardView);
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
_this.update = function () {
|
|
341
|
-
var currentlyFocusedField = react_native_1.TextInput.State.currentlyFocusedInput ?
|
|
342
|
-
(0, react_native_1.findNodeHandle)(react_native_1.TextInput.State.currentlyFocusedInput()) : react_native_1.TextInput.State.currentlyFocusedField();
|
|
343
|
-
var responder = _this.getScrollResponder();
|
|
344
|
-
if (!currentlyFocusedField || !responder) {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
_this._scrollToFocusedInputWithNodeHandle(currentlyFocusedField);
|
|
348
|
-
};
|
|
349
|
-
_this.keyboardWillShowEvent = undefined;
|
|
350
|
-
_this.keyboardWillHideEvent = undefined;
|
|
351
|
-
_this.callbacks = {};
|
|
352
|
-
_this.position = { x: 0, y: 0 };
|
|
353
|
-
_this.defaultResetScrollToCoords = null;
|
|
354
|
-
var keyboardSpace = props.viewIsInsideTabBar
|
|
355
|
-
? _KAM_DEFAULT_TAB_BAR_HEIGHT
|
|
356
|
-
: 0;
|
|
357
|
-
_this.state = { keyboardSpace: keyboardSpace };
|
|
358
|
-
return _this;
|
|
359
|
-
}
|
|
360
|
-
KeyboardAwareScrollable.prototype.componentDidMount = function () {
|
|
361
|
-
var _this = this;
|
|
362
|
-
this.mountedComponent = true;
|
|
363
|
-
// Keyboard events
|
|
364
|
-
if (react_native_1.Platform.OS === 'ios') {
|
|
365
|
-
this.keyboardWillShowEvent = react_native_1.Keyboard.addListener('keyboardWillShow', this._updateKeyboardSpace);
|
|
366
|
-
this.keyboardWillHideEvent = react_native_1.Keyboard.addListener('keyboardWillHide', this._resetKeyboardSpace);
|
|
367
|
-
}
|
|
368
|
-
else if (react_native_1.Platform.OS === 'android' && this.props.enableOnAndroid) {
|
|
369
|
-
this.keyboardWillShowEvent = react_native_1.Keyboard.addListener('keyboardDidShow', this._updateKeyboardSpace);
|
|
370
|
-
this.keyboardWillHideEvent = react_native_1.Keyboard.addListener('keyboardDidHide', this._resetKeyboardSpace);
|
|
371
|
-
}
|
|
372
|
-
supportedKeyboardEvents.forEach(function (eventName) {
|
|
373
|
-
var callbackName = keyboardEventToCallbackName(eventName);
|
|
374
|
-
if (_this.props[callbackName]) {
|
|
375
|
-
_this.callbacks[eventName] = react_native_1.Keyboard.addListener(eventName, _this.props[callbackName]);
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
};
|
|
379
|
-
KeyboardAwareScrollable.prototype.componentDidUpdate = function (prevProps) {
|
|
380
|
-
if (this.props.viewIsInsideTabBar !== prevProps.viewIsInsideTabBar) {
|
|
381
|
-
var keyboardSpace = this.props.viewIsInsideTabBar
|
|
382
|
-
? _KAM_DEFAULT_TAB_BAR_HEIGHT
|
|
383
|
-
: 0;
|
|
384
|
-
if (this.state.keyboardSpace !== keyboardSpace) {
|
|
385
|
-
this.setState({ keyboardSpace: keyboardSpace });
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
KeyboardAwareScrollable.prototype.componentWillUnmount = function () {
|
|
390
|
-
this.mountedComponent = false;
|
|
391
|
-
this.keyboardWillShowEvent && this.keyboardWillShowEvent.remove();
|
|
392
|
-
this.keyboardWillHideEvent && this.keyboardWillHideEvent.remove();
|
|
393
|
-
Object.values(this.callbacks).forEach(function (callback) { return callback.remove(); });
|
|
394
|
-
};
|
|
395
|
-
KeyboardAwareScrollable.prototype.render = function () {
|
|
396
|
-
var _a;
|
|
397
|
-
var _b = this.props, enableOnAndroid = _b.enableOnAndroid, contentContainerStyle = _b.contentContainerStyle, onScroll = _b.onScroll, Scrollable = _b.Scrollable;
|
|
398
|
-
var newContentContainerStyle;
|
|
399
|
-
if (react_native_1.Platform.OS === 'android' && enableOnAndroid) {
|
|
400
|
-
newContentContainerStyle = [].concat(contentContainerStyle).concat({
|
|
401
|
-
paddingBottom: ((contentContainerStyle || {}).paddingBottom || 0) +
|
|
402
|
-
this.state.keyboardSpace,
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
var refProps = (_a = {}, _a[this.props.hocOptions.refPropName] = this._handleRef, _a);
|
|
406
|
-
return (<Scrollable {...refProps} keyboardDismissMode='interactive' contentInset={{ bottom: this.state.keyboardSpace }} automaticallyAdjustContentInsets={false} showsVerticalScrollIndicator={true} scrollEventThrottle={1} {...this.props} contentContainerStyle={newContentContainerStyle || contentContainerStyle} keyboardSpace={this.state.keyboardSpace} getScrollResponder={this.getScrollResponder} scrollToPosition={this.scrollToPosition} scrollToEnd={this.scrollToEnd} scrollForExtraHeightOnAndroid={this.scrollForExtraHeightOnAndroid} scrollToFocusedInput={this.scrollToFocusedInput} scrollIntoView={this.scrollIntoView} resetKeyboardSpace={this._resetKeyboardSpace} handleOnScroll={this._handleOnScroll} update={this.update}
|
|
407
|
-
// @ts-ignore
|
|
408
|
-
onScroll={react_native_1.Animated.forkEvent(onScroll, this._handleOnScroll)}/>);
|
|
409
|
-
};
|
|
410
|
-
KeyboardAwareScrollable.displayName = "KeyboardAware";
|
|
411
|
-
KeyboardAwareScrollable.propTypes = __assign({ viewIsInsideTabBar: prop_types_1.default.bool, resetScrollToCoords: prop_types_1.default.shape({
|
|
412
|
-
x: prop_types_1.default.number.isRequired,
|
|
413
|
-
y: prop_types_1.default.number.isRequired,
|
|
414
|
-
}), enableResetScrollToCoords: prop_types_1.default.bool, enableAutomaticScroll: prop_types_1.default.bool, extraHeight: prop_types_1.default.number, extraScrollHeight: prop_types_1.default.number, keyboardOpeningTime: prop_types_1.default.number, onScroll: prop_types_1.default.oneOfType([
|
|
415
|
-
prop_types_1.default.func,
|
|
416
|
-
prop_types_1.default.object, // Animated.event listener
|
|
417
|
-
]), update: prop_types_1.default.func, contentContainerStyle: prop_types_1.default.any, enableOnAndroid: prop_types_1.default.bool, innerRef: prop_types_1.default.func }, keyboardEventPropTypes);
|
|
418
|
-
// HOC options are used to init default props, so that these options can be overriden with component props
|
|
419
|
-
KeyboardAwareScrollable.defaultProps = {
|
|
420
|
-
enableAutomaticScroll: ScrollIntoViewDefaultOptions.enableAutomaticScroll,
|
|
421
|
-
extraHeight: ScrollIntoViewDefaultOptions.extraHeight,
|
|
422
|
-
extraScrollHeight: ScrollIntoViewDefaultOptions.extraScrollHeight,
|
|
423
|
-
enableResetScrollToCoords: ScrollIntoViewDefaultOptions.enableResetScrollToCoords,
|
|
424
|
-
keyboardOpeningTime: ScrollIntoViewDefaultOptions.keyboardOpeningTime,
|
|
425
|
-
viewIsInsideTabBar: ScrollIntoViewDefaultOptions.viewIsInsideTabBar,
|
|
426
|
-
enableOnAndroid: ScrollIntoViewDefaultOptions.enableOnAndroid,
|
|
427
|
-
};
|
|
428
|
-
return KeyboardAwareScrollable;
|
|
429
|
-
}(react_1.default.Component));
|
|
430
|
-
function KeyboardAwareHOC(ScrollableComponent, userOptions) {
|
|
431
|
-
if (userOptions === void 0) { userOptions = ScrollIntoViewDefaultOptions; }
|
|
432
|
-
var hocOptions = __assign(__assign({}, ScrollIntoViewDefaultOptions), userOptions);
|
|
433
|
-
return react_1.default.forwardRef(function (props, ref) { return <KeyboardAwareScrollable hocOptions={hocOptions}
|
|
434
|
-
// @ts-ignore
|
|
435
|
-
ref={ref} Scrollable={ScrollableComponent} {...props}/>; });
|
|
436
|
-
}
|
|
437
|
-
// Allow to pass options, without breaking change, and curried for composition
|
|
438
|
-
// listenToKeyboardEvents(ScrollView);
|
|
439
|
-
// listenToKeyboardEvents(options)(Comp);
|
|
440
|
-
var listenToKeyboardEvents = function (configOrComp) {
|
|
441
|
-
//@ts-ignore
|
|
442
|
-
if (typeof configOrComp === 'object' && !configOrComp.displayName) {
|
|
443
|
-
return (function (Comp) { return KeyboardAwareHOC(Comp, configOrComp); });
|
|
444
|
-
}
|
|
445
|
-
else {
|
|
446
|
-
//@ts-ignore
|
|
447
|
-
return KeyboardAwareHOC(configOrComp);
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
exports.default = listenToKeyboardEvents;
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable max-lines */
|
|
3
|
+
/* @flow */
|
|
4
|
+
var __extends = (this && this.__extends) || (function () {
|
|
5
|
+
var extendStatics = function (d, b) {
|
|
6
|
+
extendStatics = Object.setPrototypeOf ||
|
|
7
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
9
|
+
return extendStatics(d, b);
|
|
10
|
+
};
|
|
11
|
+
return function (d, b) {
|
|
12
|
+
if (typeof b !== "function" && b !== null)
|
|
13
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
14
|
+
extendStatics(d, b);
|
|
15
|
+
function __() { this.constructor = d; }
|
|
16
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
var __assign = (this && this.__assign) || function () {
|
|
20
|
+
__assign = Object.assign || function(t) {
|
|
21
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
22
|
+
s = arguments[i];
|
|
23
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
24
|
+
t[p] = s[p];
|
|
25
|
+
}
|
|
26
|
+
return t;
|
|
27
|
+
};
|
|
28
|
+
return __assign.apply(this, arguments);
|
|
29
|
+
};
|
|
30
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
31
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
32
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
33
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
34
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
35
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
36
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
40
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
41
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
42
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
43
|
+
function step(op) {
|
|
44
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
45
|
+
while (_) try {
|
|
46
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
47
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
48
|
+
switch (op[0]) {
|
|
49
|
+
case 0: case 1: t = op; break;
|
|
50
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
51
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
52
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
53
|
+
default:
|
|
54
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
55
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
56
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
57
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
58
|
+
if (t[2]) _.ops.pop();
|
|
59
|
+
_.trys.pop(); continue;
|
|
60
|
+
}
|
|
61
|
+
op = body.call(thisArg, _);
|
|
62
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
63
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
67
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
68
|
+
};
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
exports.isIphoneX = void 0;
|
|
71
|
+
var react_1 = __importDefault(require("react"));
|
|
72
|
+
var prop_types_1 = __importDefault(require("prop-types"));
|
|
73
|
+
var react_native_1 = require("react-native");
|
|
74
|
+
function isIphoneX() {
|
|
75
|
+
var dimen = react_native_1.Dimensions.get('window');
|
|
76
|
+
return (react_native_1.Platform.OS === 'ios' &&
|
|
77
|
+
!react_native_1.Platform.isPad &&
|
|
78
|
+
!react_native_1.Platform.isTVOS &&
|
|
79
|
+
((dimen.height === 780 || dimen.width === 780)
|
|
80
|
+
|| (dimen.height === 812 || dimen.width === 812)
|
|
81
|
+
|| (dimen.height === 844 || dimen.width === 844)
|
|
82
|
+
|| (dimen.height === 896 || dimen.width === 896)
|
|
83
|
+
|| (dimen.height === 926 || dimen.width === 926)));
|
|
84
|
+
}
|
|
85
|
+
exports.isIphoneX = isIphoneX;
|
|
86
|
+
var _KAM_DEFAULT_TAB_BAR_HEIGHT = isIphoneX() ? 83 : 49;
|
|
87
|
+
var _KAM_KEYBOARD_OPENING_TIME = 250;
|
|
88
|
+
var _KAM_EXTRA_HEIGHT = 75;
|
|
89
|
+
var supportedKeyboardEvents = [
|
|
90
|
+
'keyboardWillShow',
|
|
91
|
+
'keyboardDidShow',
|
|
92
|
+
'keyboardWillHide',
|
|
93
|
+
'keyboardDidHide',
|
|
94
|
+
'keyboardWillChangeFrame',
|
|
95
|
+
'keyboardDidChangeFrame',
|
|
96
|
+
];
|
|
97
|
+
var keyboardEventToCallbackName = function (eventName) { return 'on' + eventName[0].toUpperCase() + eventName.substring(1); };
|
|
98
|
+
var keyboardEventPropTypes = supportedKeyboardEvents.reduce(function (acc, eventName) {
|
|
99
|
+
var _a;
|
|
100
|
+
return (__assign(__assign({}, acc), (_a = {}, _a[keyboardEventToCallbackName(eventName)] = prop_types_1.default.func, _a)));
|
|
101
|
+
}, {});
|
|
102
|
+
var keyboardAwareHOCTypeEvents = supportedKeyboardEvents.reduce(function (acc, eventName) {
|
|
103
|
+
var _a;
|
|
104
|
+
return (__assign(__assign({}, acc), (_a = {}, _a[keyboardEventToCallbackName(eventName)] = Function, _a)));
|
|
105
|
+
}, {});
|
|
106
|
+
function getDisplayName(WrappedComponent) {
|
|
107
|
+
return ((WrappedComponent &&
|
|
108
|
+
(WrappedComponent.displayName || WrappedComponent.name)) ||
|
|
109
|
+
'Component');
|
|
110
|
+
}
|
|
111
|
+
var ScrollIntoViewDefaultOptions = {
|
|
112
|
+
enableOnAndroid: false,
|
|
113
|
+
contentContainerStyle: undefined,
|
|
114
|
+
enableAutomaticScroll: true,
|
|
115
|
+
extraHeight: _KAM_EXTRA_HEIGHT,
|
|
116
|
+
extraScrollHeight: 0,
|
|
117
|
+
enableResetScrollToCoords: true,
|
|
118
|
+
keyboardOpeningTime: _KAM_KEYBOARD_OPENING_TIME,
|
|
119
|
+
viewIsInsideTabBar: false,
|
|
120
|
+
// The ref prop name that will be passed to the wrapped component to obtain a ref
|
|
121
|
+
// If your ScrollView is already wrapped, maybe the wrapper permit to get a ref
|
|
122
|
+
// For example, with glamorous-native ScrollView, you should use "innerRef"
|
|
123
|
+
refPropName: 'ref',
|
|
124
|
+
// Sometimes the ref you get is a ref to a wrapped view (ex: Animated.ScrollView)
|
|
125
|
+
// We need access to the imperative API of a real native ScrollView so we need extraction logic
|
|
126
|
+
extractNativeRef: function (ref) {
|
|
127
|
+
// getNode() permit to support Animated.ScrollView automatically, but is deprecated since RN 0.62
|
|
128
|
+
// see https://github.com/facebook/react-native/issues/19650
|
|
129
|
+
// see https://stackoverflow.com/questions/42051368/scrollto-is-undefined-on-animated-scrollview/48786374
|
|
130
|
+
// see https://github.com/facebook/react-native/commit/66e72bb4e00aafbcb9f450ed5db261d98f99f82a
|
|
131
|
+
var shouldCallGetNode = !react_native_1.Platform.constants || (react_native_1.Platform.constants.reactNativeVersion.major === 0 && react_native_1.Platform.constants.reactNativeVersion.minor < 62);
|
|
132
|
+
if (ref.getNode && shouldCallGetNode) {
|
|
133
|
+
return ref.getNode();
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
return ref;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
var KeyboardAwareScrollable = /** @class */ (function (_super) {
|
|
141
|
+
__extends(KeyboardAwareScrollable, _super);
|
|
142
|
+
function KeyboardAwareScrollable(props) {
|
|
143
|
+
var _this = _super.call(this, props) || this;
|
|
144
|
+
_this.getScrollResponder = function () {
|
|
145
|
+
return (_this._rnkasv_keyboardView &&
|
|
146
|
+
_this._rnkasv_keyboardView.getScrollResponder &&
|
|
147
|
+
_this._rnkasv_keyboardView.getScrollResponder());
|
|
148
|
+
};
|
|
149
|
+
_this.scrollToPosition = function (x, y, animated) {
|
|
150
|
+
if (animated === void 0) { animated = true; }
|
|
151
|
+
var responder = _this.getScrollResponder();
|
|
152
|
+
if (!responder) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (responder.scrollResponderScrollTo) {
|
|
156
|
+
// React Native < 0.65
|
|
157
|
+
responder.scrollResponderScrollTo({ x: x, y: y, animated: animated });
|
|
158
|
+
}
|
|
159
|
+
else if (responder.scrollTo) {
|
|
160
|
+
// React Native >= 0.65
|
|
161
|
+
responder.scrollTo({ x: x, y: y, animated: animated });
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
_this.scrollToEnd = function (animated) {
|
|
165
|
+
if (animated === void 0) { animated = true; }
|
|
166
|
+
var responder = _this.getScrollResponder();
|
|
167
|
+
if (!responder) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (responder.scrollResponderScrollToEnd) {
|
|
171
|
+
// React Native < 0.65
|
|
172
|
+
responder.scrollResponderScrollToEnd({ animated: animated });
|
|
173
|
+
}
|
|
174
|
+
else if (responder.scrollToEnd) {
|
|
175
|
+
// React Native >= 0.65
|
|
176
|
+
responder.scrollToEnd({ animated: animated });
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
_this.scrollForExtraHeightOnAndroid = function (extraHeight) {
|
|
180
|
+
_this.scrollToPosition(0, _this.position.y + extraHeight, true);
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* @param keyboardOpeningTime: takes a different keyboardOpeningTime in consideration.
|
|
184
|
+
* @param extraHeight: takes an extra height in consideration.
|
|
185
|
+
*/
|
|
186
|
+
_this.scrollToFocusedInput = function (reactNode, extraHeight, keyboardOpeningTime) {
|
|
187
|
+
if (extraHeight === undefined) {
|
|
188
|
+
extraHeight = _this.props.extraHeight || 0;
|
|
189
|
+
}
|
|
190
|
+
if (keyboardOpeningTime === undefined) {
|
|
191
|
+
keyboardOpeningTime = _this.props.keyboardOpeningTime || 0;
|
|
192
|
+
}
|
|
193
|
+
setTimeout(function () {
|
|
194
|
+
if (!_this.mountedComponent) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
var responder = _this.getScrollResponder();
|
|
198
|
+
responder &&
|
|
199
|
+
responder.scrollResponderScrollNativeHandleToKeyboard(reactNode, extraHeight, true);
|
|
200
|
+
}, keyboardOpeningTime);
|
|
201
|
+
};
|
|
202
|
+
_this.scrollIntoView = function (element, options) {
|
|
203
|
+
if (options === void 0) { options = {}; }
|
|
204
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
205
|
+
var _a, parentLayout, childLayout, getScrollPosition, _b, x, y, animated;
|
|
206
|
+
return __generator(this, function (_c) {
|
|
207
|
+
switch (_c.label) {
|
|
208
|
+
case 0:
|
|
209
|
+
if (!this._rnkasv_keyboardView || !element) {
|
|
210
|
+
return [2 /*return*/];
|
|
211
|
+
}
|
|
212
|
+
return [4 /*yield*/, Promise.all([
|
|
213
|
+
this._measureElement(this._rnkasv_keyboardView),
|
|
214
|
+
this._measureElement(element),
|
|
215
|
+
])];
|
|
216
|
+
case 1:
|
|
217
|
+
_a = _c.sent(), parentLayout = _a[0], childLayout = _a[1];
|
|
218
|
+
getScrollPosition = options.getScrollPosition || this._defaultGetScrollPosition;
|
|
219
|
+
_b = getScrollPosition(parentLayout, childLayout, this.position), x = _b.x, y = _b.y, animated = _b.animated;
|
|
220
|
+
this.scrollToPosition(x, y, animated);
|
|
221
|
+
return [2 /*return*/];
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
_this._defaultGetScrollPosition = function (parentLayout, childLayout, contentOffset) {
|
|
227
|
+
return {
|
|
228
|
+
x: 0,
|
|
229
|
+
y: Math.max(0, childLayout.y - parentLayout.y + contentOffset.y),
|
|
230
|
+
animated: true,
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
_this._measureElement = function (element) {
|
|
234
|
+
var node = (0, react_native_1.findNodeHandle)(element);
|
|
235
|
+
return new Promise(function (resolve) {
|
|
236
|
+
react_native_1.UIManager.measureInWindow(node, function (x, y, width, height) {
|
|
237
|
+
resolve({ x: x, y: y, width: width, height: height });
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
// Keyboard actions
|
|
242
|
+
_this._updateKeyboardSpace = function (frames) {
|
|
243
|
+
// Automatically scroll to focused TextInput
|
|
244
|
+
if (_this.props.enableAutomaticScroll) {
|
|
245
|
+
var keyboardSpace_1 = frames.endCoordinates.height + _this.props.extraScrollHeight;
|
|
246
|
+
if (_this.props.viewIsInsideTabBar) {
|
|
247
|
+
keyboardSpace_1 -= _KAM_DEFAULT_TAB_BAR_HEIGHT;
|
|
248
|
+
}
|
|
249
|
+
_this.setState({ keyboardSpace: keyboardSpace_1 });
|
|
250
|
+
var currentlyFocusedField_1 = react_native_1.TextInput.State.currentlyFocusedInput ?
|
|
251
|
+
(0, react_native_1.findNodeHandle)(react_native_1.TextInput.State.currentlyFocusedInput()) : react_native_1.TextInput.State.currentlyFocusedField();
|
|
252
|
+
var responder = _this.getScrollResponder();
|
|
253
|
+
if (!currentlyFocusedField_1 || !responder) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
// @ts-ignore
|
|
257
|
+
react_native_1.UIManager.viewIsDescendantOf(currentlyFocusedField_1, responder.getInnerViewNode(), function (isAncestor) {
|
|
258
|
+
if (isAncestor) {
|
|
259
|
+
// Check if the TextInput will be hidden by the keyboard
|
|
260
|
+
react_native_1.UIManager.measureInWindow(currentlyFocusedField_1, function (x, y, width, height) {
|
|
261
|
+
var textInputBottomPosition = y + height;
|
|
262
|
+
var keyboardPosition = frames.endCoordinates.screenY;
|
|
263
|
+
var totalExtraHeight = _this.props.extraScrollHeight + _this.props.extraHeight;
|
|
264
|
+
if (react_native_1.Platform.OS === 'ios') {
|
|
265
|
+
if (textInputBottomPosition >
|
|
266
|
+
keyboardPosition - totalExtraHeight) {
|
|
267
|
+
_this._scrollToFocusedInputWithNodeHandle(currentlyFocusedField_1);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
// On android, the system would scroll the text input just
|
|
272
|
+
// above the keyboard so we just neet to scroll the extra
|
|
273
|
+
// height part
|
|
274
|
+
if (textInputBottomPosition > keyboardPosition) {
|
|
275
|
+
// Since the system already scrolled the whole view up
|
|
276
|
+
// we should reduce that amount
|
|
277
|
+
keyboardSpace_1 =
|
|
278
|
+
keyboardSpace_1 -
|
|
279
|
+
(textInputBottomPosition - keyboardPosition);
|
|
280
|
+
_this.setState({ keyboardSpace: keyboardSpace_1 });
|
|
281
|
+
_this.scrollForExtraHeightOnAndroid(totalExtraHeight);
|
|
282
|
+
}
|
|
283
|
+
else if (textInputBottomPosition >
|
|
284
|
+
keyboardPosition - totalExtraHeight) {
|
|
285
|
+
_this.scrollForExtraHeightOnAndroid(totalExtraHeight -
|
|
286
|
+
(keyboardPosition - textInputBottomPosition));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
if (!_this.props.resetScrollToCoords) {
|
|
294
|
+
if (!_this.defaultResetScrollToCoords) {
|
|
295
|
+
_this.defaultResetScrollToCoords = _this.position;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
_this._resetKeyboardSpace = function () {
|
|
300
|
+
var keyboardSpace = _this.props.viewIsInsideTabBar
|
|
301
|
+
? _KAM_DEFAULT_TAB_BAR_HEIGHT
|
|
302
|
+
: 0;
|
|
303
|
+
_this.setState({ keyboardSpace: keyboardSpace });
|
|
304
|
+
// Reset scroll position after keyboard dismissal
|
|
305
|
+
if (_this.props.enableResetScrollToCoords === false) {
|
|
306
|
+
_this.defaultResetScrollToCoords = null;
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
else if (_this.props.resetScrollToCoords) {
|
|
310
|
+
_this.scrollToPosition(_this.props.resetScrollToCoords.x, _this.props.resetScrollToCoords.y, true);
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
if (_this.defaultResetScrollToCoords) {
|
|
314
|
+
_this.scrollToPosition(_this.defaultResetScrollToCoords.x, _this.defaultResetScrollToCoords.y, true);
|
|
315
|
+
_this.defaultResetScrollToCoords = null;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
_this.scrollToPosition(0, 0, true);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
_this._scrollToFocusedInputWithNodeHandle = function (nodeID, extraHeight, keyboardOpeningTime) {
|
|
323
|
+
if (extraHeight === undefined) {
|
|
324
|
+
extraHeight = _this.props.extraHeight;
|
|
325
|
+
}
|
|
326
|
+
var reactNode = (0, react_native_1.findNodeHandle)(nodeID);
|
|
327
|
+
_this.scrollToFocusedInput(reactNode, extraHeight + _this.props.extraScrollHeight, keyboardOpeningTime !== undefined
|
|
328
|
+
? keyboardOpeningTime
|
|
329
|
+
: _this.props.keyboardOpeningTime || 0);
|
|
330
|
+
};
|
|
331
|
+
_this._handleOnScroll = function (e) {
|
|
332
|
+
_this.position = e.nativeEvent.contentOffset;
|
|
333
|
+
};
|
|
334
|
+
_this._handleRef = function (ref) {
|
|
335
|
+
_this._rnkasv_keyboardView = ref ? _this.props.hocOptions.extractNativeRef(ref) : ref;
|
|
336
|
+
if (_this.props.innerRef) {
|
|
337
|
+
_this.props.innerRef(_this._rnkasv_keyboardView);
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
_this.update = function () {
|
|
341
|
+
var currentlyFocusedField = react_native_1.TextInput.State.currentlyFocusedInput ?
|
|
342
|
+
(0, react_native_1.findNodeHandle)(react_native_1.TextInput.State.currentlyFocusedInput()) : react_native_1.TextInput.State.currentlyFocusedField();
|
|
343
|
+
var responder = _this.getScrollResponder();
|
|
344
|
+
if (!currentlyFocusedField || !responder) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
_this._scrollToFocusedInputWithNodeHandle(currentlyFocusedField);
|
|
348
|
+
};
|
|
349
|
+
_this.keyboardWillShowEvent = undefined;
|
|
350
|
+
_this.keyboardWillHideEvent = undefined;
|
|
351
|
+
_this.callbacks = {};
|
|
352
|
+
_this.position = { x: 0, y: 0 };
|
|
353
|
+
_this.defaultResetScrollToCoords = null;
|
|
354
|
+
var keyboardSpace = props.viewIsInsideTabBar
|
|
355
|
+
? _KAM_DEFAULT_TAB_BAR_HEIGHT
|
|
356
|
+
: 0;
|
|
357
|
+
_this.state = { keyboardSpace: keyboardSpace };
|
|
358
|
+
return _this;
|
|
359
|
+
}
|
|
360
|
+
KeyboardAwareScrollable.prototype.componentDidMount = function () {
|
|
361
|
+
var _this = this;
|
|
362
|
+
this.mountedComponent = true;
|
|
363
|
+
// Keyboard events
|
|
364
|
+
if (react_native_1.Platform.OS === 'ios') {
|
|
365
|
+
this.keyboardWillShowEvent = react_native_1.Keyboard.addListener('keyboardWillShow', this._updateKeyboardSpace);
|
|
366
|
+
this.keyboardWillHideEvent = react_native_1.Keyboard.addListener('keyboardWillHide', this._resetKeyboardSpace);
|
|
367
|
+
}
|
|
368
|
+
else if (react_native_1.Platform.OS === 'android' && this.props.enableOnAndroid) {
|
|
369
|
+
this.keyboardWillShowEvent = react_native_1.Keyboard.addListener('keyboardDidShow', this._updateKeyboardSpace);
|
|
370
|
+
this.keyboardWillHideEvent = react_native_1.Keyboard.addListener('keyboardDidHide', this._resetKeyboardSpace);
|
|
371
|
+
}
|
|
372
|
+
supportedKeyboardEvents.forEach(function (eventName) {
|
|
373
|
+
var callbackName = keyboardEventToCallbackName(eventName);
|
|
374
|
+
if (_this.props[callbackName]) {
|
|
375
|
+
_this.callbacks[eventName] = react_native_1.Keyboard.addListener(eventName, _this.props[callbackName]);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
};
|
|
379
|
+
KeyboardAwareScrollable.prototype.componentDidUpdate = function (prevProps) {
|
|
380
|
+
if (this.props.viewIsInsideTabBar !== prevProps.viewIsInsideTabBar) {
|
|
381
|
+
var keyboardSpace = this.props.viewIsInsideTabBar
|
|
382
|
+
? _KAM_DEFAULT_TAB_BAR_HEIGHT
|
|
383
|
+
: 0;
|
|
384
|
+
if (this.state.keyboardSpace !== keyboardSpace) {
|
|
385
|
+
this.setState({ keyboardSpace: keyboardSpace });
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
KeyboardAwareScrollable.prototype.componentWillUnmount = function () {
|
|
390
|
+
this.mountedComponent = false;
|
|
391
|
+
this.keyboardWillShowEvent && this.keyboardWillShowEvent.remove();
|
|
392
|
+
this.keyboardWillHideEvent && this.keyboardWillHideEvent.remove();
|
|
393
|
+
Object.values(this.callbacks).forEach(function (callback) { return callback.remove(); });
|
|
394
|
+
};
|
|
395
|
+
KeyboardAwareScrollable.prototype.render = function () {
|
|
396
|
+
var _a;
|
|
397
|
+
var _b = this.props, enableOnAndroid = _b.enableOnAndroid, contentContainerStyle = _b.contentContainerStyle, onScroll = _b.onScroll, Scrollable = _b.Scrollable;
|
|
398
|
+
var newContentContainerStyle;
|
|
399
|
+
if (react_native_1.Platform.OS === 'android' && enableOnAndroid) {
|
|
400
|
+
newContentContainerStyle = [].concat(contentContainerStyle).concat({
|
|
401
|
+
paddingBottom: ((contentContainerStyle || {}).paddingBottom || 0) +
|
|
402
|
+
this.state.keyboardSpace,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
var refProps = (_a = {}, _a[this.props.hocOptions.refPropName] = this._handleRef, _a);
|
|
406
|
+
return (<Scrollable {...refProps} keyboardDismissMode='interactive' contentInset={{ bottom: this.state.keyboardSpace }} automaticallyAdjustContentInsets={false} showsVerticalScrollIndicator={true} scrollEventThrottle={1} {...this.props} contentContainerStyle={newContentContainerStyle || contentContainerStyle} keyboardSpace={this.state.keyboardSpace} getScrollResponder={this.getScrollResponder} scrollToPosition={this.scrollToPosition} scrollToEnd={this.scrollToEnd} scrollForExtraHeightOnAndroid={this.scrollForExtraHeightOnAndroid} scrollToFocusedInput={this.scrollToFocusedInput} scrollIntoView={this.scrollIntoView} resetKeyboardSpace={this._resetKeyboardSpace} handleOnScroll={this._handleOnScroll} update={this.update}
|
|
407
|
+
// @ts-ignore
|
|
408
|
+
onScroll={react_native_1.Animated.forkEvent(onScroll, this._handleOnScroll)}/>);
|
|
409
|
+
};
|
|
410
|
+
KeyboardAwareScrollable.displayName = "KeyboardAware";
|
|
411
|
+
KeyboardAwareScrollable.propTypes = __assign({ viewIsInsideTabBar: prop_types_1.default.bool, resetScrollToCoords: prop_types_1.default.shape({
|
|
412
|
+
x: prop_types_1.default.number.isRequired,
|
|
413
|
+
y: prop_types_1.default.number.isRequired,
|
|
414
|
+
}), enableResetScrollToCoords: prop_types_1.default.bool, enableAutomaticScroll: prop_types_1.default.bool, extraHeight: prop_types_1.default.number, extraScrollHeight: prop_types_1.default.number, keyboardOpeningTime: prop_types_1.default.number, onScroll: prop_types_1.default.oneOfType([
|
|
415
|
+
prop_types_1.default.func,
|
|
416
|
+
prop_types_1.default.object, // Animated.event listener
|
|
417
|
+
]), update: prop_types_1.default.func, contentContainerStyle: prop_types_1.default.any, enableOnAndroid: prop_types_1.default.bool, innerRef: prop_types_1.default.func }, keyboardEventPropTypes);
|
|
418
|
+
// HOC options are used to init default props, so that these options can be overriden with component props
|
|
419
|
+
KeyboardAwareScrollable.defaultProps = {
|
|
420
|
+
enableAutomaticScroll: ScrollIntoViewDefaultOptions.enableAutomaticScroll,
|
|
421
|
+
extraHeight: ScrollIntoViewDefaultOptions.extraHeight,
|
|
422
|
+
extraScrollHeight: ScrollIntoViewDefaultOptions.extraScrollHeight,
|
|
423
|
+
enableResetScrollToCoords: ScrollIntoViewDefaultOptions.enableResetScrollToCoords,
|
|
424
|
+
keyboardOpeningTime: ScrollIntoViewDefaultOptions.keyboardOpeningTime,
|
|
425
|
+
viewIsInsideTabBar: ScrollIntoViewDefaultOptions.viewIsInsideTabBar,
|
|
426
|
+
enableOnAndroid: ScrollIntoViewDefaultOptions.enableOnAndroid,
|
|
427
|
+
};
|
|
428
|
+
return KeyboardAwareScrollable;
|
|
429
|
+
}(react_1.default.Component));
|
|
430
|
+
function KeyboardAwareHOC(ScrollableComponent, userOptions) {
|
|
431
|
+
if (userOptions === void 0) { userOptions = ScrollIntoViewDefaultOptions; }
|
|
432
|
+
var hocOptions = __assign(__assign({}, ScrollIntoViewDefaultOptions), userOptions);
|
|
433
|
+
return react_1.default.forwardRef(function (props, ref) { return <KeyboardAwareScrollable hocOptions={hocOptions}
|
|
434
|
+
// @ts-ignore
|
|
435
|
+
ref={ref} Scrollable={ScrollableComponent} {...props}/>; });
|
|
436
|
+
}
|
|
437
|
+
// Allow to pass options, without breaking change, and curried for composition
|
|
438
|
+
// listenToKeyboardEvents(ScrollView);
|
|
439
|
+
// listenToKeyboardEvents(options)(Comp);
|
|
440
|
+
var listenToKeyboardEvents = function (configOrComp) {
|
|
441
|
+
//@ts-ignore
|
|
442
|
+
if (typeof configOrComp === 'object' && !configOrComp.displayName) {
|
|
443
|
+
return (function (Comp) { return KeyboardAwareHOC(Comp, configOrComp); });
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
//@ts-ignore
|
|
447
|
+
return KeyboardAwareHOC(configOrComp);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
exports.default = listenToKeyboardEvents;
|
|
451
451
|
//# sourceMappingURL=KeyboardAwareHOC.js.map
|