@artsy/palette-mobile 11.0.3 → 11.0.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.
|
@@ -11,12 +11,14 @@ interface BodyProps extends Partial<Pick<FlexProps, "backgroundColor">> {
|
|
|
11
11
|
children?: ReactNode;
|
|
12
12
|
scroll?: boolean;
|
|
13
13
|
nosafe?: boolean;
|
|
14
|
+
noTopSafe?: boolean;
|
|
15
|
+
noBottomSafe?: boolean;
|
|
14
16
|
fullwidth?: boolean;
|
|
15
17
|
}
|
|
16
18
|
export declare const Screen: (({ children }: {
|
|
17
19
|
children?: ReactNode;
|
|
18
20
|
}) => JSX.Element) & {
|
|
19
|
-
Body: ({ scroll, nosafe, fullwidth, children, ...restFlexProps }: BodyProps) => JSX.Element;
|
|
21
|
+
Body: ({ scroll, nosafe, noTopSafe, noBottomSafe, fullwidth, children, ...restFlexProps }: BodyProps) => JSX.Element;
|
|
20
22
|
Header: ({ onBack }: HeaderProps) => JSX.Element;
|
|
21
23
|
FloatingHeader: FC<HeaderProps>;
|
|
22
24
|
RawHeader: ({ children, nosafe }: RawHeaderProps) => JSX.Element;
|
|
@@ -15,9 +15,11 @@ const ArtsyKeyboardAvoidingView_1 = require("../ArtsyKeyboardAvoidingView");
|
|
|
15
15
|
const BackButton_1 = require("../BackButton");
|
|
16
16
|
const Flex_1 = require("../Flex");
|
|
17
17
|
const Spacer_1 = require("../Spacer");
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
18
19
|
const ScreenContext = (0, react_1.createContext)(null);
|
|
19
20
|
function useScreenContext() {
|
|
20
21
|
const context = (0, react_1.useContext)(ScreenContext);
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
21
23
|
if (!context) {
|
|
22
24
|
throw new Error("useScreenContext must be used within a Screen");
|
|
23
25
|
}
|
|
@@ -73,14 +75,14 @@ const RawHeader = ({ children, nosafe = false }) => {
|
|
|
73
75
|
return ((0, jsx_runtime_1.jsx)(Wrap_1.Wrap, { if: !nosafe, children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { top: saInsets.top, children: (0, jsx_runtime_1.jsx)(Wrap_1.Wrap.Content, { children: children }) }) }));
|
|
74
76
|
};
|
|
75
77
|
const SCREEN_HORIZONTAL_PADDING = 2;
|
|
76
|
-
const Body = ({ scroll = false, nosafe = false, fullwidth = false, children, ...restFlexProps }) => {
|
|
78
|
+
const Body = ({ scroll = false, nosafe = false, noTopSafe = false, noBottomSafe = false, fullwidth = false, children, ...restFlexProps }) => {
|
|
77
79
|
const childrenExceptBottomView = (0, react_nanny_1.removeChildrenByType)(children, exports.Screen.BottomView);
|
|
78
80
|
const bottomView = (0, react_nanny_1.getChildrenByType)(children, exports.Screen.BottomView);
|
|
79
81
|
const { options } = useScreenContext();
|
|
80
82
|
const insets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
|
|
81
|
-
const withTopSafeArea = options.handleTopSafeArea && !
|
|
82
|
-
const withBottomSafeArea = !
|
|
83
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, mt: withTopSafeArea ? `${insets.top}px` : undefined, mb: withBottomSafeArea ? `${insets.bottom}px` : undefined, ...restFlexProps, children: (0, jsx_runtime_1.jsx)(Wrap_1.Wrap, { if: scroll, children: (0, jsx_runtime_1.jsxs)(ArtsyKeyboardAvoidingView_1.ArtsyKeyboardAvoidingView, { children: [(0, jsx_runtime_1.jsx)(react_native_1.ScrollView, { keyboardShouldPersistTaps: "handled", contentInset: { bottom: options.bottomViewHeight - insets.bottom }, children: (0, jsx_runtime_1.jsx)(Wrap_1.Wrap.Content, { children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, px: fullwidth ? undefined : SCREEN_HORIZONTAL_PADDING, children: childrenExceptBottomView }) }) }), bottomView] }) }) }) }));
|
|
83
|
+
const withTopSafeArea = options.handleTopSafeArea && !noTopSafe;
|
|
84
|
+
const withBottomSafeArea = !noBottomSafe;
|
|
85
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, mt: nosafe || withTopSafeArea ? `${insets.top}px` : undefined, mb: nosafe || withBottomSafeArea ? `${insets.bottom}px` : undefined, ...restFlexProps, children: (0, jsx_runtime_1.jsx)(Wrap_1.Wrap, { if: scroll, children: (0, jsx_runtime_1.jsxs)(ArtsyKeyboardAvoidingView_1.ArtsyKeyboardAvoidingView, { children: [(0, jsx_runtime_1.jsx)(react_native_1.ScrollView, { keyboardShouldPersistTaps: "handled", contentInset: { bottom: options.bottomViewHeight - insets.bottom }, children: (0, jsx_runtime_1.jsx)(Wrap_1.Wrap.Content, { children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, px: fullwidth ? undefined : SCREEN_HORIZONTAL_PADDING, children: childrenExceptBottomView }) }) }), bottomView] }) }) }) }));
|
|
84
86
|
};
|
|
85
87
|
const Background = ({ children }) => ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { position: "absolute", top: 0, bottom: 0, left: 0, right: 0, children: children }));
|
|
86
88
|
const BottomView = ({ children }) => {
|