@selfcommunity/react-templates 0.4.5-courses.114 → 0.4.5-courses.116
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/CategoryFeed/CategoryFeed.js +2 -1
- package/lib/cjs/components/Lesson/Lesson.d.ts +7 -1
- package/lib/cjs/components/Lesson/Lesson.js +3 -2
- package/lib/esm/components/CategoryFeed/CategoryFeed.js +4 -3
- package/lib/esm/components/Lesson/Lesson.d.ts +7 -1
- package/lib/esm/components/Lesson/Lesson.js +3 -2
- package/lib/umd/{165.js → 649.js} +2 -2
- package/lib/umd/react-templates.js +1 -1
- package/package.json +6 -6
- /package/lib/umd/{165.js.LICENSE.txt → 649.js.LICENSE.txt} +0 -0
|
@@ -72,6 +72,7 @@ function CategoryFeed(inProps) {
|
|
|
72
72
|
const { id = 'category_feed', className, category, categoryId, widgets = WIDGETS, FeedObjectProps = {}, FeedSidebarProps = null, FeedProps = {} } = props;
|
|
73
73
|
// CONTEXT
|
|
74
74
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
75
|
+
const scUserContext = (0, react_core_1.useSCUser)();
|
|
75
76
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
76
77
|
// REF
|
|
77
78
|
const feedRef = (0, react_1.useRef)();
|
|
@@ -114,7 +115,7 @@ function CategoryFeed(inProps) {
|
|
|
114
115
|
markRead: scUser ? !item.seen_by_id.includes(scUser.id) : null
|
|
115
116
|
}), itemIdGenerator: (item) => item[item.type].id, ItemProps: FeedObjectProps, ItemSkeleton: react_ui_1.FeedObjectSkeleton, ItemSkeletonProps: {
|
|
116
117
|
template: react_ui_1.SCFeedObjectTemplateType.PREVIEW
|
|
117
|
-
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: (0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { categories: [scCategory] }, feedType: types_1.SCFeedTypologyType.CATEGORY }), CustomAdvProps: { categoriesId: [scCategory.id] }, enabledCustomAdvPositions: [
|
|
118
|
+
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: ((scCategory.content_only_staff && react_core_1.UserUtils.isStaff(scUserContext.user)) || !scCategory.content_only_staff) && ((0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { categories: [scCategory] }, feedType: types_1.SCFeedTypologyType.CATEGORY })) }), CustomAdvProps: { categoriesId: [scCategory.id] }, enabledCustomAdvPositions: [
|
|
118
119
|
types_1.SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
119
120
|
types_1.SCCustomAdvPosition.POSITION_FEED,
|
|
120
121
|
types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR
|
|
@@ -40,8 +40,14 @@ export interface LessonProps {
|
|
|
40
40
|
editMode?: boolean;
|
|
41
41
|
/**
|
|
42
42
|
* Callback fired on edit mode close
|
|
43
|
+
* @default null
|
|
44
|
+
*/
|
|
45
|
+
onEditModeClose?: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Handler on lesson change
|
|
48
|
+
* @default null
|
|
43
49
|
*/
|
|
44
|
-
|
|
50
|
+
onLessonChange?: (id: any) => void;
|
|
45
51
|
/**
|
|
46
52
|
* Any other properties
|
|
47
53
|
*/
|
|
@@ -36,7 +36,7 @@ function Lesson(inProps) {
|
|
|
36
36
|
props: inProps,
|
|
37
37
|
name: constants_1.PREFIX
|
|
38
38
|
});
|
|
39
|
-
const { className = null, courseId, sectionId, lesson = null, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false,
|
|
39
|
+
const { className = null, courseId, sectionId, lesson = null, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false, onEditModeClose = null, onLessonChange = null } = props, rest = tslib_1.__rest(props, ["className", "courseId", "sectionId", "lesson", "lessonId", "LessonAppbarProps", "LessonDrawerProps", "editMode", "onEditModeClose", "onLessonChange"]);
|
|
40
40
|
// HOOKS
|
|
41
41
|
const theme = (0, material_1.useTheme)();
|
|
42
42
|
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
@@ -63,7 +63,7 @@ function Lesson(inProps) {
|
|
|
63
63
|
};
|
|
64
64
|
const handleCloseDrawer = () => {
|
|
65
65
|
setActivePanel(null);
|
|
66
|
-
|
|
66
|
+
onEditModeClose && onEditModeClose();
|
|
67
67
|
};
|
|
68
68
|
const handleLessonContentEdit = (html) => {
|
|
69
69
|
setLessonContent(html);
|
|
@@ -75,6 +75,7 @@ function Lesson(inProps) {
|
|
|
75
75
|
setLessonId(l.id);
|
|
76
76
|
setSectionId(s.id);
|
|
77
77
|
setCurrentSection(s);
|
|
78
|
+
onLessonChange && onLessonChange(l.id);
|
|
78
79
|
};
|
|
79
80
|
/**
|
|
80
81
|
* Handles Lesson Edit
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useRef } from 'react';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { CategoryTrendingFeedWidget, CategoryTrendingUsersWidget, ContributionUtils, Feed, FeedObject, FeedObjectSkeleton, InlineComposerWidget, SCFeedObjectTemplateType } from '@selfcommunity/react-ui';
|
|
5
5
|
import { Endpoints } from '@selfcommunity/api-services';
|
|
6
|
-
import { Link, SCRoutes, useSCFetchCategory, useSCRouting } from '@selfcommunity/react-core';
|
|
6
|
+
import { Link, SCRoutes, UserUtils, useSCFetchCategory, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
7
7
|
import { SCCustomAdvPosition, SCFeedTypologyType } from '@selfcommunity/types';
|
|
8
8
|
import { CategoryFeedSkeleton } from './index';
|
|
9
9
|
import { useThemeProps } from '@mui/system';
|
|
@@ -69,6 +69,7 @@ export default function CategoryFeed(inProps) {
|
|
|
69
69
|
const { id = 'category_feed', className, category, categoryId, widgets = WIDGETS, FeedObjectProps = {}, FeedSidebarProps = null, FeedProps = {} } = props;
|
|
70
70
|
// CONTEXT
|
|
71
71
|
const scRoutingContext = useSCRouting();
|
|
72
|
+
const scUserContext = useSCUser();
|
|
72
73
|
const { enqueueSnackbar } = useSnackbar();
|
|
73
74
|
// REF
|
|
74
75
|
const feedRef = useRef();
|
|
@@ -111,7 +112,7 @@ export default function CategoryFeed(inProps) {
|
|
|
111
112
|
markRead: scUser ? !item.seen_by_id.includes(scUser.id) : null
|
|
112
113
|
}), itemIdGenerator: (item) => item[item.type].id, ItemProps: FeedObjectProps, ItemSkeleton: FeedObjectSkeleton, ItemSkeletonProps: {
|
|
113
114
|
template: SCFeedObjectTemplateType.PREVIEW
|
|
114
|
-
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: _jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { categories: [scCategory] }, feedType: SCFeedTypologyType.CATEGORY }), CustomAdvProps: { categoriesId: [scCategory.id] }, enabledCustomAdvPositions: [
|
|
115
|
+
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: _jsx(_Fragment, { children: ((scCategory.content_only_staff && UserUtils.isStaff(scUserContext.user)) || !scCategory.content_only_staff) && (_jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { categories: [scCategory] }, feedType: SCFeedTypologyType.CATEGORY })) }), CustomAdvProps: { categoriesId: [scCategory.id] }, enabledCustomAdvPositions: [
|
|
115
116
|
SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
116
117
|
SCCustomAdvPosition.POSITION_FEED,
|
|
117
118
|
SCCustomAdvPosition.POSITION_BELOW_TOPBAR
|
|
@@ -40,8 +40,14 @@ export interface LessonProps {
|
|
|
40
40
|
editMode?: boolean;
|
|
41
41
|
/**
|
|
42
42
|
* Callback fired on edit mode close
|
|
43
|
+
* @default null
|
|
44
|
+
*/
|
|
45
|
+
onEditModeClose?: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Handler on lesson change
|
|
48
|
+
* @default null
|
|
43
49
|
*/
|
|
44
|
-
|
|
50
|
+
onLessonChange?: (id: any) => void;
|
|
45
51
|
/**
|
|
46
52
|
* Any other properties
|
|
47
53
|
*/
|
|
@@ -34,7 +34,7 @@ export default function Lesson(inProps) {
|
|
|
34
34
|
props: inProps,
|
|
35
35
|
name: PREFIX
|
|
36
36
|
});
|
|
37
|
-
const { className = null, courseId, sectionId, lesson = null, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false,
|
|
37
|
+
const { className = null, courseId, sectionId, lesson = null, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false, onEditModeClose = null, onLessonChange = null } = props, rest = __rest(props, ["className", "courseId", "sectionId", "lesson", "lessonId", "LessonAppbarProps", "LessonDrawerProps", "editMode", "onEditModeClose", "onLessonChange"]);
|
|
38
38
|
// HOOKS
|
|
39
39
|
const theme = useTheme();
|
|
40
40
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
@@ -61,7 +61,7 @@ export default function Lesson(inProps) {
|
|
|
61
61
|
};
|
|
62
62
|
const handleCloseDrawer = () => {
|
|
63
63
|
setActivePanel(null);
|
|
64
|
-
|
|
64
|
+
onEditModeClose && onEditModeClose();
|
|
65
65
|
};
|
|
66
66
|
const handleLessonContentEdit = (html) => {
|
|
67
67
|
setLessonContent(html);
|
|
@@ -73,6 +73,7 @@ export default function Lesson(inProps) {
|
|
|
73
73
|
setLessonId(l.id);
|
|
74
74
|
setSectionId(s.id);
|
|
75
75
|
setCurrentSection(s);
|
|
76
|
+
onLessonChange && onLessonChange(l.id);
|
|
76
77
|
};
|
|
77
78
|
/**
|
|
78
79
|
* Handles Lesson Edit
|