@bigbinary/neeto-commons-rn 1.0.88 → 1.0.90
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.TextWithUrl=void 0;var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _neetouiRn=require("@bigbinary/neetoui-rn");var _propTypes=_interopRequireDefault(require("prop-types"));var _constants=require("./constants");var _jsxRuntime=require("react/jsx-runtime");var _excluded=["text"];var _this=this,_jsxFileName="/home/runner/work/neeto-commons-rn/neeto-commons-rn/src/components/TextWithUrl.jsx";var TextWithUrl=exports.TextWithUrl=function TextWithUrl(_ref){var text=_ref.text,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);if(typeof text!=="string")return text;var parts=text.split(_constants.VALID_URL_EMAIL_REGEX);return parts.map(function(part,index){if(_constants.VALID_URL_EMAIL_REGEX.test(part)){var isEmailPresent=_constants.VALID_EMAIL_REGEX.test(part);return(0,_jsxRuntime.jsx)(_reactNative.TouchableWithoutFeedback,{onPress:function onPress(){return isEmailPresent?_reactNative.Linking.openURL("mailto:"+part):_reactNative.Linking.openURL(part);},children:(0,_jsxRuntime.jsx)(_neetouiRn.Typography,{color:"font.blue",fontSize:"l",children:part})},index);}return(0,_jsxRuntime.jsx)(_neetouiRn.Typography,Object.assign({},rest,{children:part}),index);});};TextWithUrl.propTypes={text:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.number]).isRequired,rest:_propTypes.default.object};TextWithUrl.defaultProps={text:"",rest:{}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.VALID_URL_EMAIL_REGEX=exports.VALID_EMAIL_REGEX=void 0;var VALID_URL_EMAIL_REGEX=exports.VALID_URL_EMAIL_REGEX=/(https?:\/\/[^\s]+)|(\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b)/g;var VALID_EMAIL_REGEX=exports.VALID_EMAIL_REGEX=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
package/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"AppVersion",{enumerable:true,get:function get(){return _AppVersion.AppVersion;}});Object.defineProperty(exports,"BaseHeader",{enumerable:true,get:function get(){return _BaseHeader.BaseHeader;}});Object.defineProperty(exports,"EmptyView",{enumerable:true,get:function get(){return _EmptyView.EmptyView;}});Object.defineProperty(exports,"Header",{enumerable:true,get:function get(){return _Header.Header;}});Object.defineProperty(exports,"LineLoader",{enumerable:true,get:function get(){return _LineLoader.LineLoader;}});Object.defineProperty(exports,"NotificationIcon",{enumerable:true,get:function get(){return _NotificationIcon.NotificationIcon;}});Object.defineProperty(exports,"ScreenHeader",{enumerable:true,get:function get(){return _ScreenHeader.ScreenHeader;}});var _BaseHeader=require("./Header/BaseHeader");var _ScreenHeader=require("./Header/ScreenHeader");var _AppVersion=require("./AppVersion");var _LineLoader=require("./LineLoader");var _Header=require("./Header");var _NotificationIcon=require("./NotificationIcon");var _EmptyView=require("./EmptyView");
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"AppVersion",{enumerable:true,get:function get(){return _AppVersion.AppVersion;}});Object.defineProperty(exports,"BaseHeader",{enumerable:true,get:function get(){return _BaseHeader.BaseHeader;}});Object.defineProperty(exports,"EmptyView",{enumerable:true,get:function get(){return _EmptyView.EmptyView;}});Object.defineProperty(exports,"Header",{enumerable:true,get:function get(){return _Header.Header;}});Object.defineProperty(exports,"LineLoader",{enumerable:true,get:function get(){return _LineLoader.LineLoader;}});Object.defineProperty(exports,"NotificationIcon",{enumerable:true,get:function get(){return _NotificationIcon.NotificationIcon;}});Object.defineProperty(exports,"ScreenHeader",{enumerable:true,get:function get(){return _ScreenHeader.ScreenHeader;}});Object.defineProperty(exports,"TextWithUrl",{enumerable:true,get:function get(){return _TextWithUrl.TextWithUrl;}});var _BaseHeader=require("./Header/BaseHeader");var _ScreenHeader=require("./Header/ScreenHeader");var _AppVersion=require("./AppVersion");var _LineLoader=require("./LineLoader");var _Header=require("./Header");var _NotificationIcon=require("./NotificationIcon");var _EmptyView=require("./EmptyView");var _TextWithUrl=require("./TextWithUrl");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.usePushNotification=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _react=require("react");var _reactNative=require("react-native");var _dayjs=_interopRequireDefault(require("dayjs"));var _reactNativeNotifications=require("react-native-notifications");var _reactNativePermissions=require("react-native-permissions");var _reactNativePushNotification=_interopRequireDefault(require("react-native-push-notification"));var _bugsnag=require("../../config/bugsnag");var _constants=require("../../constants");var _asyncStore=require("../asyncStore");var _useNotification2=require("../../hooks/query/useNotification");var _useAppState=require("../../hooks/useAppState");var usePushNotification=exports.usePushNotification=function usePushNotification(isLoggedIn,_ref){var handleClick=_ref.handleClick;var appState=(0,_useAppState.useAppState)();var _useNotification=(0,_useNotification2.useNotification)(),useRegisterTokenMutation=_useNotification.useRegisterTokenMutation,useMarkReadUnreadNotification=_useNotification.useMarkReadUnreadNotification;var _useRegisterTokenMuta=useRegisterTokenMutation(),registerToken=_useRegisterTokenMuta.mutate;var _useMarkReadUnreadNot=useMarkReadUnreadNotification(),markReadUnreadNotification=_useMarkReadUnreadNot.mutate;(0,_react.useEffect)(function(){var events=initializeNotificationEvents();return function(){events.forEach(function(event){return event.remove();});};},[]);(0,_react.useEffect)(function(){if(isLoggedIn&&appState==="active"){initializePN();}},[initializePN,isLoggedIn,appState]);var initializePN=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(){var notificationPermission=yield(0,_reactNativePermissions.checkNotifications)();if(["blocked","unavailable"].includes(notificationPermission.status)){return;}var isRegisteredAlready=yield _reactNativeNotifications.Notifications.isRegisteredForRemoteNotifications();var storedDeviceToken=yield(0,_asyncStore.getItem)(_constants.STORAGE_KEYS.DEVICE_TOKEN);if(isRegisteredAlready&&storedDeviceToken)return;registerForRemoteNotifications();});return function initializePN(){return _ref2.apply(this,arguments);};}();var registerForRemoteNotifications=function registerForRemoteNotifications(){_reactNativeNotifications.Notifications.registerRemoteNotifications();var registerDeviceOnce=function(
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.usePushNotification=void 0;var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _react=require("react");var _reactNative=require("react-native");var _dayjs=_interopRequireDefault(require("dayjs"));var _reactNativeNotifications=require("react-native-notifications");var _reactNativePermissions=require("react-native-permissions");var _reactNativePushNotification=_interopRequireDefault(require("react-native-push-notification"));var _bugsnag=require("../../config/bugsnag");var _constants=require("../../constants");var _asyncStore=require("../asyncStore");var _useNotification2=require("../../hooks/query/useNotification");var _useAppState=require("../../hooks/useAppState");var _store=require("../../store");var usePushNotification=exports.usePushNotification=function usePushNotification(isLoggedIn,_ref){var handleClick=_ref.handleClick;var appState=(0,_useAppState.useAppState)();var _useNotification=(0,_useNotification2.useNotification)(),useRegisterTokenMutation=_useNotification.useRegisterTokenMutation,useMarkReadUnreadNotification=_useNotification.useMarkReadUnreadNotification;var _useRegisterTokenMuta=useRegisterTokenMutation(),registerToken=_useRegisterTokenMuta.mutate;var _useMarkReadUnreadNot=useMarkReadUnreadNotification(),markReadUnreadNotification=_useMarkReadUnreadNot.mutate;(0,_react.useEffect)(function(){var events=initializeNotificationEvents();return function(){events.forEach(function(event){return event.remove();});};},[]);(0,_react.useEffect)(function(){if(isLoggedIn&&appState==="active"){initializePN();}},[initializePN,isLoggedIn,appState]);var initializePN=function(){var _ref2=(0,_asyncToGenerator2.default)(function*(){var notificationPermission=yield(0,_reactNativePermissions.checkNotifications)();if(["blocked","unavailable"].includes(notificationPermission.status)){return;}var isRegisteredAlready=yield _reactNativeNotifications.Notifications.isRegisteredForRemoteNotifications();var storedDeviceToken=yield(0,_asyncStore.getItem)(_constants.STORAGE_KEYS.DEVICE_TOKEN);if(isRegisteredAlready&&storedDeviceToken)return;registerForRemoteNotifications();});return function initializePN(){return _ref2.apply(this,arguments);};}();var registerForRemoteNotifications=function registerForRemoteNotifications(){_reactNativeNotifications.Notifications.registerRemoteNotifications();var registerDeviceOnce=function(){var isRegistered=false;return function(){var _ref3=(0,_asyncToGenerator2.default)(function*(event){var _Store$getState,_Store$getState$auth;if(isRegistered)return;var isLoggedIn=((_Store$getState=_store.Store.getState())==null?void 0:(_Store$getState$auth=_Store$getState.auth)==null?void 0:_Store$getState$auth.isLoggedIn)||false;if(isLoggedIn&&event.deviceToken){isRegistered=true;var payload={device:{device_token:event.deviceToken,platform:_reactNative.Platform.OS}};var notificationDeviceId=yield(0,_asyncStore.getItem)(_constants.STORAGE_KEYS.DEVICE_TOKEN);if(typeof notificationDeviceId!=="string"){registerToken(payload,{onError:function onError(){return isRegistered=false;}});}}});return function(_x){return _ref3.apply(this,arguments);};}();}();_reactNativeNotifications.Notifications.events().registerRemoteNotificationsRegistered(function(event){return registerDeviceOnce(event);});_reactNativeNotifications.Notifications.events().registerRemoteNotificationsRegistrationFailed(function(event){(0,_bugsnag.bugsnagErrorHandler)(JSON.stringify(event),"notification");});};var markNotificationsAsRead=function markNotificationsAsRead(notification){var _notification$payload,_notification$payload2,_notification$payload3,_notification$payload4;var notificationId=(notification==null?void 0:(_notification$payload=notification.payload)==null?void 0:_notification$payload.notification_id)||(notification==null?void 0:(_notification$payload2=notification.payload)==null?void 0:(_notification$payload3=_notification$payload2.aps)==null?void 0:(_notification$payload4=_notification$payload3.alert)==null?void 0:_notification$payload4.notification_id);handleClick(notification);if(notificationId){markReadUnreadNotification({readAt:(0,_dayjs.default)().toISOString(),notificationId:notificationId});}};_reactNativePushNotification.default.configure({onNotification:function onNotification(notification){return handleClick(notification);}});var initializeNotificationEvents=function initializeNotificationEvents(){var foregroundEvent=_reactNativeNotifications.Notifications.events().registerNotificationReceivedForeground(function(notification,completion){if(_reactNative.Platform.OS==="android"){var _notification$payload5,_notification$payload6,_notification$payload7;_reactNativeNotifications.Notifications.postLocalNotification({body:notification==null?void 0:(_notification$payload5=notification.payload)==null?void 0:_notification$payload5["gcm.notification.body"],title:notification==null?void 0:(_notification$payload6=notification.payload)==null?void 0:_notification$payload6["gcm.notification.title"],url:notification==null?void 0:(_notification$payload7=notification.payload)==null?void 0:_notification$payload7.url});}completion({alert:true,sound:true,badge:false});});var backgroundEvent=_reactNativeNotifications.Notifications.events().registerNotificationReceivedBackground(function(_,completion){completion({alert:true,sound:true,badge:false});});var openedEvent=_reactNativeNotifications.Notifications.events().registerNotificationOpened(function(notification,completion){markNotificationsAsRead(notification);completion();});if(_reactNative.Platform.OS==="android"){_reactNativeNotifications.Notifications.setNotificationChannel({channelId:"default",name:"default",importance:5,enableLights:true,enableVibration:true,showBadge:true});}return[foregroundEvent,backgroundEvent,openedEvent];};return[];};
|