secullum-react-native-ui 4.18.2 → 4.18.4
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/lib/components/Modal.js +51 -2
- package/lib/modules/layout.d.ts +8 -0
- package/lib/modules/layout.js +12 -1
- package/package.json +4 -2
package/lib/components/Modal.js
CHANGED
|
@@ -2,7 +2,32 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Modal = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
|
+
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
6
|
+
const layout_1 = require("../modules/layout");
|
|
5
7
|
const react_native_1 = require("react-native");
|
|
8
|
+
// From the most specific to the most generic, in the order Yoga resolves each edge.
|
|
9
|
+
// paddingStart/End map to left/right in LTR, which is the only case we support.
|
|
10
|
+
const paddingSources = {
|
|
11
|
+
top: ['paddingTop', 'paddingVertical', 'padding'],
|
|
12
|
+
bottom: ['paddingBottom', 'paddingVertical', 'padding'],
|
|
13
|
+
left: ['paddingStart', 'paddingLeft', 'paddingHorizontal', 'padding'],
|
|
14
|
+
right: ['paddingEnd', 'paddingRight', 'paddingHorizontal', 'padding']
|
|
15
|
+
};
|
|
16
|
+
const resolvePadding = (style, edge) => {
|
|
17
|
+
for (const key of paddingSources[edge]) {
|
|
18
|
+
const value = style[key];
|
|
19
|
+
if (typeof value === 'number') {
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
// Percentages and 'auto' can't be added to an inset in dp. The safe area wins,
|
|
23
|
+
// since it's the one that can't be missing. If both are needed, declare the
|
|
24
|
+
// padding on the container instead.
|
|
25
|
+
if (value != null) {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return 0;
|
|
30
|
+
};
|
|
6
31
|
class Modal extends React.Component {
|
|
7
32
|
constructor() {
|
|
8
33
|
super(...arguments);
|
|
@@ -22,8 +47,32 @@ class Modal extends React.Component {
|
|
|
22
47
|
const { children, visible, overlayStyle, onRequestClose } = this.props;
|
|
23
48
|
const { isMounted } = this.state;
|
|
24
49
|
return (React.createElement(react_native_1.Modal, { animationType: react_native_1.Platform.OS === 'ios' ? 'none' : 'fade', transparent: true, visible: visible, supportedOrientations: ['landscape', 'portrait'], onRequestClose: onRequestClose, onShow: this.handleShow },
|
|
25
|
-
React.createElement(
|
|
26
|
-
|
|
50
|
+
React.createElement(react_native_safe_area_context_1.SafeAreaInsetsContext.Consumer, null, insets => {
|
|
51
|
+
const flattenedOverlayStyle = react_native_1.StyleSheet.flatten([
|
|
52
|
+
styles.overlay,
|
|
53
|
+
overlayStyle
|
|
54
|
+
]);
|
|
55
|
+
// sec-issues#14678: On edge-to-edge the modal window is the whole screen,
|
|
56
|
+
// including the system bar areas, and React Native no longer applies
|
|
57
|
+
// fitsSystemWindows to that window. The safe area is added to the padding
|
|
58
|
+
// of the consumer that already declared it and is applied last, so that
|
|
59
|
+
// no overlayStyle accidentally overrides it. On Android, when the navigation
|
|
60
|
+
// bar moves to the side, the inset comes in from the left or right instead
|
|
61
|
+
// of from the bottom.
|
|
62
|
+
const safeAreaStyle = (0, layout_1.isEdgeToEdge)() && insets
|
|
63
|
+
? {
|
|
64
|
+
paddingTop: resolvePadding(flattenedOverlayStyle, 'top') + insets.top,
|
|
65
|
+
paddingBottom: resolvePadding(flattenedOverlayStyle, 'bottom') +
|
|
66
|
+
insets.bottom,
|
|
67
|
+
paddingLeft: resolvePadding(flattenedOverlayStyle, 'left') +
|
|
68
|
+
insets.left,
|
|
69
|
+
paddingRight: resolvePadding(flattenedOverlayStyle, 'right') +
|
|
70
|
+
insets.right
|
|
71
|
+
}
|
|
72
|
+
: null;
|
|
73
|
+
return (React.createElement(react_native_1.TouchableWithoutFeedback, { onPress: onRequestClose },
|
|
74
|
+
React.createElement(react_native_1.View, { style: [flattenedOverlayStyle, safeAreaStyle] }, react_native_1.Platform.OS !== 'android' || isMounted ? children : React.createElement(react_native_1.View, null))));
|
|
75
|
+
})));
|
|
27
76
|
}
|
|
28
77
|
}
|
|
29
78
|
exports.Modal = Modal;
|
package/lib/modules/layout.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
1
|
export declare const isTablet: () => boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Whether the app window draws behind the system bars (edge-to-edge).
|
|
4
|
+
* Starting on Android 15 (API 35) this mode is enforced, and the content has to
|
|
5
|
+
* reserve the status and navigation bar areas on its own.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link https://developer.android.com/develop/ui/views/layout/edge-to-edge|Android documentation}
|
|
8
|
+
*/
|
|
9
|
+
export declare const isEdgeToEdge: () => boolean;
|
package/lib/modules/layout.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isTablet = void 0;
|
|
3
|
+
exports.isEdgeToEdge = exports.isTablet = void 0;
|
|
4
4
|
const react_native_1 = require("react-native");
|
|
5
5
|
const isTablet = () => {
|
|
6
6
|
if (react_native_1.Platform.OS === 'web') {
|
|
@@ -10,3 +10,14 @@ const isTablet = () => {
|
|
|
10
10
|
react_native_1.Dimensions.get('window').width >= 500);
|
|
11
11
|
};
|
|
12
12
|
exports.isTablet = isTablet;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the app window draws behind the system bars (edge-to-edge).
|
|
15
|
+
* Starting on Android 15 (API 35) this mode is enforced, and the content has to
|
|
16
|
+
* reserve the status and navigation bar areas on its own.
|
|
17
|
+
*
|
|
18
|
+
* @see {@link https://developer.android.com/develop/ui/views/layout/edge-to-edge|Android documentation}
|
|
19
|
+
*/
|
|
20
|
+
const isEdgeToEdge = () => {
|
|
21
|
+
return react_native_1.Platform.OS === 'android' && Number(react_native_1.Platform.Version) >= 35;
|
|
22
|
+
};
|
|
23
|
+
exports.isEdgeToEdge = isEdgeToEdge;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "secullum-react-native-ui",
|
|
3
|
-
"version": "4.18.
|
|
3
|
+
"version": "4.18.4",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -46,13 +46,15 @@
|
|
|
46
46
|
"react": "^16.8.6",
|
|
47
47
|
"react-dom": "^16.8.6",
|
|
48
48
|
"react-native": "^0.52 || ^0.53 || ^0.54 || ^0.55 || ^0.63",
|
|
49
|
+
"react-native-safe-area-context": "^4.10.5",
|
|
49
50
|
"rimraf": "^2.6.2",
|
|
50
51
|
"typescript": "^4.8.3"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|
|
53
54
|
"react": "^16.8.6",
|
|
54
55
|
"react-dom": "^16.8.6",
|
|
55
|
-
"react-native": "^0.52 || ^0.53 || ^0.54 || ^0.55 || ^0.63"
|
|
56
|
+
"react-native": "^0.52 || ^0.53 || ^0.54 || ^0.55 || ^0.63",
|
|
57
|
+
"react-native-safe-area-context": ">=4.0.0"
|
|
56
58
|
},
|
|
57
59
|
"resolutions": {
|
|
58
60
|
"docz-plugin-css/node-sass": "~9.0.0",
|