@selfcommunity/react-core 0.1.2-alpha.0
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/LICENSE.md +21 -0
- package/README.md +13 -0
- package/lib/cjs/components/provider/SCAlertMessagesProvider/index.js +67 -0
- package/lib/cjs/components/provider/SCContextProvider/index.js +117 -0
- package/lib/cjs/components/provider/SCLocaleProvider/index.js +158 -0
- package/lib/cjs/components/provider/SCNotificationProvider/index.js +73 -0
- package/lib/cjs/components/provider/SCPreferencesProvider/index.js +93 -0
- package/lib/cjs/components/provider/SCRoutingProvider/index.js +146 -0
- package/lib/cjs/components/provider/SCThemeProvider/index.js +123 -0
- package/lib/cjs/components/provider/SCUserProvider/index.js +310 -0
- package/lib/cjs/components/router/index.js +91 -0
- package/lib/cjs/constants/Actions.js +6 -0
- package/lib/cjs/constants/ContextProviders.js +29 -0
- package/lib/cjs/constants/Device.js +11 -0
- package/lib/cjs/constants/Errors.js +10 -0
- package/lib/cjs/constants/Features.js +84 -0
- package/lib/cjs/constants/Locale.js +19 -0
- package/lib/cjs/constants/Notification.js +67 -0
- package/lib/cjs/constants/Notifications.js +27 -0
- package/lib/cjs/constants/Preferences.js +344 -0
- package/lib/cjs/constants/Routes.js +68 -0
- package/lib/cjs/constants/Session.js +22 -0
- package/lib/cjs/constants/Theme.js +6 -0
- package/lib/cjs/constants/WebSocket.js +10 -0
- package/lib/cjs/hooks/useSCAuth.js +340 -0
- package/lib/cjs/hooks/useSCCachingManager.js +58 -0
- package/lib/cjs/hooks/useSCConnectionsManager.js +285 -0
- package/lib/cjs/hooks/useSCFetchCategories.js +71 -0
- package/lib/cjs/hooks/useSCFetchCategory.js +68 -0
- package/lib/cjs/hooks/useSCFetchCommentObject.js +68 -0
- package/lib/cjs/hooks/useSCFetchCommentObjects.js +296 -0
- package/lib/cjs/hooks/useSCFetchCustomAdv.js +84 -0
- package/lib/cjs/hooks/useSCFetchFeedObject.js +79 -0
- package/lib/cjs/hooks/useSCFetchIncubator.js +68 -0
- package/lib/cjs/hooks/useSCFetchTag.js +68 -0
- package/lib/cjs/hooks/useSCFetchUser.js +68 -0
- package/lib/cjs/hooks/useSCFollowedCategoriesManager.js +162 -0
- package/lib/cjs/hooks/useSCFollowersManager.js +232 -0
- package/lib/cjs/hooks/useSCMediaClick.js +27 -0
- package/lib/cjs/hooks/useSCSubscribedIncubatorsManager.js +165 -0
- package/lib/cjs/hooks/useSCWebPushMessaging.js +286 -0
- package/lib/cjs/hooks/useSCWebSocket.js +120 -0
- package/lib/cjs/index.js +169 -0
- package/lib/cjs/scss/styles.scss +1 -0
- package/lib/cjs/themes/theme.js +165 -0
- package/lib/cjs/types/context.js +3 -0
- package/lib/cjs/types/index.js +22 -0
- package/lib/cjs/utils/errors.js +196 -0
- package/lib/cjs/utils/locale.js +56 -0
- package/lib/cjs/utils/logger.js +32 -0
- package/lib/cjs/utils/object.js +44 -0
- package/lib/cjs/utils/session.js +17 -0
- package/lib/cjs/utils/string.js +57 -0
- package/lib/cjs/utils/url.js +70 -0
- package/lib/cjs/utils/user.js +83 -0
- package/lib/cjs/utils/validator.js +771 -0
- package/lib/cjs/utils/webPushMessaging.js +110 -0
- package/lib/cjs/utils/websocket.js +307 -0
- package/lib/esm/api-services/src/client/index.d.ts +115 -0
- package/lib/esm/api-services/src/client/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/constants/Endpoints.d.ts +10 -0
- package/lib/esm/api-services/src/constants/Endpoints.d.ts.map +1 -0
- package/lib/esm/api-services/src/index.d.ts +24 -0
- package/lib/esm/api-services/src/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/services/category/index.d.ts +13 -0
- package/lib/esm/api-services/src/services/category/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/services/feature/index.d.ts +10 -0
- package/lib/esm/api-services/src/services/feature/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/services/preference/index.d.ts +16 -0
- package/lib/esm/api-services/src/services/preference/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/services/user/index.d.ts +16 -0
- package/lib/esm/api-services/src/services/user/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/utils/http.d.ts +6 -0
- package/lib/esm/api-services/src/utils/http.d.ts.map +1 -0
- package/lib/esm/api-services/src/utils/token.d.ts +16 -0
- package/lib/esm/api-services/src/utils/token.d.ts.map +1 -0
- package/lib/esm/components/provider/SCAlertMessagesProvider/index.js +67 -0
- package/lib/esm/components/provider/SCContextProvider/index.js +117 -0
- package/lib/esm/components/provider/SCLocaleProvider/index.js +158 -0
- package/lib/esm/components/provider/SCNotificationProvider/index.js +73 -0
- package/lib/esm/components/provider/SCPreferencesProvider/index.js +93 -0
- package/lib/esm/components/provider/SCRoutingProvider/index.js +146 -0
- package/lib/esm/components/provider/SCThemeProvider/index.js +123 -0
- package/lib/esm/components/provider/SCUserProvider/index.js +310 -0
- package/lib/esm/components/router/index.js +91 -0
- package/lib/esm/constants/Actions.js +6 -0
- package/lib/esm/constants/ContextProviders.js +29 -0
- package/lib/esm/constants/Device.js +11 -0
- package/lib/esm/constants/Errors.js +10 -0
- package/lib/esm/constants/Features.js +84 -0
- package/lib/esm/constants/Locale.js +19 -0
- package/lib/esm/constants/Notification.js +67 -0
- package/lib/esm/constants/Notifications.js +27 -0
- package/lib/esm/constants/Preferences.js +344 -0
- package/lib/esm/constants/Routes.js +68 -0
- package/lib/esm/constants/Session.js +22 -0
- package/lib/esm/constants/Theme.js +6 -0
- package/lib/esm/constants/WebSocket.js +10 -0
- package/lib/esm/hooks/useSCAuth.js +340 -0
- package/lib/esm/hooks/useSCCachingManager.js +58 -0
- package/lib/esm/hooks/useSCConnectionsManager.js +285 -0
- package/lib/esm/hooks/useSCFetchCategories.js +71 -0
- package/lib/esm/hooks/useSCFetchCategory.js +68 -0
- package/lib/esm/hooks/useSCFetchCommentObject.js +68 -0
- package/lib/esm/hooks/useSCFetchCommentObjects.js +296 -0
- package/lib/esm/hooks/useSCFetchCustomAdv.js +84 -0
- package/lib/esm/hooks/useSCFetchFeedObject.js +79 -0
- package/lib/esm/hooks/useSCFetchIncubator.js +68 -0
- package/lib/esm/hooks/useSCFetchTag.js +68 -0
- package/lib/esm/hooks/useSCFetchUser.js +68 -0
- package/lib/esm/hooks/useSCFollowedCategoriesManager.js +162 -0
- package/lib/esm/hooks/useSCFollowersManager.js +232 -0
- package/lib/esm/hooks/useSCMediaClick.js +27 -0
- package/lib/esm/hooks/useSCSubscribedIncubatorsManager.js +165 -0
- package/lib/esm/hooks/useSCWebPushMessaging.js +286 -0
- package/lib/esm/hooks/useSCWebSocket.js +120 -0
- package/lib/esm/index.js +169 -0
- package/lib/esm/react-core/src/components/provider/SCAlertMessagesProvider/index.d.ts +37 -0
- package/lib/esm/react-core/src/components/provider/SCAlertMessagesProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCContextProvider/index.d.ts +35 -0
- package/lib/esm/react-core/src/components/provider/SCContextProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCLocaleProvider/index.d.ts +42 -0
- package/lib/esm/react-core/src/components/provider/SCLocaleProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCNotificationProvider/index.d.ts +37 -0
- package/lib/esm/react-core/src/components/provider/SCNotificationProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCPreferencesProvider/index.d.ts +38 -0
- package/lib/esm/react-core/src/components/provider/SCPreferencesProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCRoutingProvider/index.d.ts +39 -0
- package/lib/esm/react-core/src/components/provider/SCRoutingProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCThemeProvider/index.d.ts +49 -0
- package/lib/esm/react-core/src/components/provider/SCThemeProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCUserProvider/index.d.ts +38 -0
- package/lib/esm/react-core/src/components/provider/SCUserProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/router/index.d.ts +34 -0
- package/lib/esm/react-core/src/components/router/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Actions.d.ts +2 -0
- package/lib/esm/react-core/src/constants/Actions.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/ContextProviders.d.ts +6 -0
- package/lib/esm/react-core/src/constants/ContextProviders.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Device.d.ts +6 -0
- package/lib/esm/react-core/src/constants/Device.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Errors.d.ts +5 -0
- package/lib/esm/react-core/src/constants/Errors.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Features.d.ts +41 -0
- package/lib/esm/react-core/src/constants/Features.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Locale.d.ts +8 -0
- package/lib/esm/react-core/src/constants/Locale.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Notification.d.ts +55 -0
- package/lib/esm/react-core/src/constants/Notification.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Notifications.d.ts +11 -0
- package/lib/esm/react-core/src/constants/Notifications.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Routes.d.ts +29 -0
- package/lib/esm/react-core/src/constants/Routes.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Session.d.ts +10 -0
- package/lib/esm/react-core/src/constants/Session.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Theme.d.ts +2 -0
- package/lib/esm/react-core/src/constants/Theme.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCAuth.d.ts +56 -0
- package/lib/esm/react-core/src/hooks/useSCAuth.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCCachingManager.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCCachingManager.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCConnectionsManager.d.ts +40 -0
- package/lib/esm/react-core/src/hooks/useSCConnectionsManager.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCategories.d.ts +17 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCategories.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCategory.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCategory.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCommentObject.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCommentObject.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCommentObjects.d.ts +54 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCommentObjects.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCustomAdv.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCustomAdv.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchFeedObject.d.ts +21 -0
- package/lib/esm/react-core/src/hooks/useSCFetchFeedObject.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchIncubator.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCFetchIncubator.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchTag.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCFetchTag.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchUser.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCFetchUser.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFollowedCategoriesManager.d.ts +37 -0
- package/lib/esm/react-core/src/hooks/useSCFollowedCategoriesManager.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFollowersManager.d.ts +37 -0
- package/lib/esm/react-core/src/hooks/useSCFollowersManager.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCMediaClick.d.ts +4 -0
- package/lib/esm/react-core/src/hooks/useSCMediaClick.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCSubscribedIncubatorsManager.d.ts +27 -0
- package/lib/esm/react-core/src/hooks/useSCSubscribedIncubatorsManager.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCWebPushMessaging.d.ts +9 -0
- package/lib/esm/react-core/src/hooks/useSCWebPushMessaging.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCWebSocket.d.ts +12 -0
- package/lib/esm/react-core/src/hooks/useSCWebSocket.d.ts.map +1 -0
- package/lib/esm/react-core/src/index.d.ts +77 -0
- package/lib/esm/react-core/src/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/types/context.d.ts +428 -0
- package/lib/esm/react-core/src/types/context.d.ts.map +1 -0
- package/lib/esm/react-core/src/types/index.d.ts +3 -0
- package/lib/esm/react-core/src/types/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/errors.d.ts +98 -0
- package/lib/esm/react-core/src/utils/errors.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/locale.d.ts +10 -0
- package/lib/esm/react-core/src/utils/locale.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/logger.d.ts +11 -0
- package/lib/esm/react-core/src/utils/logger.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/object.d.ts +13 -0
- package/lib/esm/react-core/src/utils/object.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/session.d.ts +6 -0
- package/lib/esm/react-core/src/utils/session.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/string.d.ts +21 -0
- package/lib/esm/react-core/src/utils/string.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/url.d.ts +22 -0
- package/lib/esm/react-core/src/utils/url.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/user.d.ts +41 -0
- package/lib/esm/react-core/src/utils/user.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/validator.d.ts +239 -0
- package/lib/esm/react-core/src/utils/validator.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/webPushMessaging.d.ts +14 -0
- package/lib/esm/react-core/src/utils/webPushMessaging.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/websocket.d.ts +177 -0
- package/lib/esm/react-core/src/utils/websocket.d.ts.map +1 -0
- package/lib/esm/react-i18n/src/index.d.ts +815 -0
- package/lib/esm/react-i18n/src/index.d.ts.map +1 -0
- package/lib/esm/scss/styles.scss +1 -0
- package/lib/esm/themes/theme.js +165 -0
- package/lib/esm/types/context.js +3 -0
- package/lib/esm/types/index.js +22 -0
- package/lib/esm/types/src/index.d.ts +9 -0
- package/lib/esm/types/src/index.d.ts.map +1 -0
- package/lib/esm/types/src/types/auth.d.ts +26 -0
- package/lib/esm/types/src/types/auth.d.ts.map +1 -0
- package/lib/esm/types/src/types/broadcastMessage.d.ts +73 -0
- package/lib/esm/types/src/types/broadcastMessage.d.ts.map +1 -0
- package/lib/esm/types/src/types/category.d.ts +100 -0
- package/lib/esm/types/src/types/category.d.ts.map +1 -0
- package/lib/esm/types/src/types/comment.d.ts +97 -0
- package/lib/esm/types/src/types/comment.d.ts.map +1 -0
- package/lib/esm/types/src/types/customAdv.d.ts +53 -0
- package/lib/esm/types/src/types/customAdv.d.ts.map +1 -0
- package/lib/esm/types/src/types/customNotification.d.ts +28 -0
- package/lib/esm/types/src/types/customNotification.d.ts.map +1 -0
- package/lib/esm/types/src/types/embed.d.ts +33 -0
- package/lib/esm/types/src/types/embed.d.ts.map +1 -0
- package/lib/esm/types/src/types/feed.d.ts +208 -0
- package/lib/esm/types/src/types/feed.d.ts.map +1 -0
- package/lib/esm/types/src/types/incubator.d.ts +53 -0
- package/lib/esm/types/src/types/incubator.d.ts.map +1 -0
- package/lib/esm/types/src/types/index.d.ts +22 -0
- package/lib/esm/types/src/types/index.d.ts.map +1 -0
- package/lib/esm/types/src/types/location.d.ts +61 -0
- package/lib/esm/types/src/types/location.d.ts.map +1 -0
- package/lib/esm/types/src/types/media.d.ts +52 -0
- package/lib/esm/types/src/types/media.d.ts.map +1 -0
- package/lib/esm/types/src/types/notification.d.ts +416 -0
- package/lib/esm/types/src/types/notification.d.ts.map +1 -0
- package/lib/esm/types/src/types/poll.d.ts +77 -0
- package/lib/esm/types/src/types/poll.d.ts.map +1 -0
- package/lib/esm/types/src/types/privateMessage.d.ts +109 -0
- package/lib/esm/types/src/types/privateMessage.d.ts.map +1 -0
- package/lib/esm/types/src/types/prize.d.ts +48 -0
- package/lib/esm/types/src/types/prize.d.ts.map +1 -0
- package/lib/esm/types/src/types/tag.d.ts +47 -0
- package/lib/esm/types/src/types/tag.d.ts.map +1 -0
- package/lib/esm/types/src/types/user.d.ts +227 -0
- package/lib/esm/types/src/types/user.d.ts.map +1 -0
- package/lib/esm/utils/errors.js +196 -0
- package/lib/esm/utils/locale.js +56 -0
- package/lib/esm/utils/logger.js +32 -0
- package/lib/esm/utils/object.js +44 -0
- package/lib/esm/utils/session.js +17 -0
- package/lib/esm/utils/src/index.d.ts +7 -0
- package/lib/esm/utils/src/index.d.ts.map +1 -0
- package/lib/esm/utils/src/utils/string.d.ts +21 -0
- package/lib/esm/utils/src/utils/string.d.ts.map +1 -0
- package/lib/esm/utils/src/utils/url.d.ts +22 -0
- package/lib/esm/utils/src/utils/url.d.ts.map +1 -0
- package/lib/esm/utils/string.js +57 -0
- package/lib/esm/utils/url.js +70 -0
- package/lib/esm/utils/user.js +83 -0
- package/lib/esm/utils/validator.js +771 -0
- package/lib/esm/utils/webPushMessaging.js +110 -0
- package/lib/esm/utils/websocket.js +307 -0
- package/lib/umd/react-core.js +2 -0
- package/lib/umd/react-core.js.LICENSE.txt +1 -0
- package/package.json +128 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
|
|
6
|
+
var _styles = require("@mui/material/styles");
|
|
7
|
+
|
|
8
|
+
var _object = require("../utils/object");
|
|
9
|
+
|
|
10
|
+
var _validateColor = _interopRequireDefault(require("validate-color"));
|
|
11
|
+
|
|
12
|
+
var _Preferences = require("../constants/Preferences");
|
|
13
|
+
|
|
14
|
+
var _string = require("../utils/string");
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* check if colorProp is a valid color
|
|
20
|
+
* @param preferences
|
|
21
|
+
* @param colorProp
|
|
22
|
+
* @param tFunc: type func validator
|
|
23
|
+
* @return {boolean|(function(*=): boolean)}
|
|
24
|
+
*/
|
|
25
|
+
const isValidPreference = (preferences, prop, tFunc) => {
|
|
26
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
27
|
+
if (preferences.hasOwnProperty(prop) && preferences[prop].hasOwnProperty('value')) {
|
|
28
|
+
return tFunc(preferences[prop].value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Overrides theme properties
|
|
35
|
+
* @param options: store.settings.theme
|
|
36
|
+
* @param preferences: community global preferences
|
|
37
|
+
* @return {Theme}
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const getTheme = (options, preferences) => {
|
|
42
|
+
const defaultOptions = preferences ? {
|
|
43
|
+
palette: Object.assign({}, isValidPreference(preferences, _Preferences.COLORS_COLORBACK, _validateColor.default) && {
|
|
44
|
+
background: {
|
|
45
|
+
default: preferences[_Preferences.COLORS_COLORBACK].value
|
|
46
|
+
}
|
|
47
|
+
}, isValidPreference(preferences, _Preferences.COLORS_COLORFONT, _validateColor.default) && {
|
|
48
|
+
text: {
|
|
49
|
+
primary: preferences[_Preferences.COLORS_COLORFONT].value
|
|
50
|
+
}
|
|
51
|
+
}, isValidPreference(preferences, _Preferences.COLORS_COLORPRIMARY, _validateColor.default) && {
|
|
52
|
+
primary: {
|
|
53
|
+
main: preferences[_Preferences.COLORS_COLORPRIMARY].value
|
|
54
|
+
}
|
|
55
|
+
}, isValidPreference(preferences, _Preferences.COLORS_COLORSECONDARY, _validateColor.default) && {
|
|
56
|
+
secondary: {
|
|
57
|
+
main: preferences[_Preferences.COLORS_COLORSECONDARY].value
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
typography: Object.assign({}, isValidPreference(preferences, _Preferences.FONT_FAMILY, _string.isString) && {
|
|
61
|
+
fontFamily: preferences[_Preferences.FONT_FAMILY].value
|
|
62
|
+
}, {
|
|
63
|
+
body1: {
|
|
64
|
+
fontSize: '0.9rem'
|
|
65
|
+
},
|
|
66
|
+
body2: {
|
|
67
|
+
fontSize: '0.8rem'
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
components: {
|
|
71
|
+
MuiPaper: {// styleOverrides: {
|
|
72
|
+
// rounded: {
|
|
73
|
+
// borderRadius: 3,
|
|
74
|
+
// },
|
|
75
|
+
// },
|
|
76
|
+
},
|
|
77
|
+
SCWidget: {// variants: [
|
|
78
|
+
// {
|
|
79
|
+
// props: {elevation: 0},
|
|
80
|
+
// style: {
|
|
81
|
+
// border: 0,
|
|
82
|
+
// boxShadow: 'none',
|
|
83
|
+
// marginBottom: '0 !important',
|
|
84
|
+
// },
|
|
85
|
+
// },
|
|
86
|
+
// {
|
|
87
|
+
// props: {variant: 'outlined'},
|
|
88
|
+
// style: {
|
|
89
|
+
// border: '1px solid rgba(0, 0, 0, 0.12)',
|
|
90
|
+
// boxShadow: 'none',
|
|
91
|
+
// },
|
|
92
|
+
// },
|
|
93
|
+
// ],
|
|
94
|
+
// styleOverrides: {
|
|
95
|
+
// root: {
|
|
96
|
+
// border: '0 none',
|
|
97
|
+
// boxShadow: '0px 5px 20px rgba(0, 0, 0, 0.1)',
|
|
98
|
+
// borderRadius: '15px',
|
|
99
|
+
// },
|
|
100
|
+
// },
|
|
101
|
+
},
|
|
102
|
+
MuiDivider: {
|
|
103
|
+
styleOverrides: {
|
|
104
|
+
root: {
|
|
105
|
+
borderWidth: '1px'
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
SCFeedObject: {
|
|
110
|
+
styleOverrides: {
|
|
111
|
+
root: {}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
SCTrendingFeed: {
|
|
115
|
+
styleOverrides: {
|
|
116
|
+
root: {
|
|
117
|
+
'& .MuiIcon-root': {
|
|
118
|
+
marginBottom: '0.5px'
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
SCNotificationItem: {// styleOverrides: {
|
|
124
|
+
// root: {
|
|
125
|
+
// '&.SCNotificationItem-new-snippet': {
|
|
126
|
+
// '&::before': {
|
|
127
|
+
// backgroundColor: 'yellow',
|
|
128
|
+
// },
|
|
129
|
+
// },
|
|
130
|
+
// },
|
|
131
|
+
// },
|
|
132
|
+
},
|
|
133
|
+
SCSnippetNotifications: {
|
|
134
|
+
styleOverrides: {
|
|
135
|
+
root: {
|
|
136
|
+
'& .SCSnippetNotifications-notifications-list': {// wrap notifications list (ul)
|
|
137
|
+
},
|
|
138
|
+
'& .SCSnippetNotifications-notification-item': {// single notification item (li)
|
|
139
|
+
},
|
|
140
|
+
['& .SCUserFollowNotification-username, .SCUserFollowNotification-username, .SCCommentNotification-username,' + 'SCContributionFollowNotification-username, .SCContributionFollowNotification-username, .SCUserNotificationMention-username,' + '.SCUserNotificationMention-username, .SCUserNotificationPrivateMessage-message-sender, .SCVoteUpNotification-username']: {// username for notification types: user follow, comment/nested comment,
|
|
141
|
+
// follow contribution, mention, private message, vote up
|
|
142
|
+
},
|
|
143
|
+
['& .SCUserFollowNotification-list-item-snippet-new, .SCVoteUpNotification-list-item-snippet-new, ' + '.SCUserBlockedNotification-list-item-snippet-new, .SCUndeletedForNotification-list-item-snippet-new, ' + '.SCUserNotificationPrivateMessage-list-item-snippet-new, .SCUserNotificationMention-list-item-snippet-new,' + '.SCKindlyNoticeForNotification-list-item-snippet-new, .SCKindlyNoticeFlagNotification-list-item-snippet-new,' + '.SCIncubatorApprovedNotification-list-item-snippet-new, .SCDeletedForNotification-list-item-snippet-new,' + '.SCContributionFollowNotification-list-item-snippet-new, .SCCommentNotification-list-item-snippet-new,' + '.SCCollapsedForNotification-list-item-snippet-new']: {// border left indicate new notification of various type
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
SCPlatform: {
|
|
149
|
+
styleOverrides: {
|
|
150
|
+
root: {
|
|
151
|
+
'& .MuiIcon-root': {
|
|
152
|
+
fontSize: '18px',
|
|
153
|
+
marginLeft: '2px',
|
|
154
|
+
marginBottom: '-3px'
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
} : {};
|
|
161
|
+
return (0, _styles.createTheme)((0, _object.mergeDeep)(defaultOptions, options));
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
var _default = getTheme;
|
|
165
|
+
exports.default = _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
|
|
5
|
+
var _context = require("./context");
|
|
6
|
+
|
|
7
|
+
exports.SCUserContextType = _context.SCUserContextType;
|
|
8
|
+
exports.SCFollowedManagerType = _context.SCFollowedManagerType;
|
|
9
|
+
exports.SCFollowedCategoriesManagerType = _context.SCFollowedCategoriesManagerType;
|
|
10
|
+
exports.SCSubscribedIncubatorsManagerType = _context.SCSubscribedIncubatorsManagerType;
|
|
11
|
+
exports.SCConnectionsManagerType = _context.SCConnectionsManagerType;
|
|
12
|
+
exports.SCContextProviderType = _context.SCContextProviderType;
|
|
13
|
+
exports.SCContextType = _context.SCContextType;
|
|
14
|
+
exports.SCSettingsType = _context.SCSettingsType;
|
|
15
|
+
exports.SCSessionType = _context.SCSessionType;
|
|
16
|
+
exports.SCPreferencesContextType = _context.SCPreferencesContextType;
|
|
17
|
+
exports.SCNotificationContextType = _context.SCNotificationContextType;
|
|
18
|
+
exports.SCLocaleType = _context.SCLocaleType;
|
|
19
|
+
exports.SCThemeContextType = _context.SCThemeContextType;
|
|
20
|
+
exports.SCRoutingContextType = _context.SCRoutingContextType;
|
|
21
|
+
exports.SCLocaleContextType = _context.SCLocaleContextType;
|
|
22
|
+
exports.SCAlertMessagesContextType = _context.SCAlertMessagesContextType;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.ValidationWarnings = exports.ValidationResult = exports.ValidationError = void 0;
|
|
5
|
+
exports.isFunc = isFunc;
|
|
6
|
+
|
|
7
|
+
var _Locale = require("../constants/Locale");
|
|
8
|
+
|
|
9
|
+
var Session = _interopRequireWildcard(require("../constants/Session"));
|
|
10
|
+
|
|
11
|
+
var _logger = require("./logger");
|
|
12
|
+
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Manage Validation Error
|
|
19
|
+
* Used to check the initial configurations
|
|
20
|
+
*/
|
|
21
|
+
class ValidationError {
|
|
22
|
+
constructor(errorCode, errorData, errorMessage = ValidationError.defaultErrorMessageMap[errorCode]) {
|
|
23
|
+
this.errorCode = null;
|
|
24
|
+
this.errorData = null;
|
|
25
|
+
this.errorMessage = null;
|
|
26
|
+
this.errorCode = errorCode;
|
|
27
|
+
this.errorData = errorData;
|
|
28
|
+
this.errorMessage = errorMessage;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Manage Validation Warnings
|
|
34
|
+
* Used to check the initial configurations
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
exports.ValidationError = ValidationError;
|
|
39
|
+
ValidationError.ERROR_INVALID_CONF = 3100;
|
|
40
|
+
ValidationError.ERROR_INVALID_SESSION = 4100;
|
|
41
|
+
ValidationError.ERROR_INVALID_SESSION_TYPE = 4101;
|
|
42
|
+
ValidationError.ERROR_INVALID_SESSION_AUTH_TOKEN = 4102;
|
|
43
|
+
ValidationError.ERROR_INVALID_SESSION_CLIENT_ID = 4103;
|
|
44
|
+
ValidationError.ERROR_INVALID_SESSION_REFRESH_TOKEN_CALLBACK = 4104;
|
|
45
|
+
ValidationError.ERROR_INVALID_PORTAL = 4200;
|
|
46
|
+
ValidationError.ERROR_INVALID_LOCALE = 4300;
|
|
47
|
+
ValidationError.ERROR_INVALID_TRANSLATIONS = 4400;
|
|
48
|
+
ValidationError.ERROR_INVALID_THEME = 4500;
|
|
49
|
+
ValidationError.ERROR_INVALID_ROUTER = 4600;
|
|
50
|
+
ValidationError.ERROR_INVALID_PROVIDERS = 4700;
|
|
51
|
+
ValidationError.ERROR_INVALID_HANDLE_ANONYMOUS_ACTION = 4800;
|
|
52
|
+
ValidationError.ERROR_INVALID_NOTIFICATIONS = 4900;
|
|
53
|
+
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET = 4901;
|
|
54
|
+
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_DISABLE_TOAST_MESSAGE = 4902;
|
|
55
|
+
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING = 4921;
|
|
56
|
+
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_DISABLE_TOAST_MESSAGE = 4922;
|
|
57
|
+
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_APPLICATION_SERVER_KEY = 4923;
|
|
58
|
+
ValidationError.defaultErrorMessageMap = {
|
|
59
|
+
[ValidationError.ERROR_INVALID_CONF]: 'Invalid or missing library configuration. Check the configuration that is passed to the SCContextProvider.',
|
|
60
|
+
[ValidationError.ERROR_INVALID_SESSION]: 'Invalid session format.',
|
|
61
|
+
[ValidationError.ERROR_INVALID_SESSION_TYPE]: `Invalid sessionType. Available options are ${Session.sessionTypes.join(', ')}.`,
|
|
62
|
+
[ValidationError.ERROR_INVALID_SESSION_AUTH_TOKEN]: 'Invalid auth token format',
|
|
63
|
+
[ValidationError.ERROR_INVALID_SESSION_CLIENT_ID]: 'Invalid clientId in the initial configuration.',
|
|
64
|
+
[ValidationError.ERROR_INVALID_SESSION_REFRESH_TOKEN_CALLBACK]: 'Invalid refresh token callback',
|
|
65
|
+
[ValidationError.ERROR_INVALID_PORTAL]: `Invalid portal. Check if the url format is valid.`,
|
|
66
|
+
[ValidationError.ERROR_INVALID_LOCALE]: `Invalid locale. Available options are ${_Locale.LOCALES.join(', ')}.`,
|
|
67
|
+
[ValidationError.ERROR_INVALID_TRANSLATIONS]: `Invalid locale messages(translations) options.`,
|
|
68
|
+
[ValidationError.ERROR_INVALID_THEME]: 'Invalid theme options.',
|
|
69
|
+
[ValidationError.ERROR_INVALID_ROUTER]: 'Invalid router configuration',
|
|
70
|
+
[ValidationError.ERROR_INVALID_PROVIDERS]: `Invalid providers. Check if the list of providers is valid.`,
|
|
71
|
+
[ValidationError.ERROR_INVALID_HANDLE_ANONYMOUS_ACTION]: 'Invalid handle anonymous action callback',
|
|
72
|
+
[ValidationError.ERROR_INVALID_NOTIFICATIONS]: 'Invalid notifications conf.',
|
|
73
|
+
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET]: 'Invalid notifications (websocket) option.',
|
|
74
|
+
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_DISABLE_TOAST_MESSAGE]: 'Invalid notifications websocket conf: disableToastMessage must be a boolean value.',
|
|
75
|
+
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING]: 'Invalid notifications (web push messaging) option.',
|
|
76
|
+
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_DISABLE_TOAST_MESSAGE]: "Invalid notifications web push messaging option. 'disableToastMessage' must be a boolean value.",
|
|
77
|
+
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_APPLICATION_SERVER_KEY]: "Invalid notifications web push messaging option. 'applicationServerKey' must be a string value."
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
class ValidationWarnings {
|
|
81
|
+
constructor(warningCode, warningData, warningMessage = ValidationWarnings.defaultErrorMessageMap[warningCode]) {
|
|
82
|
+
this.warningCode = null;
|
|
83
|
+
this.warningData = null;
|
|
84
|
+
this.warningMessage = null;
|
|
85
|
+
this.warningCode = warningCode;
|
|
86
|
+
this.warningData = warningData;
|
|
87
|
+
this.warningMessage = warningMessage;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* /**
|
|
93
|
+
* Manage Validation Error/Warnings
|
|
94
|
+
* of the initial configuration
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
exports.ValidationWarnings = ValidationWarnings;
|
|
99
|
+
ValidationWarnings.WARNING_SESSION_REFRESH_TOKEN_CALLBACK_NOT_FOUND = 3100;
|
|
100
|
+
ValidationWarnings.WARNING_LOCALE_FALLBACK = 3300;
|
|
101
|
+
ValidationWarnings.WARNING_ROUTER_FALLBACK = 3500;
|
|
102
|
+
ValidationWarnings.WARNING_HANDLE_ANONYMOUS_ACTION_FALLBACK = 3700;
|
|
103
|
+
ValidationWarnings.defaultErrorMessageMap = {
|
|
104
|
+
[ValidationWarnings.WARNING_SESSION_REFRESH_TOKEN_CALLBACK_NOT_FOUND]: "The 'handleRefreshToken' is not defined in initial conf. When the token expires it will not be renewed and the user session will be lost.",
|
|
105
|
+
[ValidationWarnings.WARNING_LOCALE_FALLBACK]: `The 'locale' is not defined in initial conf, fallback to the default ${_Locale.DEFAULT_LANGUAGE_UI}.`,
|
|
106
|
+
[ValidationWarnings.WARNING_ROUTER_FALLBACK]: "The 'router' is not defined in initial conf, fallback to the default configurations.",
|
|
107
|
+
[ValidationWarnings.WARNING_HANDLE_ANONYMOUS_ACTION_FALLBACK]: "The 'handleAnonymousAction' is not defined in initial conf, fallback to the default configurations."
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
class ValidationResult {
|
|
111
|
+
constructor(scope = '[Report Error]') {
|
|
112
|
+
this.errors = [];
|
|
113
|
+
this.warnings = [];
|
|
114
|
+
this.scope = '';
|
|
115
|
+
this.scope = scope;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Add an error
|
|
119
|
+
* @param errorCode
|
|
120
|
+
* @param errorData
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
addError(errorCode, errorData) {
|
|
125
|
+
this.errors.push(new ValidationError(errorCode, errorData));
|
|
126
|
+
return this.errors;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Add a warning
|
|
130
|
+
* @param errorCode
|
|
131
|
+
* @param errorData
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
addWarnings(warningCode, warningData) {
|
|
136
|
+
this.warnings.push(new ValidationWarnings(warningCode, warningData));
|
|
137
|
+
return this.errors;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Check if contains errors
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
hasErrors() {
|
|
145
|
+
return this.errors.length > 0;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Check if contains warnings
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
hasWarnings() {
|
|
153
|
+
return this.warnings.length > 0;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Emit in console all the errors
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
emitErrors() {
|
|
161
|
+
if (this.hasErrors()) {
|
|
162
|
+
this.errors.map(e => _logger.Logger.error(this.scope, e.errorMessage));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Emit in console all the warnings
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
emitWarnings() {
|
|
171
|
+
if (this.hasWarnings()) {
|
|
172
|
+
this.warnings.map(w => _logger.Logger.warn(this.scope, w.warningMessage));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Emit in console errors/warnings
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
emit() {
|
|
181
|
+
this.emitErrors();
|
|
182
|
+
this.emitWarnings();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Check if v is a func
|
|
188
|
+
* @param v
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
exports.ValidationResult = ValidationResult;
|
|
193
|
+
|
|
194
|
+
function isFunc(v) {
|
|
195
|
+
return typeof v === 'function';
|
|
196
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
exports.loadLocaleData = loadLocaleData;
|
|
6
|
+
|
|
7
|
+
var _Locale = require("../constants/Locale");
|
|
8
|
+
|
|
9
|
+
var _reactI18n = _interopRequireDefault(require("@selfcommunity/react-i18n"));
|
|
10
|
+
|
|
11
|
+
var _reactIntl = require("react-intl");
|
|
12
|
+
|
|
13
|
+
var _logger = require("./logger");
|
|
14
|
+
|
|
15
|
+
var _Errors = require("../constants/Errors");
|
|
16
|
+
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Load Locale Data
|
|
21
|
+
*/
|
|
22
|
+
function loadLocaleData(locale, settings) {
|
|
23
|
+
let _locale = locale;
|
|
24
|
+
let locales = settings.locale && settings.locale.messages ? settings.locale.messages : _reactI18n.default;
|
|
25
|
+
|
|
26
|
+
if (!locales[_locale]) {
|
|
27
|
+
_locale = _Locale.DEFAULT_LANGUAGE_UI;
|
|
28
|
+
|
|
29
|
+
if (settings.messages) {
|
|
30
|
+
_logger.Logger.warn(_Errors.SCOPE_SC_CORE, `Locale ${_locale} not found in messages configuration. Fallback to 'en'.`);
|
|
31
|
+
} else {
|
|
32
|
+
_logger.Logger.warn(_Errors.SCOPE_SC_CORE, `Locale ${_locale} not found in sc-i18n package. Fallback to 'en'.`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
return {
|
|
38
|
+
messages: locales[_locale],
|
|
39
|
+
locale: _locale
|
|
40
|
+
};
|
|
41
|
+
} catch (e) {
|
|
42
|
+
if (settings.messages) {
|
|
43
|
+
locales = _reactI18n.default;
|
|
44
|
+
|
|
45
|
+
_logger.Logger.error(_Errors.SCOPE_SC_CORE, `Configuration Locale.messages doesn't contains ${_locale}. Fallback to 'en' of 'sc-i18n'`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
messages: locales[_Locale.LOCALE_EN],
|
|
50
|
+
locale: _Locale.DEFAULT_LANGUAGE_UI
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var _default = _reactIntl.createIntl;
|
|
56
|
+
exports.default = _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.Logger = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Emit styled message
|
|
8
|
+
*/
|
|
9
|
+
class Logger {
|
|
10
|
+
static info(scope, message) {
|
|
11
|
+
console.info(`%c[${scope}]`, 'color:#008080', ` ${message}`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static warn(scope, message) {
|
|
15
|
+
console.warn(`%c[${scope}]`, 'color:#008080', ` ${message}`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static error(scope, message) {
|
|
19
|
+
console.error(`%c[${scope}]`, 'color:#008080', ` ${message}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static log(scope, message) {
|
|
23
|
+
console.log(`%c[${scope}]`, 'color:#008080', ` ${message}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static debug(scope, message) {
|
|
27
|
+
console.debug(`%c[${scope}]`, 'color:#008080', ` ${message}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.Logger = Logger;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.isObject = isObject;
|
|
5
|
+
exports.mergeDeep = mergeDeep;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Check if v is an object
|
|
9
|
+
* @param v
|
|
10
|
+
*/
|
|
11
|
+
function isObject(v) {
|
|
12
|
+
return typeof v === 'object' && !Array.isArray(v) && v !== null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Perfrom deep merge of two objects (not a shallow merge)
|
|
16
|
+
* @param target
|
|
17
|
+
* @param source
|
|
18
|
+
* @return {*}
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
function mergeDeep(target, source) {
|
|
23
|
+
let output = Object.assign({}, target);
|
|
24
|
+
|
|
25
|
+
if (isObject(target) && isObject(source)) {
|
|
26
|
+
Object.keys(source).forEach(key => {
|
|
27
|
+
if (isObject(source[key])) {
|
|
28
|
+
if (!(key in target)) {
|
|
29
|
+
Object.assign(output, {
|
|
30
|
+
[key]: source[key]
|
|
31
|
+
});
|
|
32
|
+
} else {
|
|
33
|
+
output[key] = mergeDeep(target[key], source[key]);
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
Object.assign(output, {
|
|
37
|
+
[key]: source[key]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return output;
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.parseJwt = parseJwt;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Extract from a jwt token payload
|
|
8
|
+
* @param token
|
|
9
|
+
*/
|
|
10
|
+
function parseJwt(token) {
|
|
11
|
+
let base64Url = token.split('.')[1];
|
|
12
|
+
let base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
13
|
+
let jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
|
|
14
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
15
|
+
}).join(''));
|
|
16
|
+
return JSON.parse(jsonPayload);
|
|
17
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.camelCase = camelCase;
|
|
5
|
+
exports.capitalize = capitalize;
|
|
6
|
+
exports.isString = isString;
|
|
7
|
+
exports.stripHtml = stripHtml;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Check if v is a string
|
|
11
|
+
* @param v
|
|
12
|
+
*/
|
|
13
|
+
function isString(v) {
|
|
14
|
+
return typeof v === 'string' || v instanceof String;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Capitalize a string
|
|
18
|
+
* @param str
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
function capitalize(str) {
|
|
23
|
+
let strVal = '';
|
|
24
|
+
let strArr = str.split(' ');
|
|
25
|
+
|
|
26
|
+
for (let chr = 0; chr < strArr.length; chr++) {
|
|
27
|
+
strVal += strArr[chr].substring(0, 1).toUpperCase() + strArr[chr].substring(1, strArr[chr].length);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return strVal;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* CamelCase a string
|
|
34
|
+
* @param str
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
function camelCase(str) {
|
|
39
|
+
// Lower cases the string
|
|
40
|
+
return str.toLowerCase() // Replaces any - or _ characters with a space
|
|
41
|
+
.replace(/[-_]+/g, ' ') // Removes any non alphanumeric characters
|
|
42
|
+
.replace(/[^\w\s]/g, '') // Uppercases the first character in each group immediately following a space
|
|
43
|
+
// (delimited by spaces)
|
|
44
|
+
.replace(/ (.)/g, $1 => {
|
|
45
|
+
return $1.toUpperCase();
|
|
46
|
+
}) // Removes spaces
|
|
47
|
+
.replace(/ /g, '');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Stripe html tags from a string
|
|
51
|
+
* @param str
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
function stripHtml(str) {
|
|
56
|
+
return str.replace(/<[^>]*>?/gm, '').trim();
|
|
57
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.urlReplacer = exports.isValidUrls = exports.isValidUrl = exports.getDomain = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Utility Url Replacer
|
|
8
|
+
* @param path
|
|
9
|
+
*/
|
|
10
|
+
const urlReplacer = path => {
|
|
11
|
+
const replacer = function replacer(tpl, data) {
|
|
12
|
+
const re = /\$\(([^)]+)?\)/g;
|
|
13
|
+
let match = re.exec(tpl);
|
|
14
|
+
|
|
15
|
+
while (match) {
|
|
16
|
+
tpl = tpl.replace(match[0], data[match[1]]);
|
|
17
|
+
re.lastIndex = 0;
|
|
18
|
+
match = re.exec(tpl);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return tpl;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return params => replacer(path, params);
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Get domain
|
|
28
|
+
* @param url
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
exports.urlReplacer = urlReplacer;
|
|
33
|
+
|
|
34
|
+
const getDomain = url => {
|
|
35
|
+
// eslint-disable-next-line no-useless-escape,@typescript-eslint/prefer-regexp-exec
|
|
36
|
+
const matches = url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
|
|
37
|
+
|
|
38
|
+
if (matches && matches[1]) {
|
|
39
|
+
return matches[1];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return '';
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Check a str is a valid url pattern
|
|
46
|
+
* @param url
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
exports.getDomain = getDomain;
|
|
51
|
+
|
|
52
|
+
const isValidUrl = url => {
|
|
53
|
+
const regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/;
|
|
54
|
+
return regexp.test(url);
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Check a str is a valid list of urls separated by delimiter
|
|
58
|
+
* @param value
|
|
59
|
+
* @param delimiter
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
exports.isValidUrl = isValidUrl;
|
|
64
|
+
|
|
65
|
+
const isValidUrls = (value, delimiter) => {
|
|
66
|
+
const urls = value.trim().split(delimiter);
|
|
67
|
+
return urls.every(isValidUrl);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.isValidUrls = isValidUrls;
|