@codeleap/mobile 4.2.8 → 4.2.10
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/dist/Registry.js +28 -53
- package/dist/Registry.js.map +1 -1
- package/dist/components/ActionIcon/index.js +27 -67
- package/dist/components/ActionIcon/index.js.map +1 -1
- package/dist/components/ActionIcon/styles.js +1 -2
- package/dist/components/ActionIcon/types.js +1 -2
- package/dist/components/ActivityIndicator/index.js +22 -62
- package/dist/components/ActivityIndicator/index.js.map +1 -1
- package/dist/components/ActivityIndicator/styles.js +1 -2
- package/dist/components/ActivityIndicator/types.js +1 -2
- package/dist/components/Autocomplete/index.js +73 -121
- package/dist/components/Autocomplete/index.js.map +1 -1
- package/dist/components/Autocomplete/styles.js +1 -2
- package/dist/components/Autocomplete/types.js +1 -2
- package/dist/components/Avatar/index.js +49 -90
- package/dist/components/Avatar/index.js.map +1 -1
- package/dist/components/Avatar/styles.js +1 -2
- package/dist/components/Avatar/types.js +1 -2
- package/dist/components/AvatarGroup/index.js +30 -75
- package/dist/components/AvatarGroup/index.js.map +1 -1
- package/dist/components/AvatarGroup/styles.js +1 -2
- package/dist/components/AvatarGroup/types.js +1 -2
- package/dist/components/Backdrop/index.js +26 -66
- package/dist/components/Backdrop/index.js.map +1 -1
- package/dist/components/Backdrop/styles.js +1 -2
- package/dist/components/Backdrop/types.js +1 -2
- package/dist/components/Badge/index.js +44 -85
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Badge/styles.js +1 -2
- package/dist/components/Badge/types.js +1 -2
- package/dist/components/Button/index.js +49 -98
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/styles.js +1 -2
- package/dist/components/Button/types.js +1 -2
- package/dist/components/Calendar/index.js +27 -68
- package/dist/components/Calendar/index.js.map +1 -1
- package/dist/components/Calendar/types.d.ts +1 -2
- package/dist/components/Calendar/types.js +1 -2
- package/dist/components/Checkbox/index.js +52 -85
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Checkbox/styles.js +1 -2
- package/dist/components/Checkbox/types.js +1 -2
- package/dist/components/DatePickerModal/index.js +61 -113
- package/dist/components/DatePickerModal/index.js.map +1 -1
- package/dist/components/DatePickerModal/styles.js +1 -2
- package/dist/components/DatePickerModal/types.js +1 -2
- package/dist/components/EmptyPlaceholder/index.js +40 -69
- package/dist/components/EmptyPlaceholder/index.js.map +1 -1
- package/dist/components/EmptyPlaceholder/styles.js +1 -2
- package/dist/components/EmptyPlaceholder/types.js +1 -2
- package/dist/components/FileInput/index.js +112 -178
- package/dist/components/FileInput/index.js.map +1 -1
- package/dist/components/FileInput/types.js +1 -2
- package/dist/components/Grid/index.js +47 -97
- package/dist/components/Grid/index.js.map +1 -1
- package/dist/components/Grid/styles.js +1 -2
- package/dist/components/Grid/types.js +1 -2
- package/dist/components/Icon/index.js +34 -75
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Icon/styles.js +1 -2
- package/dist/components/Icon/types.js +1 -2
- package/dist/components/Image/index.js +53 -96
- package/dist/components/Image/index.js.map +1 -1
- package/dist/components/Image/styles.js +1 -2
- package/dist/components/Image/types.js +1 -2
- package/dist/components/ImageView/Spotlight.js +75 -131
- package/dist/components/ImageView/Spotlight.js.map +1 -1
- package/dist/components/ImageView/component.js +8 -15
- package/dist/components/ImageView/component.js.map +1 -1
- package/dist/components/ImageView/index.js +2 -18
- package/dist/components/ImageView/index.js.map +1 -1
- package/dist/components/InputBase/index.js +35 -75
- package/dist/components/InputBase/index.js.map +1 -1
- package/dist/components/InputBase/styles.d.ts +3 -3
- package/dist/components/InputBase/styles.js +49 -50
- package/dist/components/InputBase/styles.js.map +1 -1
- package/dist/components/InputBase/types.d.ts +1 -0
- package/dist/components/InputBase/types.js +1 -2
- package/dist/components/InputBase/utils.js +4 -19
- package/dist/components/InputBase/utils.js.map +1 -1
- package/dist/components/List/index.js +46 -86
- package/dist/components/List/index.js.map +1 -1
- package/dist/components/List/styles.js +1 -2
- package/dist/components/List/types.js +1 -2
- package/dist/components/LoadingOverlay/index.js +28 -66
- package/dist/components/LoadingOverlay/index.js.map +1 -1
- package/dist/components/LoadingOverlay/styles.js +1 -2
- package/dist/components/LoadingOverlay/types.js +1 -2
- package/dist/components/Modal/index.js +77 -113
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/styles.js +1 -2
- package/dist/components/Modal/types.js +1 -2
- package/dist/components/Navigation/Navigation.js +23 -66
- package/dist/components/Navigation/Navigation.js.map +1 -1
- package/dist/components/Navigation/constants.js +7 -10
- package/dist/components/Navigation/constants.js.map +1 -1
- package/dist/components/Navigation/index.js +3 -19
- package/dist/components/Navigation/index.js.map +1 -1
- package/dist/components/Navigation/types.js +1 -2
- package/dist/components/Navigation/utils.js +24 -59
- package/dist/components/Navigation/utils.js.map +1 -1
- package/dist/components/NumberIncrement/index.js +132 -165
- package/dist/components/NumberIncrement/index.js.map +1 -1
- package/dist/components/NumberIncrement/styles.js +1 -2
- package/dist/components/NumberIncrement/types.d.ts +2 -2
- package/dist/components/NumberIncrement/types.js +1 -2
- package/dist/components/NumberIncrement/utils.js +8 -12
- package/dist/components/NumberIncrement/utils.js.map +1 -1
- package/dist/components/Pager/PagerDots.js +17 -54
- package/dist/components/Pager/PagerDots.js.map +1 -1
- package/dist/components/Pager/index.js +43 -97
- package/dist/components/Pager/index.js.map +1 -1
- package/dist/components/Pager/styles.js +1 -2
- package/dist/components/Pager/types.js +1 -2
- package/dist/components/PaginationIndicator/index.js +23 -38
- package/dist/components/PaginationIndicator/index.js.map +1 -1
- package/dist/components/PaginationIndicator/styles.js +1 -2
- package/dist/components/PaginationIndicator/types.js +1 -2
- package/dist/components/PlacesAutocomplete/index.js +55 -106
- package/dist/components/PlacesAutocomplete/index.js.map +1 -1
- package/dist/components/PlacesAutocomplete/styles.js +1 -2
- package/dist/components/PlacesAutocomplete/types.js +1 -2
- package/dist/components/RadioInput/index.js +46 -84
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/RadioInput/styles.js +1 -2
- package/dist/components/RadioInput/types.js +1 -2
- package/dist/components/RefreshControl/index.js +22 -63
- package/dist/components/RefreshControl/index.js.map +1 -1
- package/dist/components/RefreshControl/styles.js +1 -2
- package/dist/components/RefreshControl/types.js +1 -2
- package/dist/components/Scroll/index.js +33 -81
- package/dist/components/Scroll/index.js.map +1 -1
- package/dist/components/Scroll/styles.js +1 -2
- package/dist/components/Scroll/types.js +1 -2
- package/dist/components/SearchInput/index.js +22 -69
- package/dist/components/SearchInput/index.js.map +1 -1
- package/dist/components/SectionFilters/context.d.ts +6 -0
- package/dist/components/SectionFilters/context.js +4 -8
- package/dist/components/SectionFilters/context.js.map +1 -1
- package/dist/components/SectionFilters/index.js +33 -76
- package/dist/components/SectionFilters/index.js.map +1 -1
- package/dist/components/SectionFilters/types.js +1 -2
- package/dist/components/SectionFilters/useSectionFilters.d.ts +3 -0
- package/dist/components/SectionFilters/useSectionFilters.js +71 -73
- package/dist/components/SectionFilters/useSectionFilters.js.map +1 -1
- package/dist/components/Sections/index.d.ts +8 -8
- package/dist/components/Sections/index.js +61 -106
- package/dist/components/Sections/index.js.map +1 -1
- package/dist/components/Sections/styles.d.ts +1 -1
- package/dist/components/Sections/styles.js +1 -2
- package/dist/components/Sections/types.js +1 -2
- package/dist/components/SegmentedControl/Option.js +13 -31
- package/dist/components/SegmentedControl/Option.js.map +1 -1
- package/dist/components/SegmentedControl/index.js +71 -114
- package/dist/components/SegmentedControl/index.js.map +1 -1
- package/dist/components/SegmentedControl/styles.js +1 -2
- package/dist/components/SegmentedControl/types.js +1 -2
- package/dist/components/Select/index.js +94 -157
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/styles.js +1 -2
- package/dist/components/Select/types.js +1 -2
- package/dist/components/Slider/index.js +89 -129
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Slider/styles.d.ts +0 -6
- package/dist/components/Slider/styles.js +1 -2
- package/dist/components/Slider/types.js +1 -2
- package/dist/components/SortablePhotos/index.js +58 -91
- package/dist/components/SortablePhotos/index.js.map +1 -1
- package/dist/components/SortablePhotos/styles.js +1 -2
- package/dist/components/SortablePhotos/types.js +1 -2
- package/dist/components/SortablePhotos/useSortablePhotos.js +93 -157
- package/dist/components/SortablePhotos/useSortablePhotos.js.map +1 -1
- package/dist/components/Switch/index.js +51 -84
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/styles.js +1 -2
- package/dist/components/Switch/types.js +1 -2
- package/dist/components/Text/index.js +40 -88
- package/dist/components/Text/index.js.map +1 -1
- package/dist/components/Text/styles.js +1 -2
- package/dist/components/Text/types.js +1 -2
- package/dist/components/TextInput/index.js +83 -131
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/TextInput/styles.js +1 -2
- package/dist/components/TextInput/types.js +1 -2
- package/dist/components/Touchable/index.js +69 -122
- package/dist/components/Touchable/index.js.map +1 -1
- package/dist/components/Touchable/styles.js +1 -2
- package/dist/components/Touchable/types.js +1 -2
- package/dist/components/View/index.js +19 -51
- package/dist/components/View/index.js.map +1 -1
- package/dist/components/View/styles.js +1 -2
- package/dist/components/View/types.js +1 -2
- package/dist/components/components.js +43 -59
- package/dist/components/components.js.map +1 -1
- package/dist/hooks/index.js +7 -11
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.js +8 -43
- package/dist/index.js.map +1 -1
- package/dist/modules/PressableRipple/index.js +2 -8
- package/dist/modules/PressableRipple/index.js.map +1 -1
- package/dist/modules/PressableRipple/ripple.js +125 -163
- package/dist/modules/PressableRipple/ripple.js.map +1 -1
- package/dist/modules/PressableRipple/styles.js +9 -20
- package/dist/modules/PressableRipple/styles.js.map +1 -1
- package/dist/modules/PressableRipple/type.js +1 -2
- package/dist/modules/reactNavigation.js +10 -21
- package/dist/modules/reactNavigation.js.map +1 -1
- package/dist/modules/textInputMask.js +3 -20
- package/dist/modules/textInputMask.js.map +1 -1
- package/dist/modules/types/textInputMask.js +1 -2
- package/dist/types/index.js +1 -17
- package/dist/types/index.js.map +1 -1
- package/dist/types/utility.js +1 -2
- package/dist/utils/KeyboardAware/context.js +5 -14
- package/dist/utils/KeyboardAware/context.js.map +1 -1
- package/dist/utils/KeyboardAware/index.js +3 -19
- package/dist/utils/KeyboardAware/index.js.map +1 -1
- package/dist/utils/KeyboardAware/keyboardHooks.js +36 -41
- package/dist/utils/KeyboardAware/keyboardHooks.js.map +1 -1
- package/dist/utils/KeyboardAware/types.js +1 -2
- package/dist/utils/KeyboardAware/types.js.map +1 -1
- package/dist/utils/ModalManager/components.js +24 -54
- package/dist/utils/ModalManager/components.js.map +1 -1
- package/dist/utils/ModalManager/context.js +94 -89
- package/dist/utils/ModalManager/context.js.map +1 -1
- package/dist/utils/ModalManager/index.js +7 -10
- package/dist/utils/ModalManager/index.js.map +1 -1
- package/dist/utils/NotificationManager/index.js +115 -245
- package/dist/utils/NotificationManager/index.js.map +1 -1
- package/dist/utils/NotificationManager/types.js +1 -2
- package/dist/utils/OSAlert.js +32 -48
- package/dist/utils/OSAlert.js.map +1 -1
- package/dist/utils/PermissionManager/context.js +138 -255
- package/dist/utils/PermissionManager/context.js.map +1 -1
- package/dist/utils/PermissionManager/index.js +2 -8
- package/dist/utils/PermissionManager/index.js.map +1 -1
- package/dist/utils/PermissionManager/types.js +1 -2
- package/dist/utils/StorageManager.js +39 -46
- package/dist/utils/StorageManager.js.map +1 -1
- package/dist/utils/Subscription.js +30 -54
- package/dist/utils/Subscription.js.map +1 -1
- package/dist/utils/deprecated/notifications.js +143 -250
- package/dist/utils/deprecated/notifications.js.map +1 -1
- package/dist/utils/hooks.js +101 -120
- package/dist/utils/hooks.js.map +1 -1
- package/dist/utils/index.js +14 -43
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/input.js +15 -19
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/locale.js +5 -9
- package/dist/utils/locale.js.map +1 -1
- package/dist/utils/misc.js +25 -40
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/theme.js +24 -33
- package/dist/utils/theme.js.map +1 -1
- package/dist/utils/useQueryListRefresh.js +16 -26
- package/dist/utils/useQueryListRefresh.js.map +1 -1
- package/package.json +6 -6
- package/package.json.bak +2 -2
- package/src/components/Calendar/types.ts +3 -3
- package/src/components/InputBase/styles.ts +35 -23
- package/src/components/InputBase/types.ts +1 -0
- package/src/components/NumberIncrement/index.tsx +8 -2
- package/src/components/NumberIncrement/types.ts +3 -3
- package/src/components/RadioInput/index.tsx +4 -0
- package/src/components/SectionFilters/useSectionFilters.tsx +31 -1
- package/src/components/Sections/index.tsx +3 -2
- package/src/components/Sections/styles.ts +2 -2
- package/src/components/Slider/index.tsx +9 -1
- package/src/components/Slider/styles.ts +0 -6
- package/src/components/TextInput/index.tsx +5 -0
package/dist/types/utility.js
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useKeyboard = exports.KeyboardProvider = void 0;
|
|
7
|
-
var react_1 = __importDefault(require("react"));
|
|
8
|
-
var react_native_avoid_softinput_1 = require("react-native-avoid-softinput");
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSoftInputState } from 'react-native-avoid-softinput';
|
|
9
3
|
/**
|
|
10
4
|
*
|
|
11
5
|
* @deprecated useKeyboard does not need to be wrapped in a provider
|
|
12
6
|
*/
|
|
13
|
-
|
|
14
|
-
var children = _a.children;
|
|
7
|
+
export const KeyboardProvider = ({ children }) => {
|
|
15
8
|
return <>
|
|
16
9
|
{children}
|
|
17
10
|
</>;
|
|
18
11
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var state = (0, react_native_avoid_softinput_1.useSoftInputState)();
|
|
12
|
+
export const useKeyboard = () => {
|
|
13
|
+
const state = useSoftInputState();
|
|
22
14
|
return {
|
|
23
15
|
isVisible: state.isSoftInputShown,
|
|
24
16
|
height: state.softInputHeight,
|
|
25
17
|
};
|
|
26
18
|
};
|
|
27
|
-
exports.useKeyboard = useKeyboard;
|
|
28
19
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/utils/KeyboardAware/context.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/utils/KeyboardAware/context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAOhE;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC/C,OAAO,EACL;IAAA,CAAC,QAAQ,CACX;EAAA,GAAG,CAAA;AACL,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,GAAiB,EAAE;IAC5C,MAAM,KAAK,GAAG,iBAAiB,EAAE,CAAA;IACjC,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,gBAAgB;QACjC,MAAM,EAAE,KAAK,CAAC,eAAe;KAC9B,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./keyboardHooks"), exports);
|
|
18
|
-
__exportStar(require("./context"), exports);
|
|
19
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
export * from './keyboardHooks';
|
|
2
|
+
export * from './context';
|
|
3
|
+
export * from './types';
|
|
20
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/KeyboardAware/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/KeyboardAware/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
|
|
@@ -1,72 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var react_native_1 = require("react-native");
|
|
17
|
-
var context_1 = require("./context");
|
|
18
|
-
var useKeyboardAwareView = function (params) {
|
|
19
|
-
var keyboard = (0, context_1.useKeyboard)();
|
|
20
|
-
var options = params || {};
|
|
21
|
-
var _options = __assign(__assign({ adapt: 'maxHeight', baseStyleProp: 'style', enabled: true, enableOnAndroid: false, animated: false }, options), { transition: {
|
|
22
|
-
easing: react_native_1.Easing.linear,
|
|
1
|
+
import { TypeGuards } from '@codeleap/common';
|
|
2
|
+
import { Platform, StyleSheet, Dimensions, Easing } from 'react-native';
|
|
3
|
+
import { useKeyboard } from './context';
|
|
4
|
+
export const useKeyboardAwareView = (params) => {
|
|
5
|
+
const keyboard = useKeyboard();
|
|
6
|
+
const options = params || {};
|
|
7
|
+
const _options = {
|
|
8
|
+
adapt: 'maxHeight',
|
|
9
|
+
baseStyleProp: 'style',
|
|
10
|
+
enabled: true,
|
|
11
|
+
enableOnAndroid: false,
|
|
12
|
+
animated: false,
|
|
13
|
+
...options,
|
|
14
|
+
transition: {
|
|
15
|
+
easing: Easing.linear,
|
|
23
16
|
duration: 200,
|
|
24
17
|
type: 'timing',
|
|
25
|
-
}
|
|
26
|
-
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
if (!_options.enabled || (Platform.OS === 'android' && !_options.enableOnAndroid)) {
|
|
27
21
|
return {
|
|
28
|
-
keyboard
|
|
29
|
-
style: params
|
|
22
|
+
keyboard,
|
|
23
|
+
style: params?.styles,
|
|
30
24
|
};
|
|
31
25
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
26
|
+
const baseStyle = StyleSheet.flatten(params.styles || {});
|
|
27
|
+
let baseValue = baseStyle[_options.adapt];
|
|
28
|
+
if (TypeGuards.isNil(baseValue)) {
|
|
35
29
|
baseValue = 0;
|
|
36
30
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!
|
|
31
|
+
let valid = true;
|
|
32
|
+
const warnOnNotNumber = () => {
|
|
33
|
+
if (!TypeGuards.isNil(baseValue) && !TypeGuards.isNumber(baseValue)) {
|
|
40
34
|
valid = false;
|
|
41
|
-
|
|
35
|
+
const debugStr = params?.debugName ? 'at ' + params?.debugName + ' ' : '';
|
|
42
36
|
console.log(debugStr);
|
|
43
37
|
}
|
|
44
38
|
};
|
|
45
|
-
|
|
39
|
+
let newStyleProp = {
|
|
40
|
+
...baseStyle,
|
|
41
|
+
};
|
|
46
42
|
switch (_options.adapt) {
|
|
47
43
|
case 'height':
|
|
48
44
|
warnOnNotNumber();
|
|
49
|
-
|
|
45
|
+
const baseHeight = baseValue || 0;
|
|
50
46
|
newStyleProp.height = baseHeight - keyboard.height;
|
|
51
47
|
break;
|
|
52
48
|
case 'maxHeight':
|
|
53
49
|
warnOnNotNumber();
|
|
54
|
-
|
|
50
|
+
const baseMaxHeight = baseValue || Dimensions.get('window').height;
|
|
55
51
|
newStyleProp.maxHeight = baseMaxHeight - keyboard.height;
|
|
56
52
|
break;
|
|
57
53
|
case 'paddingBottom':
|
|
58
54
|
warnOnNotNumber();
|
|
59
|
-
|
|
55
|
+
const basePaddingBottom = baseValue || 0;
|
|
60
56
|
newStyleProp.paddingBottom = basePaddingBottom + keyboard.height;
|
|
61
57
|
break;
|
|
62
58
|
case 'marginBottom':
|
|
63
59
|
warnOnNotNumber();
|
|
64
|
-
|
|
60
|
+
const baseMarginBottom = baseValue || 0;
|
|
65
61
|
newStyleProp.marginBottom = baseMarginBottom + keyboard.height;
|
|
66
62
|
break;
|
|
67
63
|
case 'bottom':
|
|
68
64
|
warnOnNotNumber();
|
|
69
|
-
|
|
65
|
+
const baseBottom = baseValue || 0;
|
|
70
66
|
newStyleProp.bottom = baseBottom + keyboard.height;
|
|
71
67
|
break;
|
|
72
68
|
}
|
|
@@ -74,9 +70,8 @@ var useKeyboardAwareView = function (params) {
|
|
|
74
70
|
newStyleProp = params.styles;
|
|
75
71
|
}
|
|
76
72
|
return {
|
|
77
|
-
keyboard
|
|
73
|
+
keyboard,
|
|
78
74
|
style: newStyleProp,
|
|
79
75
|
};
|
|
80
76
|
};
|
|
81
|
-
exports.useKeyboardAwareView = useKeyboardAwareView;
|
|
82
77
|
//# sourceMappingURL=keyboardHooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardHooks.js","sourceRoot":"","sources":["../../../src/utils/KeyboardAware/keyboardHooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keyboardHooks.js","sourceRoot":"","sources":["../../../src/utils/KeyboardAware/keyboardHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAc,QAAQ,EAAE,UAAU,EAAE,UAAU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ED,OAAO;QACL,QAAQ;QACR,KAAK,EAAE,YAAY;KAEpB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Type definitions for react-native-keyboard-aware-scroll-view
|
|
3
2
|
// Project: https://github.com/APSL/react-native-keyboard-aware-scroll-view
|
|
4
3
|
// Definitions by: Kyle Roach <https://github.com/iRoachie>
|
|
5
4
|
// TypeScript Version: 2.3.2
|
|
6
|
-
|
|
5
|
+
export {};
|
|
7
6
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/KeyboardAware/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/KeyboardAware/types.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,2EAA2E;AAC3E,2DAA2D;AAC3D,4BAA4B"}
|
|
@@ -1,42 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.Modal = void 0;
|
|
29
|
-
var react_1 = __importDefault(require("react"));
|
|
30
|
-
var common_1 = require("@codeleap/common");
|
|
31
|
-
var context_1 = require("./context");
|
|
32
|
-
var portal_1 = require("@gorhom/portal");
|
|
33
|
-
var Modal_1 = require("../../components/Modal");
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { usePrevious, onMount, onUpdate } from '@codeleap/common';
|
|
3
|
+
import { useModalContext } from './context';
|
|
4
|
+
import { Portal } from '@gorhom/portal';
|
|
5
|
+
import { Modal as _Modal } from '../../components/Modal';
|
|
34
6
|
function useManagedModal(props) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(0, common_1.onMount)(function () {
|
|
7
|
+
const { initialVisible = false, parent, id, } = props;
|
|
8
|
+
const modalId = id;
|
|
9
|
+
const modals = useModalContext();
|
|
10
|
+
onMount(() => {
|
|
40
11
|
if (!modalId)
|
|
41
12
|
return;
|
|
42
13
|
modals.setModal(modalId, {
|
|
@@ -45,39 +16,38 @@ function useManagedModal(props) {
|
|
|
45
16
|
visible: initialVisible,
|
|
46
17
|
});
|
|
47
18
|
});
|
|
48
|
-
|
|
49
|
-
|
|
19
|
+
const prevParent = usePrevious(parent);
|
|
20
|
+
onUpdate(() => {
|
|
50
21
|
if (!modalId)
|
|
51
22
|
return;
|
|
52
23
|
if (!!parent || !!prevParent) {
|
|
53
24
|
modals.attach(modalId, parent);
|
|
54
25
|
}
|
|
55
26
|
}, [parent]);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
27
|
+
const visible = modalId ? modals.isVisible(modalId) : props.visible;
|
|
28
|
+
const ctxProps = modals?.state?.[modalId]?.props;
|
|
29
|
+
const componentProps = {
|
|
30
|
+
...props, ...ctxProps, visible: visible, toggle: () => {
|
|
60
31
|
if (modalId) {
|
|
61
32
|
modals.toggleModal(modalId);
|
|
62
33
|
}
|
|
63
34
|
else {
|
|
64
|
-
|
|
35
|
+
props?.toggle?.();
|
|
65
36
|
}
|
|
66
|
-
}
|
|
37
|
+
},
|
|
38
|
+
};
|
|
67
39
|
return componentProps;
|
|
68
40
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var content = (<Modal_1.Modal {...componentProps}>
|
|
41
|
+
export const Modal = ({ children, absolute = true, ...props }) => {
|
|
42
|
+
const componentProps = useManagedModal(props);
|
|
43
|
+
const content = (<_Modal {...componentProps}>
|
|
73
44
|
{children}
|
|
74
|
-
</
|
|
45
|
+
</_Modal>);
|
|
75
46
|
if (absolute) {
|
|
76
|
-
return <
|
|
47
|
+
return <Portal>
|
|
77
48
|
{content}
|
|
78
|
-
</
|
|
49
|
+
</Portal>;
|
|
79
50
|
}
|
|
80
51
|
return content;
|
|
81
52
|
};
|
|
82
|
-
exports.Modal = Modal;
|
|
83
53
|
//# sourceMappingURL=components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../src/utils/ModalManager/components.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../src/utils/ModalManager/components.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAW,MAAM,kBAAkB,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAUxD,SAAS,eAAe,CAAC,KAAyB;I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A+B,CAAC,EAChD,QAAQ,EACR,QAAQ,GAAG,IAAI,EACf,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,cAAc,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IAE7C,MAAM,OAAO,GAAG,CACd,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,CACzB;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,MAAM,CAAC,CACV,CAAA;IAED,IAAI,QAAQ,EAAE;QACZ,OAAO,CAAC,MAAM,CACZ;MAAA,CAAC,OAAO,CACV;IAAA,EAAE,MAAM,CAAC,CAAA;KACV;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -1,83 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.useModalSequence = exports.useModalContext = exports.Provider = void 0;
|
|
18
|
-
var react_1 = __importDefault(require("react"));
|
|
19
|
-
var common_1 = require("@codeleap/common");
|
|
20
|
-
var portal_1 = require("@gorhom/portal");
|
|
21
|
-
var KeyboardAware_1 = require("../KeyboardAware");
|
|
22
|
-
var ModalContext = react_1.default.createContext({});
|
|
23
|
-
function Provider(_a) {
|
|
24
|
-
var children = _a.children;
|
|
25
|
-
var _b = (0, common_1.useState)({}), modals = _b[0], setModals = _b[1];
|
|
26
|
-
var currentModal = Object.keys(modals).find(function (name) { return modals[name].visible; });
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { onUpdate, TypeGuards, useState } from '@codeleap/common';
|
|
3
|
+
import { PortalProvider } from '@gorhom/portal';
|
|
4
|
+
import { KeyboardProvider } from '../KeyboardAware';
|
|
5
|
+
const ModalContext = React.createContext({});
|
|
6
|
+
export function Provider({ children }) {
|
|
7
|
+
const [modals, setModals] = useState({});
|
|
8
|
+
const currentModal = Object.keys(modals).find(name => modals[name].visible);
|
|
27
9
|
function isVisible(name) {
|
|
28
|
-
|
|
29
|
-
return !!((_a = modals[name]) === null || _a === void 0 ? void 0 : _a.visible);
|
|
10
|
+
return !!modals[name]?.visible;
|
|
30
11
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
setModals(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
12
|
+
const toggleModal = (name, set, props) => {
|
|
13
|
+
const visible = isVisible(name);
|
|
14
|
+
const newVisible = typeof set === 'boolean' ? set : !visible;
|
|
15
|
+
setModals((current) => {
|
|
16
|
+
const attached = newVisible ? [] : current[name].attachments.map(m => [m, { ...current[m], visible: false }]);
|
|
17
|
+
return {
|
|
18
|
+
...current,
|
|
19
|
+
[name]: {
|
|
20
|
+
...current[name],
|
|
21
|
+
visible: newVisible,
|
|
22
|
+
props,
|
|
23
|
+
},
|
|
24
|
+
...Object.fromEntries(attached),
|
|
25
|
+
};
|
|
38
26
|
});
|
|
39
27
|
};
|
|
40
|
-
|
|
41
|
-
setModals(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
const setModal = (name, to) => {
|
|
29
|
+
setModals((current) => ({
|
|
30
|
+
...current,
|
|
31
|
+
[name]: {
|
|
32
|
+
...current[name],
|
|
33
|
+
...to,
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
45
36
|
};
|
|
46
37
|
// const codeleapCtx = useCodeleapContext()
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return new Promise(
|
|
50
|
-
setTimeout(
|
|
38
|
+
const defaultDuration = 300;
|
|
39
|
+
const transition = (from, to, options) => {
|
|
40
|
+
return new Promise((resolve) => {
|
|
41
|
+
setTimeout(() => {
|
|
51
42
|
if (!from) {
|
|
52
|
-
toggleModal(to, true, options
|
|
43
|
+
toggleModal(to, true, options?.props);
|
|
53
44
|
return;
|
|
54
45
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
const _options = {
|
|
47
|
+
duration: defaultDuration,
|
|
48
|
+
...options,
|
|
49
|
+
};
|
|
50
|
+
const toVisible = isVisible(to);
|
|
51
|
+
const fromVisible = isVisible(from);
|
|
58
52
|
// if (!fromVisible && !toVisible) {
|
|
59
53
|
// toggleModal(to, true, options?.props)
|
|
60
54
|
// return
|
|
61
55
|
// }
|
|
62
56
|
toggleModal(from, false);
|
|
63
|
-
setTimeout(
|
|
64
|
-
toggleModal(to, true, options
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
toggleModal(to, true, options?.props);
|
|
65
59
|
resolve();
|
|
66
60
|
}, _options.duration);
|
|
67
61
|
});
|
|
68
62
|
});
|
|
69
63
|
};
|
|
70
64
|
function attach(modal, to) {
|
|
71
|
-
setModals(
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
setModals((modals) => {
|
|
66
|
+
const toModal = modals[to];
|
|
67
|
+
const _modal = modals[modal];
|
|
74
68
|
if (!toModal || !_modal)
|
|
75
69
|
return modals;
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
const isAttached = toModal.attachments.includes(modal) || _modal.attachedTo.includes(to);
|
|
71
|
+
const newVal = { ...modals };
|
|
78
72
|
if (isAttached) {
|
|
79
|
-
newVal[to].attachments = newVal[to].attachments.filter(
|
|
80
|
-
newVal[modal].attachedTo = newVal[modal].attachedTo.filter(
|
|
73
|
+
newVal[to].attachments = newVal[to].attachments.filter(x => x !== modal);
|
|
74
|
+
newVal[modal].attachedTo = newVal[modal].attachedTo.filter(x => x !== to);
|
|
81
75
|
}
|
|
82
76
|
else {
|
|
83
77
|
newVal[to].attachments.push(modal);
|
|
@@ -87,55 +81,59 @@ function Provider(_a) {
|
|
|
87
81
|
});
|
|
88
82
|
}
|
|
89
83
|
function remove(id) {
|
|
90
|
-
|
|
84
|
+
const newModals = { ...modals };
|
|
91
85
|
delete newModals[id];
|
|
92
86
|
setModals(newModals);
|
|
93
87
|
}
|
|
94
|
-
return <
|
|
88
|
+
return <KeyboardProvider>
|
|
95
89
|
<ModalContext.Provider value={{
|
|
96
90
|
state: modals,
|
|
97
|
-
toggleModal
|
|
98
|
-
setModal
|
|
99
|
-
currentModal
|
|
100
|
-
attach
|
|
101
|
-
isVisible
|
|
102
|
-
remove
|
|
103
|
-
transition
|
|
91
|
+
toggleModal,
|
|
92
|
+
setModal,
|
|
93
|
+
currentModal,
|
|
94
|
+
attach,
|
|
95
|
+
isVisible,
|
|
96
|
+
remove,
|
|
97
|
+
transition,
|
|
104
98
|
transitionDuration: defaultDuration,
|
|
105
99
|
}}>
|
|
106
|
-
<
|
|
100
|
+
<PortalProvider>
|
|
107
101
|
|
|
108
102
|
{children}
|
|
109
|
-
</
|
|
103
|
+
</PortalProvider>
|
|
110
104
|
</ModalContext.Provider>
|
|
111
|
-
</
|
|
105
|
+
</KeyboardProvider>;
|
|
112
106
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var context = react_1.default.useContext(ModalContext);
|
|
107
|
+
export function useModalContext() {
|
|
108
|
+
const context = React.useContext(ModalContext);
|
|
116
109
|
return context;
|
|
117
110
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
111
|
+
export function useModalSequence(ids, options) {
|
|
112
|
+
const _options = {
|
|
113
|
+
closeLastOnFinish: true,
|
|
114
|
+
onFinish: () => { },
|
|
115
|
+
resetOnFinish: false,
|
|
116
|
+
waitForLastToCloseBeforeCallingFinish: true,
|
|
117
|
+
...options,
|
|
118
|
+
};
|
|
119
|
+
const modals = useModalContext();
|
|
120
|
+
const [idx, setIdx] = useState(0);
|
|
121
|
+
const state = {
|
|
124
122
|
currentId: ids[idx],
|
|
125
123
|
nextId: ids[idx + 1],
|
|
126
124
|
previousId: ids[idx - 1],
|
|
127
125
|
};
|
|
128
|
-
|
|
129
|
-
if (_options.autoOpen && typeof
|
|
126
|
+
onUpdate(() => {
|
|
127
|
+
if (_options.autoOpen && typeof ids?.[0] === 'number') {
|
|
130
128
|
if (!modals.isVisible(ids[0])) {
|
|
131
129
|
modals.toggleModal(ids[0]);
|
|
132
130
|
}
|
|
133
131
|
}
|
|
134
|
-
}, [_options.autoOpen, ids
|
|
132
|
+
}, [_options.autoOpen, ids?.[0]]);
|
|
135
133
|
function next(props) {
|
|
136
134
|
if (idx === ids.length - 1) {
|
|
137
135
|
if (_options.closeLastOnFinish) {
|
|
138
|
-
modals.transition(ids[idx], null).then(
|
|
136
|
+
modals.transition(ids[idx], null).then(() => {
|
|
139
137
|
if (_options.waitForLastToCloseBeforeCallingFinish) {
|
|
140
138
|
_options.onFinish();
|
|
141
139
|
}
|
|
@@ -153,32 +151,39 @@ function useModalSequence(ids, options) {
|
|
|
153
151
|
if (!state.nextId)
|
|
154
152
|
return;
|
|
155
153
|
modals.transition(ids[idx], state.nextId, props);
|
|
156
|
-
setIdx(
|
|
154
|
+
setIdx(i => i + 1);
|
|
157
155
|
}
|
|
158
156
|
}
|
|
159
157
|
function previous(props) {
|
|
160
158
|
if (!state.previousId)
|
|
161
159
|
return;
|
|
162
160
|
modals.transition(ids[idx], state.previousId, props);
|
|
163
|
-
setIdx(
|
|
161
|
+
setIdx(i => i - 1);
|
|
164
162
|
}
|
|
165
163
|
function goto(idxOrId, props) {
|
|
166
|
-
|
|
167
|
-
if (
|
|
164
|
+
let newId = null;
|
|
165
|
+
if (TypeGuards.isString(idxOrId)) {
|
|
168
166
|
newId = idxOrId;
|
|
169
167
|
}
|
|
170
168
|
else {
|
|
171
169
|
newId = ids[idxOrId];
|
|
172
170
|
}
|
|
173
171
|
modals.transition(ids[idx], newId, {
|
|
174
|
-
props
|
|
172
|
+
props,
|
|
175
173
|
});
|
|
176
174
|
setIdx(ids.indexOf(newId));
|
|
177
175
|
}
|
|
178
176
|
function reset() {
|
|
179
177
|
setIdx(0);
|
|
180
178
|
}
|
|
181
|
-
return
|
|
179
|
+
return {
|
|
180
|
+
reset,
|
|
181
|
+
next,
|
|
182
|
+
previous,
|
|
183
|
+
setModal: setIdx,
|
|
184
|
+
goto,
|
|
185
|
+
currentIdx: idx,
|
|
186
|
+
...state,
|
|
187
|
+
};
|
|
182
188
|
}
|
|
183
|
-
exports.useModalSequence = useModalSequence;
|
|
184
189
|
//# sourceMappingURL=context.js.map
|