@bigbinary/neetoui-rn 0.0.205 → 0.0.206
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/index.d.ts +1 -0
- package/lib/components/ParentView.js +1 -1
- package/package.json +1 -1
- package/src/components/ParentView.js +22 -1
package/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ParentView=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _propTypes=_interopRequireDefault(require("prop-types"));var _native=require("styled-components/native");var _reactNativeSafeAreaContext=require("react-native-safe-area-context");var _=require("./");var _excluded=["barStyle","children","backgroundColor","bg","topInset","rightInset","leftInset","bottomInset"];var _this=this,_jsxFileName="/home/runner/work/neeto-ui-rn/neeto-ui-rn/src/components/ParentView.js";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var ParentView=function ParentView(_ref){var _ref$barStyle=_ref.barStyle,barStyle=_ref$barStyle===void 0?"light-content":_ref$barStyle,children=_ref.children,backgroundColor=_ref.backgroundColor,bg=_ref.bg,_ref$topInset=_ref.topInset,topInset=_ref$topInset===void 0?true:_ref$topInset,_ref$rightInset=_ref.rightInset,rightInset=_ref$rightInset===void 0?true:_ref$rightInset,_ref$leftInset=_ref.leftInset,leftInset=_ref$leftInset===void 0?true:_ref$leftInset,_ref$bottomInset=_ref.bottomInset,bottomInset=_ref$bottomInset===void 0?true:_ref$bottomInset,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var theme=(0,_react.useContext)(_native.ThemeContext);var safeAreaViewProps={edges:[topInset&&"top",rightInset&&"right",leftInset&&"left"]};var newBackgroundColor=backgroundColor||bg||theme.colors.background.parentView;var statusBarColors={default:theme.colors.background.white,"dark-content":theme.colors.background.white,"light-content":theme.colors.background.base};var statusBarColor=statusBarColors[barStyle]||statusBarColors["default"];var insets=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)();return _react.default.createElement(_reactNativeSafeAreaContext.SafeAreaView,(0,_extends2.default)({flex:1},safeAreaViewProps,{style:{backgroundColor:statusBarColor},__self:_this,__source:{fileName:_jsxFileName,lineNumber:
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ParentView=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _propTypes=_interopRequireDefault(require("prop-types"));var _native=require("styled-components/native");var _reactNativeSafeAreaContext=require("react-native-safe-area-context");var _=require("./");var _useKeyboard=require("../hooks/useKeyboard");var _excluded=["barStyle","children","backgroundColor","bg","topInset","rightInset","leftInset","bottomInset","shouldDismissKeyboardOnTap"];var _this=this,_jsxFileName="/home/runner/work/neeto-ui-rn/neeto-ui-rn/src/components/ParentView.js";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var ParentView=function ParentView(_ref){var _ref$barStyle=_ref.barStyle,barStyle=_ref$barStyle===void 0?"light-content":_ref$barStyle,children=_ref.children,backgroundColor=_ref.backgroundColor,bg=_ref.bg,_ref$topInset=_ref.topInset,topInset=_ref$topInset===void 0?true:_ref$topInset,_ref$rightInset=_ref.rightInset,rightInset=_ref$rightInset===void 0?true:_ref$rightInset,_ref$leftInset=_ref.leftInset,leftInset=_ref$leftInset===void 0?true:_ref$leftInset,_ref$bottomInset=_ref.bottomInset,bottomInset=_ref$bottomInset===void 0?true:_ref$bottomInset,_ref$shouldDismissKey=_ref.shouldDismissKeyboardOnTap,shouldDismissKeyboardOnTap=_ref$shouldDismissKey===void 0?true:_ref$shouldDismissKey,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var theme=(0,_react.useContext)(_native.ThemeContext);var keyboardHeight=(0,_useKeyboard.useKeyboard)();var safeAreaViewProps={edges:[topInset&&"top",rightInset&&"right",leftInset&&"left"]};var newBackgroundColor=backgroundColor||bg||theme.colors.background.parentView;var statusBarColors={default:theme.colors.background.white,"dark-content":theme.colors.background.white,"light-content":theme.colors.background.base};var statusBarColor=statusBarColors[barStyle]||statusBarColors["default"];var insets=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)();return _react.default.createElement(_reactNativeSafeAreaContext.SafeAreaView,(0,_extends2.default)({flex:1},safeAreaViewProps,{style:{backgroundColor:statusBarColor},__self:_this,__source:{fileName:_jsxFileName,lineNumber:66,columnNumber:5}}),_react.default.createElement(_reactNative.StatusBar,{barStyle:barStyle,backgroundColor:statusBarColor,__self:_this,__source:{fileName:_jsxFileName,lineNumber:71,columnNumber:7}}),_react.default.createElement(_.Container,(0,_extends2.default)({},shouldDismissKeyboardOnTap?{onTouchStart:function onTouchStart(e){var _e$target,_e$target$_internalFi,_e$target$_internalFi2;if(keyboardHeight&&(e==null?void 0:(_e$target=e.target)==null?void 0:(_e$target$_internalFi=_e$target._internalFiberInstanceHandleDEV)==null?void 0:(_e$target$_internalFi2=_e$target$_internalFi.elementType)==null?void 0:_e$target$_internalFi2.indexOf("TextInput"))===-1){_reactNative.Keyboard.dismiss();}}}:{},{flex:1,backgroundColor:newBackgroundColor},rest,bottomInset&&{pb:insets.bottom},{__self:_this,__source:{fileName:_jsxFileName,lineNumber:72,columnNumber:7}}),children));};exports.ParentView=ParentView;ParentView.propTypes={barStyle:_propTypes.default.string,children:_propTypes.default.node,backgroundColor:_propTypes.default.string,bg:_propTypes.default.string,topInset:_propTypes.default.bool,rightInset:_propTypes.default.bool,leftInset:_propTypes.default.bool,bottomInset:_propTypes.default.bool,shouldDismissKeyboardOnTap:_propTypes.default.bool};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
|
-
import { StatusBar } from "react-native";
|
|
2
|
+
import { Keyboard, StatusBar } from "react-native";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { ThemeContext } from "styled-components/native";
|
|
5
5
|
import {
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from "react-native-safe-area-context";
|
|
9
9
|
|
|
10
10
|
import { Container } from "@components";
|
|
11
|
+
import { useKeyboard } from "../hooks/useKeyboard";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
*ParentView wraps the childrens with SafeAreaview.
|
|
@@ -37,9 +38,11 @@ export const ParentView = ({
|
|
|
37
38
|
rightInset = true,
|
|
38
39
|
leftInset = true,
|
|
39
40
|
bottomInset = true,
|
|
41
|
+
shouldDismissKeyboardOnTap = true,
|
|
40
42
|
...rest
|
|
41
43
|
}) => {
|
|
42
44
|
const theme = useContext(ThemeContext);
|
|
45
|
+
const keyboardHeight = useKeyboard();
|
|
43
46
|
|
|
44
47
|
const safeAreaViewProps = {
|
|
45
48
|
edges: [topInset && "top", rightInset && "right", leftInset && "left"],
|
|
@@ -67,6 +70,20 @@ export const ParentView = ({
|
|
|
67
70
|
>
|
|
68
71
|
<StatusBar barStyle={barStyle} backgroundColor={statusBarColor} />
|
|
69
72
|
<Container
|
|
73
|
+
{...(shouldDismissKeyboardOnTap
|
|
74
|
+
? {
|
|
75
|
+
onTouchStart: e => {
|
|
76
|
+
if (
|
|
77
|
+
keyboardHeight &&
|
|
78
|
+
e?.target?._internalFiberInstanceHandleDEV?.elementType?.indexOf(
|
|
79
|
+
"TextInput"
|
|
80
|
+
) === -1
|
|
81
|
+
) {
|
|
82
|
+
Keyboard.dismiss();
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
: {})}
|
|
70
87
|
flex={1}
|
|
71
88
|
backgroundColor={newBackgroundColor}
|
|
72
89
|
{...rest}
|
|
@@ -108,4 +125,8 @@ ParentView.propTypes = {
|
|
|
108
125
|
* Sets Bottom Inset
|
|
109
126
|
*/
|
|
110
127
|
bottomInset: PropTypes.bool,
|
|
128
|
+
/**
|
|
129
|
+
* Dismiss keyboard on tap
|
|
130
|
+
*/
|
|
131
|
+
shouldDismissKeyboardOnTap: PropTypes.bool,
|
|
111
132
|
};
|