@selfcommunity/react-core 0.7.0-alpha.8 → 0.7.0-mui7.17
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/cjs/components/provider/SCLocaleProvider/index.d.ts +1 -1
- package/lib/cjs/components/provider/SCThemeProvider/index.d.ts +1 -1
- package/lib/cjs/components/router/index.d.ts +2 -2
- package/lib/cjs/constants/Cache.d.ts +6 -0
- package/lib/cjs/constants/Cache.js +9 -1
- package/lib/cjs/constants/Preferences.d.ts +2 -0
- package/lib/cjs/constants/Preferences.js +7 -2
- package/lib/cjs/hooks/useFetchMenuFooter.d.ts +5 -0
- package/lib/cjs/hooks/useFetchMenuFooter.js +36 -0
- package/lib/cjs/hooks/useSCFeature.d.ts +22 -0
- package/lib/cjs/hooks/useSCFeature.js +38 -0
- package/lib/cjs/hooks/useSCFetchUsers.d.ts +3 -4
- package/lib/cjs/hooks/useSCFetchUsers.js +15 -44
- package/lib/cjs/hooks/useSCPreference.d.ts +36 -0
- package/lib/cjs/hooks/useSCPreference.js +69 -0
- package/lib/cjs/hooks/useSCPreferencesAndFeaturesEnabled.d.ts +17 -0
- package/lib/cjs/hooks/useSCPreferencesAndFeaturesEnabled.js +35 -0
- package/lib/cjs/index.d.ts +5 -2
- package/lib/cjs/index.js +12 -3
- package/lib/cjs/utils/hooks/usePreviousValue.d.ts +1 -1
- package/lib/cjs/utils/hooks/usePreviousValue.js +1 -1
- package/lib/esm/components/provider/SCLocaleProvider/index.d.ts +1 -1
- package/lib/esm/components/provider/SCThemeProvider/index.d.ts +1 -1
- package/lib/esm/components/router/index.d.ts +2 -2
- package/lib/esm/constants/Cache.d.ts +6 -0
- package/lib/esm/constants/Cache.js +6 -0
- package/lib/esm/constants/Preferences.d.ts +2 -0
- package/lib/esm/constants/Preferences.js +5 -0
- package/lib/esm/hooks/useFetchMenuFooter.d.ts +5 -0
- package/lib/esm/hooks/useFetchMenuFooter.js +33 -0
- package/lib/esm/hooks/useSCFeature.d.ts +22 -0
- package/lib/esm/hooks/useSCFeature.js +33 -0
- package/lib/esm/hooks/useSCFetchUsers.d.ts +3 -4
- package/lib/esm/hooks/useSCFetchUsers.js +16 -45
- package/lib/esm/hooks/useSCPreference.d.ts +36 -0
- package/lib/esm/hooks/useSCPreference.js +65 -0
- package/lib/esm/hooks/useSCPreferencesAndFeaturesEnabled.d.ts +17 -0
- package/lib/esm/hooks/useSCPreferencesAndFeaturesEnabled.js +32 -0
- package/lib/esm/index.d.ts +5 -2
- package/lib/esm/index.js +5 -2
- package/lib/esm/utils/hooks/usePreviousValue.d.ts +1 -1
- package/lib/esm/utils/hooks/usePreviousValue.js +1 -1
- package/lib/umd/0.js +2 -0
- package/lib/umd/{440.js.LICENSE.txt → 0.js.LICENSE.txt} +2 -0
- package/lib/umd/react-core.js +1 -1
- package/lib/umd/react-core.js.LICENSE.txt +1 -1
- package/package.json +12 -12
- package/lib/cjs/hooks/useSCPreferenceEnabled.d.ts +0 -6
- package/lib/cjs/hooks/useSCPreferenceEnabled.js +0 -16
- package/lib/esm/hooks/useSCPreferenceEnabled.d.ts +0 -6
- package/lib/esm/hooks/useSCPreferenceEnabled.js +0 -13
- package/lib/umd/440.js +0 -2
|
@@ -33,7 +33,7 @@ export default function SCLocaleProvider({ children }: {
|
|
|
33
33
|
* Export hoc to inject the base theme to components
|
|
34
34
|
* @param Component
|
|
35
35
|
*/
|
|
36
|
-
export declare const withSCLocale: (Component: any) => (props: any) => JSX.Element;
|
|
36
|
+
export declare const withSCLocale: (Component: any) => (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
37
37
|
/**
|
|
38
38
|
* Let's only export the `useSCLocale` hook instead of the context.
|
|
39
39
|
* We only want to use the hook directly and never the context component.
|
|
@@ -40,7 +40,7 @@ export default function SCThemeProvider({ children }: {
|
|
|
40
40
|
* Export hoc to inject the base theme to components
|
|
41
41
|
* @param Component
|
|
42
42
|
*/
|
|
43
|
-
export declare const withSCTheme: (Component: any) => (props: any) => JSX.Element;
|
|
43
|
+
export declare const withSCTheme: (Component: any) => (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
44
44
|
/**
|
|
45
45
|
* Let's only export the `useSCTheme` hook instead of the context.
|
|
46
46
|
* We only want to use the hook directly and never the context component.
|
|
@@ -26,8 +26,8 @@ const scRoutingContext: SCRoutingContextType = useSCRouting();
|
|
|
26
26
|
|
|
27
27
|
:::
|
|
28
28
|
*/
|
|
29
|
-
declare const _default: React.ForwardRefExoticComponent<
|
|
29
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<{
|
|
30
30
|
[x: string]: any;
|
|
31
31
|
children: any;
|
|
32
|
-
},
|
|
32
|
+
}, "ref"> & React.RefAttributes<unknown>>;
|
|
33
33
|
export default _default;
|
|
@@ -82,6 +82,12 @@ export declare const getPaymentProductObjectCacheKey: (id: any) => string;
|
|
|
82
82
|
/** PAYMENT PRODUCT OBJECT **/
|
|
83
83
|
export declare const PAYMENT_ORDER_OBJECT_CACHE_PREFIX_KEY = "_pord_";
|
|
84
84
|
export declare const getPaymentOrderObjectCacheKey: (id: any) => string;
|
|
85
|
+
/** USER OBJECT **/
|
|
86
|
+
export declare const USER_OBJECT_CACHE_PREFIX_KEY = "_usr_";
|
|
87
|
+
export declare const getUserObjectCacheKey: (id: number) => string;
|
|
88
|
+
/** USERS OBJECT **/
|
|
89
|
+
export declare const USERS_OBJECT_CACHE_PREFIX_KEY = "_usrs_";
|
|
90
|
+
export declare const getUsersObjectCacheKey: (search?: string) => string;
|
|
85
91
|
/** TOOLS */
|
|
86
92
|
export declare const CATEGORIES_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = "_cListWidget_";
|
|
87
93
|
export declare const CATEGORIES_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = "_cFolWidget_";
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PM_SNIPPETS_OBJECT_CACHE_PREFIX_KEY = exports.getAdvObjectCacheKey = exports.ADV_OBJECT_CACHE_PREFIX_KEY = exports.getFeedSPCacheKey = exports.FEED_CACHE_SP_KEY = exports.getVirtualizedScrollStateCacheKey = exports.VIRTUALIZED_SCROLL_STATE_CACHE_PREFIX_KEY = exports.getStateFeedCacheKey = exports.FEED_STATE_CACHE_PREFIX_KEY = exports.getFeedCacheKey = exports.FEED_CACHE_PREFIX_KEY = exports.getBroadcastMessagesObjectCacheKey = exports.BROADCAST_MESSAGES_OBJECT_CACHE_PREFIX_KEY = exports.getContributorsCachePrefixKeys = exports.getContributorsCacheKey = exports.CONTRIBUTORS_CACHE_PREFIX_KEY = exports.getIncubatorObjectCacheKey = exports.INCUBATOR_OBJECT_CACHE_PREFIX_KEY = exports.getGroupsObjectCacheKey = exports.GROUPS_OBJECT_CACHE_PREFIX_KEY = exports.getGroupObjectCacheKey = exports.GROUP_OBJECT_CACHE_PREFIX_KEY = exports.getLiveStreamObjectCacheKey = exports.LIVESTREAM_OBJECT_CACHE_PREFIX_KEY = exports.getEventsObjectCacheKey = exports.EVENTS_OBJECT_CACHE_PREFIX_KEY = exports.getEventObjectCacheKey = exports.EVENT_OBJECT_CACHE_PREFIX_KEY = exports.getLessonObjectCacheKey = exports.LESSON_OBJECT_CACHE_PREFIX_KEY = exports.getCoursesObjectCacheKey = exports.COURSES_OBJECT_CACHE_PREFIX_KEY = exports.getCourseObjectCacheKey = exports.COURSE_OBJECT_CACHE_PREFIX_KEY = exports.getCategoryObjectCacheKey = exports.CATEGORY_OBJECT_CACHE_PREFIX_KEY = exports.getCategoriesObjectCacheKey = exports.CATEGORIES_OBJECT_CACHE_PREFIX_KEY = exports.getLessonCommentsCachePrefixKeys = exports.getLessonCommentsCacheKey = exports.LESSON_COMMENTS_CACHE_PREFIX_KEY = exports.getLessonCommentCacheKey = exports.LESSON_COMMENT_CACHE_PREFIX_KEY = exports.getCommentObjectsCachePrefixKeys = exports.getCommentObjectsCacheKey = exports.COMMENT_OBJECTS_CACHE_PREFIX_KEY = exports.getCommentObjectCacheKey = exports.COMMENT_OBJECT_CACHE_PREFIX_KEY = exports.getFeedObjectCacheKey = exports.FEED_OBJECT_CACHE_PREFIX_KEY = void 0;
|
|
7
|
-
exports.getWidgetStateCacheKey = exports.GROUPS_SUBSCRIBED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.GROUPS_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = exports.GROUP_REQUESTS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.GROUP_MEMBERS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.POLL_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.INCUBATOR_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.INCUBATOR_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = exports.PEOPLE_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.TRENDING_PEOPLE_TOOLS_STATE_CACHE_PREFIX_KEY = exports.RELATED_FEED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.TRENDING_FEED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_CONNECTIONS_REQUESTS_SENT_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_CONNECTIONS_REQUESTS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_CONNECTIONS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.EVENT_MEDIA_STATE_CACHE_PREFIX_KEY = exports.USER_LIVE_STREAM_CACHE_PREFIX_KEY = exports.USER_REQUESTS_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_INVITED_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_COMMENTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.USERS_REQUESTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.STUDENTS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.USERS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.USER_PARTECIPANTS_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_OTHER_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_CREATED_COURSES_STATE_CACHE_PREFIX_KEY = exports.USER_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_FOLLOWERS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.CATEGORIES_POPULAR_TOOLS_STATE_CACHE_PREFIX_KEY = exports.CATEGORIES_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.CATEGORIES_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.CATEGORIES_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = exports.getPaymentOrderObjectCacheKey = exports.PAYMENT_ORDER_OBJECT_CACHE_PREFIX_KEY = exports.getPaymentProductObjectCacheKey = exports.PAYMENT_PRODUCT_OBJECT_CACHE_PREFIX_KEY = exports.getPmSnippetObjectCacheKey = exports.PM_SNIPPET_OBJECT_CACHE_PREFIX_KEY = exports.getPmSnippetsObjectCacheKey = void 0;
|
|
7
|
+
exports.getWidgetStateCacheKey = exports.GROUPS_SUBSCRIBED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.GROUPS_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = exports.GROUP_REQUESTS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.GROUP_MEMBERS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.POLL_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.INCUBATOR_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.INCUBATOR_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = exports.PEOPLE_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.TRENDING_PEOPLE_TOOLS_STATE_CACHE_PREFIX_KEY = exports.RELATED_FEED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.TRENDING_FEED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_CONNECTIONS_REQUESTS_SENT_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_CONNECTIONS_REQUESTS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_CONNECTIONS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.EVENT_MEDIA_STATE_CACHE_PREFIX_KEY = exports.USER_LIVE_STREAM_CACHE_PREFIX_KEY = exports.USER_REQUESTS_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_INVITED_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_COMMENTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.USERS_REQUESTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.STUDENTS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.USERS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.USER_PARTECIPANTS_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_OTHER_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_CREATED_COURSES_STATE_CACHE_PREFIX_KEY = exports.USER_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_FOLLOWERS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.CATEGORIES_POPULAR_TOOLS_STATE_CACHE_PREFIX_KEY = exports.CATEGORIES_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.CATEGORIES_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.CATEGORIES_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = exports.getUsersObjectCacheKey = exports.USERS_OBJECT_CACHE_PREFIX_KEY = exports.getUserObjectCacheKey = exports.USER_OBJECT_CACHE_PREFIX_KEY = exports.getPaymentOrderObjectCacheKey = exports.PAYMENT_ORDER_OBJECT_CACHE_PREFIX_KEY = exports.getPaymentProductObjectCacheKey = exports.PAYMENT_PRODUCT_OBJECT_CACHE_PREFIX_KEY = exports.getPmSnippetObjectCacheKey = exports.PM_SNIPPET_OBJECT_CACHE_PREFIX_KEY = exports.getPmSnippetsObjectCacheKey = void 0;
|
|
8
8
|
/** FEED OBJECT **/
|
|
9
9
|
exports.FEED_OBJECT_CACHE_PREFIX_KEY = '_fo_';
|
|
10
10
|
const getFeedObjectCacheKey = (id, type) => `${exports.FEED_OBJECT_CACHE_PREFIX_KEY}${type}_${id}`;
|
|
@@ -120,6 +120,14 @@ exports.getPaymentProductObjectCacheKey = getPaymentProductObjectCacheKey;
|
|
|
120
120
|
exports.PAYMENT_ORDER_OBJECT_CACHE_PREFIX_KEY = '_pord_';
|
|
121
121
|
const getPaymentOrderObjectCacheKey = (id) => `${exports.PAYMENT_ORDER_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
122
122
|
exports.getPaymentOrderObjectCacheKey = getPaymentOrderObjectCacheKey;
|
|
123
|
+
/** USER OBJECT **/
|
|
124
|
+
exports.USER_OBJECT_CACHE_PREFIX_KEY = '_usr_';
|
|
125
|
+
const getUserObjectCacheKey = (id) => `${exports.USER_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
126
|
+
exports.getUserObjectCacheKey = getUserObjectCacheKey;
|
|
127
|
+
/** USERS OBJECT **/
|
|
128
|
+
exports.USERS_OBJECT_CACHE_PREFIX_KEY = '_usrs_';
|
|
129
|
+
const getUsersObjectCacheKey = (search) => search ? `${exports.USERS_OBJECT_CACHE_PREFIX_KEY}${encodeURIComponent(search)}` : `${exports.USERS_OBJECT_CACHE_PREFIX_KEY}`;
|
|
130
|
+
exports.getUsersObjectCacheKey = getUsersObjectCacheKey;
|
|
123
131
|
/** TOOLS */
|
|
124
132
|
exports.CATEGORIES_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = '_cListWidget_';
|
|
125
133
|
exports.CATEGORIES_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = '_cFolWidget_';
|
|
@@ -161,6 +161,8 @@ export declare const CONFIGURATIONS_SCHEDULED_POSTS_ENABLED: string;
|
|
|
161
161
|
export declare const CONFIGURATIONS_POST_CATEGORY_REQUIRED_ENABLED: string;
|
|
162
162
|
export declare const CONFIGURATIONS_POST_ADDRESSING_REQUIRED_ENABLED: string;
|
|
163
163
|
export declare const CONFIGURATIONS_POST_USER_ADDRESSING_ENABLED: string;
|
|
164
|
+
export declare const CONFIGURATIONS_CONTACT_API_ENABLED: string;
|
|
165
|
+
export declare const CONFIGURATIONS_ACCEPTED_MEDIA_MIMETYPES: string;
|
|
164
166
|
/**
|
|
165
167
|
* PROVIDERS
|
|
166
168
|
*/
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ADDONS_SHARE_POST_ON_FACEBOOK_ENABLED = exports.ADDONS_POST_GEOLOCATION_ENABLED = exports.ADDONS_REGISTRATION_WIZARD = exports.ADDONS_POLLS_ENABLED = exports.ADDONS_LOYALTY_POINTS_COLLECTION = exports.ADDONS_INCUBATOR_SUBSCRIBERS = exports.ADDONS_INCUBATOR_ENABLED = exports.ADDONS_CLOSED_COMMUNITY = exports.ADDONS_AFFINITY_ENABLED = exports.POINTS_DAILY_VISIT = exports.POINTS_APP_USED = exports.POINTS_SOCIAL_SHARE = exports.POINTS_CONNECTION_OR_FOLLOWER = exports.POINTS_RECEIVE_VOTE = exports.POINTS_MAKE_COMMENT = exports.POINTS_MAKE_POST = exports.POINTS_MAKE_DISCUSSION = exports.LOYALTY_PRIZE_C_IMAGE = exports.LOYALTY_PRIZE_B_IMAGE = exports.LOYALTY_PRIZE_A_IMAGE = exports.STAFF_STAFF_BADGE_LABEL = exports.STAFF_STAFF_BADGE_ICON = exports.IMAGES_ERRORPAGES_IMAGE = exports.IMAGES_ERROR_503 = exports.IMAGES_ERROR_404 = exports.IMAGES_USER_DEFAULT_COVER = exports.IMAGES_APP_ICON = exports.COVERS_VISIBILITY = exports.COVERS_COVER_4_HP_M1920 = exports.COVERS_COVER_3_HP_M1920 = exports.COVERS_COVER_2_HP_M1920 = exports.COVERS_COVER_1_HP_M1920 = exports.COLORS_COLORFONTSECONDARY = exports.COLORS_COLORFONT = exports.COLORS_NAVBARBACK = exports.COLORS_COLORSECONDARY = exports.COLORS_COLORPRIMARY = exports.COLORS_COLORBACK = exports.LOGO_NAVBAR_LOGO_MOBILE = exports.LOGO_NAVBAR_LOGO = exports.STYLE_FONT_FAMILY = exports.TEXT_ERROR_PAGES_SUBTITLE = exports.TEXT_ERROR_PAGES_TITLE = exports.TEXT_APPLICATION_COPYRIGHT = exports.TEXT_APPLICATION_SLOGAN2 = exports.TEXT_APPLICATION_SLOGAN1 = exports.TEXT_APPLICATION_NAME = exports.DEFAULT_GLOBAL_PREFERENCES_OPTION = exports.GLOBAL_PREFERENCES_OPTION = exports.PREFERENCES_OPTION = void 0;
|
|
4
4
|
exports.CONFIGURATIONS_EVENTS_ENABLED = exports.CONFIGURATIONS_GROUPS_PRIVATE_ENABLED = exports.CONFIGURATIONS_GROUPS_VISIBILITY_ENABLED = exports.CONFIGURATIONS_GROUPS_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_GROUPS_ENABLED = exports.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE = exports.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL = exports.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT = exports.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_ENABLED = exports.CONFIGURATIONS_GDPR_SIGNUP_ACCEPT_HTML = exports.CONFIGURATIONS_GDPR_COOKIE_CONSENT_EXTERNAL_HTML = exports.CONFIGURATIONS_TAG_MANAGER_CONTAINER_ID = exports.CONFIGURATIONS_USER_METADATA_DEFINITIONS = exports.CONFIGURATIONS_APP_URL = exports.CONFIGURATIONS_URL_TEMPLATE_LIVE_STREAM = exports.CONFIGURATIONS_URL_TEMPLATE_INCUBATOR = exports.CONFIGURATIONS_URL_TEMPLATE_USER_PRIVATE_MESSAGES = exports.CONFIGURATIONS_URL_TEMPLATE_NOTIFICATIONS = exports.CONFIGURATIONS_URL_TEMPLATE_USER_PROFILE_SETTINGS = exports.CONFIGURATIONS_URL_TEMPLATE_USER_PROFILE = exports.CONFIGURATIONS_URL_TEMPLATE_CATEGORIES_LIST = exports.CONFIGURATIONS_URL_TEMPLATE_CATEGORY = exports.CONFIGURATIONS_URL_TEMPLATE_COMMENT = exports.CONFIGURATIONS_URL_TEMPLATE_STATUS = exports.CONFIGURATIONS_URL_TEMPLATE_DISCUSSION = exports.CONFIGURATIONS_URL_TEMPLATE_POST = exports.CONFIGURATIONS_URL_TEMPLATE_VERIFY_EMAIL = exports.CONFIGURATIONS_URL_TEMPLATE_PASSWORD_RECOVER = exports.CONFIGURATIONS_URL_TEMPLATE_EMAIL_UNSUBSCRIBE = exports.CONFIGURATIONS_URL_TEMPLATE_EMAIL_SETTINGS = exports.CONFIGURATIONS_STATUS_TYPE_ENABLED = exports.CONFIGURATIONS_DISCUSSION_TYPE_ENABLED = exports.CONFIGURATIONS_POST_TYPE_ENABLED = exports.CONFIGURATIONS_USERS_APPROVAL_ENABLED = exports.CONFIGURATIONS_CONTENT_AVAILABILITY = exports.CONFIGURATIONS_STREAM_QUALITY = exports.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_PEOPLE_SEARCH_ENABLED = exports.CONFIGURATIONS_MANUAL_CATEGORIES_ORDER_ENABLED = exports.CONFIGURATIONS_HOME_STREAM_ORDER_BY = exports.CONFIGURATIONS_EXPLORE_STREAM_ORDER_BY = exports.CONFIGURATIONS_EXPLORE_STREAM_ENABLED = exports.CONFIGURATIONS_FOLLOW_ENABLED = exports.CONFIGURATIONS_CONNECTION_ENABLED = exports.ADVERTISING_CUSTOM_ADV_ONLY_FOR_ANONYMOUS_USERS_ENABLED = exports.ADVERTISING_CUSTOM_ADV_ENABLED = exports.ADDONS_SHARE_POST_ENABLED = exports.ADDONS_PRIVATE_MESSAGES_ENABLED = exports.ADDONS_SHARE_POST_ON_LINKEDIN_ENABLED = exports.ADDONS_SHARE_POST_ON_TWITTER_ENABLED = void 0;
|
|
5
|
-
exports.
|
|
6
|
-
exports.DATA_TYPES = exports.getPreference = exports.getPreferenceName = void 0;
|
|
5
|
+
exports.STATIC_STACKID = exports.STATIC_ENVIRONMENT = exports.WEBMASTER_META_DESCRIPTION = exports.WEBMASTER_META_TITLE_HOME_NOT_LOGGED = exports.WEBMASTER_META_ROBOTS = exports.PROVIDERS_WEB_PUSH_ENABLED = exports.PROVIDERS_WEB_PUSH_PUBLIC_KEY = exports.PROVIDERS_GOOGLE_APP_SECRET = exports.PROVIDERS_GOOGLE_APP_KEY = exports.PROVIDERS_GOOGLE_SIGNIN_ENABLED = exports.PROVIDERS_GOOGLE_GEOCODING_API_KEY = exports.PROVIDERS_TWITTER_APP_SECRET = exports.PROVIDERS_TWITTER_APP_KEY = exports.PROVIDERS_TWITTER_SIGNIN_ENABLED = exports.PROVIDERS_LINKEDIN_APP_SECRET = exports.PROVIDERS_LINKEDIN_APP_KEY = exports.PROVIDERS_LINKEDIN_SIGNIN_ENABLED = exports.PROVIDERS_FACEBOOK_APP_SECRET = exports.PROVIDERS_FACEBOOK_APP_KEY = exports.PROVIDERS_FACEBOOK_SIGNIN_ENABLED = exports.PROVIDERS_APP_URL_ON_GOOGLE_PLAY = exports.PROVIDERS_APP_URL_ON_APP_STORE = exports.CONFIGURATIONS_ACCEPTED_MEDIA_MIMETYPES = exports.CONFIGURATIONS_CONTACT_API_ENABLED = exports.CONFIGURATIONS_POST_USER_ADDRESSING_ENABLED = exports.CONFIGURATIONS_POST_ADDRESSING_REQUIRED_ENABLED = exports.CONFIGURATIONS_POST_CATEGORY_REQUIRED_ENABLED = exports.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED = exports.CONFIGURATIONS_VIDEO_PLAY_TRACKING_DELAY_SECONDS = exports.CONFIGURATIONS_VIDEO_AUTOPLAY_ENABLED = exports.CONFIGURATIONS_SIDEBAR_SHOW_ALL_CATEGORIES_ENABLED = exports.CONFIGURATIONS_COMMENTS_ENABLED = exports.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED = exports.CONFIGURATIONS_CONTEXT_MENU_ENABLED = exports.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID = exports.CONFIGURATIONS_PAYMENTS_ENABLED = exports.CONFIGURATIONS_SUBSCRIPTION_TIER = exports.CONFIGURATIONS_LIVE_VIDEO_CONFERENCE_ENABLED = exports.CONFIGURATIONS_LIVE_STREAM_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_LIVE_STREAM_ENABLED = exports.CONFIGURATIONS_ONBOARDING_HIDDEN = exports.CONFIGURATIONS_ONBOARDING_ENABLED = exports.CONFIGURATIONS_COURSES_ADVANCED_ENABLED = exports.CONFIGURATIONS_COURSES_PRIVATE_ENABLED = exports.CONFIGURATIONS_COURSES_VISIBILITY_ENABLED = exports.CONFIGURATIONS_COURSES_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_COURSES_ENABLED = exports.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED = exports.CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED = exports.CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED = void 0;
|
|
6
|
+
exports.DATA_TYPES = exports.getPreference = exports.getPreferenceName = exports.getPreferenceSection = exports.STATIC_STRIPE_PUBLIC_KEY = void 0;
|
|
7
7
|
const types_1 = require("@selfcommunity/types");
|
|
8
8
|
/**
|
|
9
9
|
* DEFAULT CONF VALIDATION OPTION
|
|
@@ -168,6 +168,8 @@ exports.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED = `${types_1.SCPreferenceSection.
|
|
|
168
168
|
exports.CONFIGURATIONS_POST_CATEGORY_REQUIRED_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.POST_CATEGORY_REQUIRED_ENABLED}`;
|
|
169
169
|
exports.CONFIGURATIONS_POST_ADDRESSING_REQUIRED_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.POST_ADDRESSING_REQUIRED_ENABLED}`;
|
|
170
170
|
exports.CONFIGURATIONS_POST_USER_ADDRESSING_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.POST_USER_ADDRESSING_ENABLED}`;
|
|
171
|
+
exports.CONFIGURATIONS_CONTACT_API_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.CONTACT_API_ENABLED}`;
|
|
172
|
+
exports.CONFIGURATIONS_ACCEPTED_MEDIA_MIMETYPES = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.ACCEPTED_MEDIA_MIMETYPES}`;
|
|
171
173
|
/**
|
|
172
174
|
* PROVIDERS
|
|
173
175
|
*/
|
|
@@ -344,6 +346,7 @@ exports.DATA_TYPES = {
|
|
|
344
346
|
[exports.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED]: booleanType,
|
|
345
347
|
[exports.CONFIGURATIONS_POST_CATEGORY_REQUIRED_ENABLED]: booleanType,
|
|
346
348
|
[exports.CONFIGURATIONS_POST_ADDRESSING_REQUIRED_ENABLED]: booleanType,
|
|
349
|
+
[exports.CONFIGURATIONS_ACCEPTED_MEDIA_MIMETYPES]: stringType,
|
|
347
350
|
[exports.PROVIDERS_APP_URL_ON_APP_STORE]: stringType,
|
|
348
351
|
[exports.PROVIDERS_APP_URL_ON_GOOGLE_PLAY]: stringType,
|
|
349
352
|
[exports.PROVIDERS_FACEBOOK_SIGNIN_ENABLED]: stringType,
|
|
@@ -367,4 +370,6 @@ exports.DATA_TYPES = {
|
|
|
367
370
|
[exports.STATIC_ENVIRONMENT]: stringType,
|
|
368
371
|
[exports.STATIC_STACKID]: stringType,
|
|
369
372
|
[exports.STATIC_STRIPE_PUBLIC_KEY]: stringType,
|
|
373
|
+
[exports.CONFIGURATIONS_POST_USER_ADDRESSING_ENABLED]: booleanType,
|
|
374
|
+
[exports.CONFIGURATIONS_CONTACT_API_ENABLED]: booleanType,
|
|
370
375
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
4
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Errors_1 = require("../constants/Errors");
|
|
7
|
+
function useFetchMenuFooter(id, menu = null) {
|
|
8
|
+
// STATES
|
|
9
|
+
const [_menu, setMenu] = (0, react_1.useState)(menu);
|
|
10
|
+
const [loading, setLoading] = (0, react_1.useState)(!menu);
|
|
11
|
+
/**
|
|
12
|
+
* Fetches custom pages
|
|
13
|
+
*/
|
|
14
|
+
const fetchMenu = (0, react_1.useCallback)(() => {
|
|
15
|
+
setLoading(true);
|
|
16
|
+
api_services_1.CustomMenuService.getASpecificCustomMenu(id)
|
|
17
|
+
.then((menu) => {
|
|
18
|
+
setMenu(menu);
|
|
19
|
+
})
|
|
20
|
+
.catch((error) => {
|
|
21
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, error);
|
|
22
|
+
})
|
|
23
|
+
.then(() => setLoading(false));
|
|
24
|
+
}, []);
|
|
25
|
+
/**
|
|
26
|
+
* On mount, fetches legal and custom pages
|
|
27
|
+
*/
|
|
28
|
+
(0, react_1.useEffect)(() => {
|
|
29
|
+
if (menu) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
fetchMenu();
|
|
33
|
+
}, [id]);
|
|
34
|
+
return { _menu, loading };
|
|
35
|
+
}
|
|
36
|
+
exports.default = useFetchMenuFooter;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SCFeatureName } from '@selfcommunity/types';
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook to check if the feature is enabled
|
|
4
|
+
* @param featureName - feature name
|
|
5
|
+
* @returns boolean - true if the feature is in the list of features
|
|
6
|
+
*
|
|
7
|
+
* Ex.
|
|
8
|
+
* const isTaggingEnabled = useSCFeatureEnabled(SCFeatureName.TAGGING);
|
|
9
|
+
*/
|
|
10
|
+
export declare function useSCFeatureEnabled(featureName: SCFeatureName): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Custom hook to check if a list of features are enabled
|
|
13
|
+
* @param featureNames - feature names
|
|
14
|
+
* @returns boolean - true if all features are in the features list
|
|
15
|
+
*
|
|
16
|
+
* Ex.
|
|
17
|
+
* const hasRequiredFeatures = useSCFeaturesEnabled([
|
|
18
|
+
* SCFeatureName.TAGGING,
|
|
19
|
+
* SCFeatureName.GROUPING
|
|
20
|
+
* ]);
|
|
21
|
+
*/
|
|
22
|
+
export declare function useSCFeaturesEnabled(featureNames: SCFeatureName[]): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSCFeaturesEnabled = exports.useSCFeatureEnabled = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const SCPreferencesProvider_1 = require("../components/provider/SCPreferencesProvider");
|
|
6
|
+
/**
|
|
7
|
+
* Custom hook to check if the feature is enabled
|
|
8
|
+
* @param featureName - feature name
|
|
9
|
+
* @returns boolean - true if the feature is in the list of features
|
|
10
|
+
*
|
|
11
|
+
* Ex.
|
|
12
|
+
* const isTaggingEnabled = useSCFeatureEnabled(SCFeatureName.TAGGING);
|
|
13
|
+
*/
|
|
14
|
+
function useSCFeatureEnabled(featureName) {
|
|
15
|
+
const { features } = (0, SCPreferencesProvider_1.useSCPreferences)();
|
|
16
|
+
return (0, react_1.useMemo)(() => {
|
|
17
|
+
return Boolean(features && features.includes(featureName));
|
|
18
|
+
}, [features, featureName]);
|
|
19
|
+
}
|
|
20
|
+
exports.useSCFeatureEnabled = useSCFeatureEnabled;
|
|
21
|
+
/**
|
|
22
|
+
* Custom hook to check if a list of features are enabled
|
|
23
|
+
* @param featureNames - feature names
|
|
24
|
+
* @returns boolean - true if all features are in the features list
|
|
25
|
+
*
|
|
26
|
+
* Ex.
|
|
27
|
+
* const hasRequiredFeatures = useSCFeaturesEnabled([
|
|
28
|
+
* SCFeatureName.TAGGING,
|
|
29
|
+
* SCFeatureName.GROUPING
|
|
30
|
+
* ]);
|
|
31
|
+
*/
|
|
32
|
+
function useSCFeaturesEnabled(featureNames) {
|
|
33
|
+
const { features } = (0, SCPreferencesProvider_1.useSCPreferences)();
|
|
34
|
+
return (0, react_1.useMemo)(() => {
|
|
35
|
+
return Boolean(features && featureNames.every((name) => features.includes(name)));
|
|
36
|
+
}, [features, featureNames]);
|
|
37
|
+
}
|
|
38
|
+
exports.useSCFeaturesEnabled = useSCFeaturesEnabled;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { SCUserAutocompleteType } from '@selfcommunity/types';
|
|
2
|
-
import { CacheStrategies } from '@selfcommunity/utils';
|
|
3
2
|
/**
|
|
4
3
|
:::info
|
|
5
4
|
This custom hook is used to fetch users.
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
|
|
8
6
|
:::tip Context can be consumed in this way:
|
|
9
7
|
|
|
10
8
|
```jsx
|
|
@@ -14,7 +12,8 @@ import { CacheStrategies } from '@selfcommunity/utils';
|
|
|
14
12
|
* @param props
|
|
15
13
|
*/
|
|
16
14
|
declare const useSCFetchUsers: (props?: {
|
|
17
|
-
|
|
15
|
+
search: string;
|
|
16
|
+
exclude?: string;
|
|
18
17
|
}) => {
|
|
19
18
|
users: SCUserAutocompleteType[];
|
|
20
19
|
isLoading: boolean;
|
|
@@ -5,28 +5,10 @@ const react_1 = require("react");
|
|
|
5
5
|
const Errors_1 = require("../constants/Errors");
|
|
6
6
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
7
7
|
const utils_1 = require("@selfcommunity/utils");
|
|
8
|
-
const init = { users: [], isLoading: true };
|
|
9
|
-
// --- Cache keys
|
|
10
|
-
const getUsersObjectCacheKey = () => '__sc_usersAct_object__';
|
|
11
|
-
const getUserObjectCacheKey = (id) => `__sc_userAct_object__${id}`;
|
|
12
|
-
// Hydrate cache
|
|
13
|
-
const hydrate = (ids) => {
|
|
14
|
-
if (!ids)
|
|
15
|
-
return null;
|
|
16
|
-
const users = ids.map((id) => {
|
|
17
|
-
const __userCacheKey = getUserObjectCacheKey(id);
|
|
18
|
-
return utils_1.LRUCache.get(__userCacheKey);
|
|
19
|
-
});
|
|
20
|
-
if (users.filter((u) => !u).length > 0) {
|
|
21
|
-
return null; // revalidate cache
|
|
22
|
-
}
|
|
23
|
-
return users;
|
|
24
|
-
};
|
|
25
8
|
/**
|
|
26
9
|
:::info
|
|
27
10
|
This custom hook is used to fetch users.
|
|
28
|
-
|
|
29
|
-
|
|
11
|
+
|
|
30
12
|
:::tip Context can be consumed in this way:
|
|
31
13
|
|
|
32
14
|
```jsx
|
|
@@ -36,44 +18,33 @@ const hydrate = (ids) => {
|
|
|
36
18
|
* @param props
|
|
37
19
|
*/
|
|
38
20
|
const useSCFetchUsers = (props) => {
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
// State
|
|
43
|
-
const users = cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? hydrate(utils_1.LRUCache.get(__usersCacheKey, null)) : null;
|
|
44
|
-
const [data, setData] = (0, react_1.useState)(users !== null ? { users, isLoading: false } : init);
|
|
45
|
-
/**
|
|
46
|
-
* Fetch all users
|
|
47
|
-
*/
|
|
48
|
-
const fetchUsers = (next = api_services_1.Endpoints.UserAutocomplete.url()) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const { search = '', exclude = '' } = props || {};
|
|
22
|
+
const [data, setData] = (0, react_1.useState)({ users: [], isLoading: false });
|
|
23
|
+
const fetchUsers = (next = api_services_1.Endpoints.UserAutocomplete.url(), searchParam, excludeParam) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
49
24
|
const response = yield api_services_1.http.request({
|
|
50
25
|
url: next,
|
|
51
26
|
method: api_services_1.Endpoints.UserAutocomplete.method,
|
|
27
|
+
params: Object.assign({ search: searchParam }, (excludeParam && { exclude: excludeParam })),
|
|
52
28
|
});
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
29
|
+
const result = response.data;
|
|
30
|
+
if (result.next) {
|
|
31
|
+
return result.results.concat(yield fetchUsers(result.next, searchParam, excludeParam));
|
|
56
32
|
}
|
|
57
|
-
return
|
|
33
|
+
return result.results;
|
|
58
34
|
});
|
|
59
35
|
(0, react_1.useEffect)(() => {
|
|
60
|
-
if (
|
|
36
|
+
if (!search)
|
|
61
37
|
return;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
setData({ users: data, isLoading: false });
|
|
66
|
-
utils_1.LRUCache.set(__usersCacheKey, data.map((u) => {
|
|
67
|
-
const __userCacheKey = getUserObjectCacheKey(u.id);
|
|
68
|
-
utils_1.LRUCache.set(__userCacheKey, u);
|
|
69
|
-
return u.id;
|
|
70
|
-
}));
|
|
38
|
+
fetchUsers(undefined, search, exclude)
|
|
39
|
+
.then((users) => {
|
|
40
|
+
setData({ users, isLoading: false });
|
|
71
41
|
})
|
|
72
42
|
.catch((error) => {
|
|
73
43
|
console.error(error);
|
|
74
44
|
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, 'Unable to retrieve users');
|
|
45
|
+
setData((prev) => (Object.assign(Object.assign({}, prev), { isLoading: false })));
|
|
75
46
|
});
|
|
76
|
-
}, []);
|
|
47
|
+
}, [search, exclude]);
|
|
77
48
|
return data;
|
|
78
49
|
};
|
|
79
50
|
exports.default = useSCFetchUsers;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook to recover a given preference.
|
|
3
|
+
* @param preferenceKey - full preference key (e.g., 'section.name')
|
|
4
|
+
* @param defaultValue - default returned value
|
|
5
|
+
* @returns the preference value or undefined/defaultValue if doesn't exist
|
|
6
|
+
*
|
|
7
|
+
* Ex.
|
|
8
|
+
* const customValue = useSCPreference<string>(SCPreferences.CUSTOM_SETTING);
|
|
9
|
+
* const numericValue = useSCPreference<number>(SCPreferences.CUSTOM_SETTING, 0);
|
|
10
|
+
*/
|
|
11
|
+
declare function useSCPreference<T = any>(preferenceKey: string, defaultValue?: T): T | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Custom hook to check if a given preference is present and has a value.
|
|
14
|
+
* @param preferenceKey - full preference key (e.g., 'section.name')
|
|
15
|
+
* @param defaultValue - default returned value (default=false)
|
|
16
|
+
* @returns boolean
|
|
17
|
+
*
|
|
18
|
+
* Ex.
|
|
19
|
+
* const isEnabled = useSCPreferenceEnabled(SCPreferences.CONFIGURATIONS_CONNECTION_ENABLED);
|
|
20
|
+
**/
|
|
21
|
+
declare function useSCPreferenceEnabled(preferenceKey: string, defaultValue?: boolean): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Custom hook to check if all specified preferences are enabled
|
|
24
|
+
* @param preferenceKeys - Array of preference keys to check
|
|
25
|
+
* @param defaultValue - Default value if a preference doesn't exist
|
|
26
|
+
* @returns boolean - true if all preferences are enabled
|
|
27
|
+
*
|
|
28
|
+
* Ex.
|
|
29
|
+
* const arePreferencesEnabled = useSCPreferencesEnabled([
|
|
30
|
+
* SCPreferences.CONFIGURATIONS_POST_USER_ADDRESSING_ENABLED,
|
|
31
|
+
* SCPreferences.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED
|
|
32
|
+
* ]);
|
|
33
|
+
*/
|
|
34
|
+
declare function useSCPreferencesEnabled(preferenceKeys: string[], defaultValue?: boolean): boolean;
|
|
35
|
+
export { useSCPreferenceEnabled, useSCPreferencesEnabled };
|
|
36
|
+
export default useSCPreference;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSCPreferencesEnabled = exports.useSCPreferenceEnabled = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const SCPreferencesProvider_1 = require("../components/provider/SCPreferencesProvider");
|
|
6
|
+
/**
|
|
7
|
+
* Custom hook to recover a given preference.
|
|
8
|
+
* @param preferenceKey - full preference key (e.g., 'section.name')
|
|
9
|
+
* @param defaultValue - default returned value
|
|
10
|
+
* @returns the preference value or undefined/defaultValue if doesn't exist
|
|
11
|
+
*
|
|
12
|
+
* Ex.
|
|
13
|
+
* const customValue = useSCPreference<string>(SCPreferences.CUSTOM_SETTING);
|
|
14
|
+
* const numericValue = useSCPreference<number>(SCPreferences.CUSTOM_SETTING, 0);
|
|
15
|
+
*/
|
|
16
|
+
function useSCPreference(preferenceKey, defaultValue) {
|
|
17
|
+
const { preferences } = (0, SCPreferencesProvider_1.useSCPreferences)();
|
|
18
|
+
return (0, react_1.useMemo)(() => {
|
|
19
|
+
if (!preferences || !(preferenceKey in preferences)) {
|
|
20
|
+
return defaultValue;
|
|
21
|
+
}
|
|
22
|
+
const pref = preferences[preferenceKey];
|
|
23
|
+
return pref.value;
|
|
24
|
+
}, [preferences, preferenceKey, defaultValue]);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Custom hook to check if a given preference is present and has a value.
|
|
28
|
+
* @param preferenceKey - full preference key (e.g., 'section.name')
|
|
29
|
+
* @param defaultValue - default returned value (default=false)
|
|
30
|
+
* @returns boolean
|
|
31
|
+
*
|
|
32
|
+
* Ex.
|
|
33
|
+
* const isEnabled = useSCPreferenceEnabled(SCPreferences.CONFIGURATIONS_CONNECTION_ENABLED);
|
|
34
|
+
**/
|
|
35
|
+
function useSCPreferenceEnabled(preferenceKey, defaultValue = false) {
|
|
36
|
+
const value = useSCPreference(preferenceKey, defaultValue);
|
|
37
|
+
return value !== null && value !== void 0 ? value : defaultValue;
|
|
38
|
+
}
|
|
39
|
+
exports.useSCPreferenceEnabled = useSCPreferenceEnabled;
|
|
40
|
+
/**
|
|
41
|
+
* Custom hook to check if all specified preferences are enabled
|
|
42
|
+
* @param preferenceKeys - Array of preference keys to check
|
|
43
|
+
* @param defaultValue - Default value if a preference doesn't exist
|
|
44
|
+
* @returns boolean - true if all preferences are enabled
|
|
45
|
+
*
|
|
46
|
+
* Ex.
|
|
47
|
+
* const arePreferencesEnabled = useSCPreferencesEnabled([
|
|
48
|
+
* SCPreferences.CONFIGURATIONS_POST_USER_ADDRESSING_ENABLED,
|
|
49
|
+
* SCPreferences.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED
|
|
50
|
+
* ]);
|
|
51
|
+
*/
|
|
52
|
+
function useSCPreferencesEnabled(preferenceKeys, defaultValue = false) {
|
|
53
|
+
const { preferences } = (0, SCPreferencesProvider_1.useSCPreferences)();
|
|
54
|
+
return (0, react_1.useMemo)(() => {
|
|
55
|
+
// Se non ci sono preferences o non è stato passato nessun preferenceKey, ritorna il valore di default
|
|
56
|
+
if (!preferences || !preferenceKeys.length) {
|
|
57
|
+
return defaultValue;
|
|
58
|
+
}
|
|
59
|
+
// Verifica che tutte le preferenze siano presenti e abbiano value = true
|
|
60
|
+
return preferenceKeys.every((key) => {
|
|
61
|
+
if (!(key in preferences)) {
|
|
62
|
+
return defaultValue;
|
|
63
|
+
}
|
|
64
|
+
return preferences[key].value;
|
|
65
|
+
});
|
|
66
|
+
}, [preferences, preferenceKeys, defaultValue]);
|
|
67
|
+
}
|
|
68
|
+
exports.useSCPreferencesEnabled = useSCPreferencesEnabled;
|
|
69
|
+
exports.default = useSCPreference;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SCFeatureName } from '@selfcommunity/types';
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook preferences and features at the same time
|
|
4
|
+
* @param preferences - array of preference keys
|
|
5
|
+
* @param features - array of feature keys
|
|
6
|
+
* @returns boolean - true only if all preferences and features are enabled
|
|
7
|
+
*
|
|
8
|
+
* Ex.
|
|
9
|
+
* const isEnabled = useSCPreferencesAndFeaturesEnabled(
|
|
10
|
+
* [
|
|
11
|
+
* SCPreferences.CONFIGURATIONS_POST_USER_ADDRESSING_ENABLED,
|
|
12
|
+
* SCPreferences.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED
|
|
13
|
+
* ],
|
|
14
|
+
* [SCFeatureName.TAGGING]
|
|
15
|
+
* );
|
|
16
|
+
*/
|
|
17
|
+
export default function useSCPreferencesAndFeaturesEnabled(preferences: string[], features?: SCFeatureName[]): boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
const SCPreferencesProvider_1 = require("../components/provider/SCPreferencesProvider");
|
|
5
|
+
/**
|
|
6
|
+
* Custom hook preferences and features at the same time
|
|
7
|
+
* @param preferences - array of preference keys
|
|
8
|
+
* @param features - array of feature keys
|
|
9
|
+
* @returns boolean - true only if all preferences and features are enabled
|
|
10
|
+
*
|
|
11
|
+
* Ex.
|
|
12
|
+
* const isEnabled = useSCPreferencesAndFeaturesEnabled(
|
|
13
|
+
* [
|
|
14
|
+
* SCPreferences.CONFIGURATIONS_POST_USER_ADDRESSING_ENABLED,
|
|
15
|
+
* SCPreferences.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED
|
|
16
|
+
* ],
|
|
17
|
+
* [SCFeatureName.TAGGING]
|
|
18
|
+
* );
|
|
19
|
+
*/
|
|
20
|
+
function useSCPreferencesAndFeaturesEnabled(preferences, features = []) {
|
|
21
|
+
const { preferences: preferencesContext, features: featuresContext } = (0, SCPreferencesProvider_1.useSCPreferences)();
|
|
22
|
+
return (0, react_1.useMemo)(() => {
|
|
23
|
+
// Check available context
|
|
24
|
+
if (!preferencesContext || !featuresContext) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
// Check every preferences
|
|
28
|
+
const preferencesEnabled = preferences.every((key) => key in preferencesContext && preferencesContext[key].value);
|
|
29
|
+
// Check every features
|
|
30
|
+
const featuresEnabled = features.every((feature) => featuresContext.includes(feature));
|
|
31
|
+
// Return true only if all preferences and features are enabled
|
|
32
|
+
return preferencesEnabled && featuresEnabled;
|
|
33
|
+
}, [preferencesContext, featuresContext, preferences, features]);
|
|
34
|
+
}
|
|
35
|
+
exports.default = useSCPreferencesAndFeaturesEnabled;
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -75,7 +75,10 @@ import useSCFetchLesson from './hooks/useSCFetchLesson';
|
|
|
75
75
|
import useSCPaymentsEnabled from './hooks/useSCPaymentsEnabled';
|
|
76
76
|
import useSCFetchPaymentProduct from './hooks/useSCFetchPaymentProduct';
|
|
77
77
|
import useSCFetchPaymentOrder from './hooks/useSCFetchPaymentOrder';
|
|
78
|
-
import
|
|
78
|
+
import useFetchMenuFooter from './hooks/useFetchMenuFooter';
|
|
79
|
+
import useSCPreference, { useSCPreferenceEnabled, useSCPreferencesEnabled } from './hooks/useSCPreference';
|
|
80
|
+
import { useSCFeatureEnabled, useSCFeaturesEnabled } from './hooks/useSCFeature';
|
|
81
|
+
import useSCPreferencesAndFeaturesEnabled from './hooks/useSCPreferencesAndFeaturesEnabled';
|
|
79
82
|
/**
|
|
80
83
|
* Routing component
|
|
81
84
|
*/
|
|
@@ -98,4 +101,4 @@ import * as Preferences from './constants/Preferences';
|
|
|
98
101
|
/**
|
|
99
102
|
* List all exports
|
|
100
103
|
*/
|
|
101
|
-
export { SCUserContextType, SCFollowedCategoriesManagerType, SCContextProviderType, SCContextType, SCSettingsType, SCSessionType, SCSettingsManagerType, SCFollowedManagerType, SCFollowersManagerType, SCConnectionsManagerType, SCSubscribedIncubatorsManagerType, SCLocaleType, SCNotificationContextType, SCPreferencesContextType, SCThemeContextType, SCRoutingContextType, SCLocaleContextType, SCAlertMessagesContextType, SCThemeAvatarVariableType, SCThemeCategoryIconVariableType, SCThemeCategoryVariableType, SCThemeVariablesType, SCThemeType, SCSubscribedGroupsManagerType, SCSubscribedEventsManagerType, SCJoinedCoursesManagerType, SCContext, SCUserContext, SCThemeContext, SCRoutingContext, SCLocaleContext, SCPreferencesContext, useSCContext, SCContextProvider, SCUserProvider, useSCUser, useSCPreferences, SCThemeProvider, useSCTheme, withSCTheme, getTheme, SCRoutingProvider, useSCRouting, SCLocaleProvider, useSCLocale, withSCLocale, SCPreferencesProvider, SCPreferences, SCFeatures, SCNotification, SCNotificationProvider, SCNotificationContext, useSCNotification, SCAlertMessagesProvider, SCAlertMessagesContext, useSCAlertMessages, Link, SCRoutes, SCCache, UserUtils, getEventStatus, Locale, Preferences, useSCFetchUser, useSCFetchUsers, useSCFetchUserProviders, useSCFetchVote, useSCFetchFeedObject, useSCFetchCommentObject, useSCFetchCommentObjects, useSCFetchLessonCommentObject, useSCFetchLessonCommentObjects, useSCFetchCustomAdv, useSCFetchTag, useSCFetchAddressingTagList, useSCFetchCategory, useSCFetchCategories, useSCFetchIncubator, useSCMediaClick, useSCFetchContributors, useSCFetchFeed, useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, useSCFetchEvent, useSCFetchEvents, useSCFetchLiveStream, useSCGoogleApiLoader, useSCFetchCourse, useSCFetchCourses, useSCFetchLesson, useSCPaymentsEnabled, useSCFetchPaymentProduct, useSCFetchPaymentOrder, useSCPreferenceEnabled, };
|
|
104
|
+
export { SCUserContextType, SCFollowedCategoriesManagerType, SCContextProviderType, SCContextType, SCSettingsType, SCSessionType, SCSettingsManagerType, SCFollowedManagerType, SCFollowersManagerType, SCConnectionsManagerType, SCSubscribedIncubatorsManagerType, SCLocaleType, SCNotificationContextType, SCPreferencesContextType, SCThemeContextType, SCRoutingContextType, SCLocaleContextType, SCAlertMessagesContextType, SCThemeAvatarVariableType, SCThemeCategoryIconVariableType, SCThemeCategoryVariableType, SCThemeVariablesType, SCThemeType, SCSubscribedGroupsManagerType, SCSubscribedEventsManagerType, SCJoinedCoursesManagerType, SCContext, SCUserContext, SCThemeContext, SCRoutingContext, SCLocaleContext, SCPreferencesContext, useSCContext, SCContextProvider, SCUserProvider, useSCUser, useSCPreferences, SCThemeProvider, useSCTheme, withSCTheme, getTheme, SCRoutingProvider, useSCRouting, SCLocaleProvider, useSCLocale, withSCLocale, SCPreferencesProvider, SCPreferences, SCFeatures, SCNotification, SCNotificationProvider, SCNotificationContext, useSCNotification, SCAlertMessagesProvider, SCAlertMessagesContext, useSCAlertMessages, Link, SCRoutes, SCCache, UserUtils, getEventStatus, Locale, Preferences, useSCFetchUser, useSCFetchUsers, useSCFetchUserProviders, useSCFetchVote, useSCFetchFeedObject, useSCFetchCommentObject, useSCFetchCommentObjects, useSCFetchLessonCommentObject, useSCFetchLessonCommentObjects, useSCFetchCustomAdv, useSCFetchTag, useSCFetchAddressingTagList, useSCFetchCategory, useSCFetchCategories, useSCFetchIncubator, useSCMediaClick, useSCFetchContributors, useSCFetchFeed, useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, useSCFetchEvent, useSCFetchEvents, useSCFetchLiveStream, useSCGoogleApiLoader, useSCFetchCourse, useSCFetchCourses, useSCFetchLesson, useSCPaymentsEnabled, useSCFetchPaymentProduct, useSCFetchPaymentOrder, useFetchMenuFooter, useSCPreference, useSCPreferenceEnabled, useSCPreferencesEnabled, useSCFeatureEnabled, useSCFeaturesEnabled, useSCPreferencesAndFeaturesEnabled, };
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSCFetchCategory = exports.useSCFetchAddressingTagList = exports.useSCFetchTag = exports.useSCFetchCustomAdv = exports.useSCFetchLessonCommentObjects = exports.useSCFetchLessonCommentObject = exports.useSCFetchCommentObjects = exports.useSCFetchCommentObject = exports.useSCFetchFeedObject = exports.useSCFetchVote = exports.useSCFetchUserProviders = exports.useSCFetchUsers = exports.useSCFetchUser = exports.Preferences = exports.Locale = exports.getEventStatus = exports.UserUtils = exports.SCCache = exports.SCRoutes = exports.Link = exports.useSCAlertMessages = exports.SCAlertMessagesContext = exports.SCAlertMessagesProvider = exports.useSCNotification = exports.SCNotificationContext = exports.SCNotificationProvider = exports.SCNotification = exports.SCFeatures = exports.SCPreferences = exports.SCPreferencesProvider = exports.withSCLocale = exports.useSCLocale = exports.SCLocaleProvider = exports.useSCRouting = exports.SCRoutingProvider = exports.getTheme = exports.withSCTheme = exports.useSCTheme = exports.SCThemeProvider = exports.useSCPreferences = exports.useSCUser = exports.SCUserProvider = exports.SCContextProvider = exports.useSCContext = exports.SCPreferencesContext = exports.SCLocaleContext = exports.SCRoutingContext = exports.SCThemeContext = exports.SCUserContext = exports.SCContext = void 0;
|
|
4
|
-
exports.useSCPreferenceEnabled = exports.useSCFetchPaymentOrder = exports.useSCFetchPaymentProduct = exports.useSCPaymentsEnabled = exports.useSCFetchLesson = exports.useSCFetchCourses = exports.useSCFetchCourse = exports.useSCGoogleApiLoader = exports.useSCFetchLiveStream = exports.useSCFetchEvents = exports.useSCFetchEvent = exports.useSCFetchGroups = exports.useSCFetchGroup = exports.useSCUserIsBlocked = exports.useSCFetchUserBlockedBy = exports.useSCFetchBroadcastMessages = exports.useSCFetchPrivateMessageSnippets = exports.useResizeObserver = exports.usePageVisibility = exports.useNoInitialEffect = exports.useEffectOnce = exports.useIsomorphicLayoutEffect = exports.usePreviousValue = exports.useIsComponentMountedRef = exports.useSCFetchFeed = exports.useSCFetchContributors = exports.useSCMediaClick = exports.useSCFetchIncubator = exports.useSCFetchCategories = void 0;
|
|
4
|
+
exports.useSCPreferencesAndFeaturesEnabled = exports.useSCFeaturesEnabled = exports.useSCFeatureEnabled = exports.useSCPreferencesEnabled = exports.useSCPreferenceEnabled = exports.useSCPreference = exports.useFetchMenuFooter = exports.useSCFetchPaymentOrder = exports.useSCFetchPaymentProduct = exports.useSCPaymentsEnabled = exports.useSCFetchLesson = exports.useSCFetchCourses = exports.useSCFetchCourse = exports.useSCGoogleApiLoader = exports.useSCFetchLiveStream = exports.useSCFetchEvents = exports.useSCFetchEvent = exports.useSCFetchGroups = exports.useSCFetchGroup = exports.useSCUserIsBlocked = exports.useSCFetchUserBlockedBy = exports.useSCFetchBroadcastMessages = exports.useSCFetchPrivateMessageSnippets = exports.useResizeObserver = exports.usePageVisibility = exports.useNoInitialEffect = exports.useEffectOnce = exports.useIsomorphicLayoutEffect = exports.usePreviousValue = exports.useIsComponentMountedRef = exports.useSCFetchFeed = exports.useSCFetchContributors = exports.useSCMediaClick = exports.useSCFetchIncubator = exports.useSCFetchCategories = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
/**
|
|
7
7
|
* ContextProvider component
|
|
@@ -140,8 +140,17 @@ const useSCFetchPaymentProduct_1 = tslib_1.__importDefault(require("./hooks/useS
|
|
|
140
140
|
exports.useSCFetchPaymentProduct = useSCFetchPaymentProduct_1.default;
|
|
141
141
|
const useSCFetchPaymentOrder_1 = tslib_1.__importDefault(require("./hooks/useSCFetchPaymentOrder"));
|
|
142
142
|
exports.useSCFetchPaymentOrder = useSCFetchPaymentOrder_1.default;
|
|
143
|
-
const
|
|
144
|
-
exports.
|
|
143
|
+
const useFetchMenuFooter_1 = tslib_1.__importDefault(require("./hooks/useFetchMenuFooter"));
|
|
144
|
+
exports.useFetchMenuFooter = useFetchMenuFooter_1.default;
|
|
145
|
+
const useSCPreference_1 = tslib_1.__importStar(require("./hooks/useSCPreference"));
|
|
146
|
+
exports.useSCPreference = useSCPreference_1.default;
|
|
147
|
+
Object.defineProperty(exports, "useSCPreferenceEnabled", { enumerable: true, get: function () { return useSCPreference_1.useSCPreferenceEnabled; } });
|
|
148
|
+
Object.defineProperty(exports, "useSCPreferencesEnabled", { enumerable: true, get: function () { return useSCPreference_1.useSCPreferencesEnabled; } });
|
|
149
|
+
const useSCFeature_1 = require("./hooks/useSCFeature");
|
|
150
|
+
Object.defineProperty(exports, "useSCFeatureEnabled", { enumerable: true, get: function () { return useSCFeature_1.useSCFeatureEnabled; } });
|
|
151
|
+
Object.defineProperty(exports, "useSCFeaturesEnabled", { enumerable: true, get: function () { return useSCFeature_1.useSCFeaturesEnabled; } });
|
|
152
|
+
const useSCPreferencesAndFeaturesEnabled_1 = tslib_1.__importDefault(require("./hooks/useSCPreferencesAndFeaturesEnabled"));
|
|
153
|
+
exports.useSCPreferencesAndFeaturesEnabled = useSCPreferencesAndFeaturesEnabled_1.default;
|
|
145
154
|
/**
|
|
146
155
|
* Routing component
|
|
147
156
|
*/
|
|
@@ -33,7 +33,7 @@ export default function SCLocaleProvider({ children }: {
|
|
|
33
33
|
* Export hoc to inject the base theme to components
|
|
34
34
|
* @param Component
|
|
35
35
|
*/
|
|
36
|
-
export declare const withSCLocale: (Component: any) => (props: any) => JSX.Element;
|
|
36
|
+
export declare const withSCLocale: (Component: any) => (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
37
37
|
/**
|
|
38
38
|
* Let's only export the `useSCLocale` hook instead of the context.
|
|
39
39
|
* We only want to use the hook directly and never the context component.
|
|
@@ -40,7 +40,7 @@ export default function SCThemeProvider({ children }: {
|
|
|
40
40
|
* Export hoc to inject the base theme to components
|
|
41
41
|
* @param Component
|
|
42
42
|
*/
|
|
43
|
-
export declare const withSCTheme: (Component: any) => (props: any) => JSX.Element;
|
|
43
|
+
export declare const withSCTheme: (Component: any) => (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
44
44
|
/**
|
|
45
45
|
* Let's only export the `useSCTheme` hook instead of the context.
|
|
46
46
|
* We only want to use the hook directly and never the context component.
|
|
@@ -26,8 +26,8 @@ const scRoutingContext: SCRoutingContextType = useSCRouting();
|
|
|
26
26
|
|
|
27
27
|
:::
|
|
28
28
|
*/
|
|
29
|
-
declare const _default: React.ForwardRefExoticComponent<
|
|
29
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<{
|
|
30
30
|
[x: string]: any;
|
|
31
31
|
children: any;
|
|
32
|
-
},
|
|
32
|
+
}, "ref"> & React.RefAttributes<unknown>>;
|
|
33
33
|
export default _default;
|