@selfcommunity/react-ui 0.8.0-live.54 → 0.8.0-live.56
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/CreateLiveStreamButton/CreateLiveStreamButton.d.ts +0 -5
- package/lib/cjs/components/CreateLiveStreamButton/CreateLiveStreamButton.js +2 -16
- package/lib/cjs/components/CreateLiveStreamDialog/CreateLiveStreamDialog.d.ts +0 -2
- package/lib/cjs/components/CreateLiveStreamDialog/CreateLiveStreamDialog.js +13 -31
- package/lib/cjs/components/CreateLiveStreamDialog/LiveStreamSelector/LiveStreamSelector.js +10 -2
- package/lib/cjs/components/EventForm/EventAddress.d.ts +2 -1
- package/lib/cjs/components/EventForm/EventAddress.js +23 -3
- package/lib/cjs/components/EventForm/EventForm.js +8 -1
- package/lib/cjs/components/LiveStream/LiveStream.d.ts +79 -0
- package/lib/cjs/components/LiveStream/LiveStream.js +143 -0
- package/lib/cjs/components/LiveStream/Skeleton.d.ts +46 -0
- package/lib/cjs/components/LiveStream/Skeleton.js +92 -0
- package/lib/cjs/components/LiveStream/constants.d.ts +1 -0
- package/lib/cjs/components/LiveStream/constants.js +4 -0
- package/lib/cjs/components/LiveStream/index.d.ts +4 -0
- package/lib/cjs/components/LiveStream/index.js +8 -0
- package/lib/cjs/components/LiveStreamForm/LiveStreamForm.d.ts +1 -1
- package/lib/cjs/components/LiveStreamForm/LiveStreamForm.js +33 -38
- package/lib/cjs/components/LiveStreamForm/LiveStreamFormSettings.d.ts +46 -0
- package/lib/cjs/components/LiveStreamForm/LiveStreamFormSettings.js +61 -0
- package/lib/cjs/components/LiveStreamForm/constants.d.ts +7 -0
- package/lib/cjs/components/LiveStreamForm/constants.js +8 -1
- package/lib/cjs/components/LiveStreamRoom/LiveStreamRoom.d.ts +3 -2
- package/lib/cjs/components/LiveStreamRoom/LiveStreamRoom.js +24 -38
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.d.ts +7 -2
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.js +4 -4
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.d.ts +39 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +112 -0
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.js +2 -16
- package/lib/cjs/index.d.ts +3 -1
- package/lib/cjs/index.js +6 -1
- package/lib/cjs/shared/LiveStreamInfoDetails/index.d.ts +17 -0
- package/lib/cjs/shared/LiveStreamInfoDetails/index.js +45 -0
- package/lib/cjs/types/liveStream.d.ts +5 -0
- package/lib/cjs/types/liveStream.js +9 -0
- package/lib/esm/components/CreateLiveStreamButton/CreateLiveStreamButton.d.ts +0 -5
- package/lib/esm/components/CreateLiveStreamButton/CreateLiveStreamButton.js +3 -17
- package/lib/esm/components/CreateLiveStreamDialog/CreateLiveStreamDialog.d.ts +0 -2
- package/lib/esm/components/CreateLiveStreamDialog/CreateLiveStreamDialog.js +10 -28
- package/lib/esm/components/CreateLiveStreamDialog/LiveStreamSelector/LiveStreamSelector.js +10 -2
- package/lib/esm/components/EventForm/EventAddress.d.ts +2 -1
- package/lib/esm/components/EventForm/EventAddress.js +23 -3
- package/lib/esm/components/EventForm/EventForm.js +8 -1
- package/lib/esm/components/LiveStream/LiveStream.d.ts +79 -0
- package/lib/esm/components/LiveStream/LiveStream.js +140 -0
- package/lib/esm/components/LiveStream/Skeleton.d.ts +46 -0
- package/lib/esm/components/LiveStream/Skeleton.js +89 -0
- package/lib/esm/components/LiveStream/constants.d.ts +1 -0
- package/lib/esm/components/LiveStream/constants.js +1 -0
- package/lib/esm/components/LiveStream/index.d.ts +4 -0
- package/lib/esm/components/LiveStream/index.js +4 -0
- package/lib/esm/components/LiveStreamForm/LiveStreamForm.d.ts +1 -1
- package/lib/esm/components/LiveStreamForm/LiveStreamForm.js +33 -38
- package/lib/esm/components/LiveStreamForm/LiveStreamFormSettings.d.ts +46 -0
- package/lib/esm/components/LiveStreamForm/LiveStreamFormSettings.js +57 -0
- package/lib/esm/components/LiveStreamForm/constants.d.ts +7 -0
- package/lib/esm/components/LiveStreamForm/constants.js +7 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamRoom.d.ts +3 -2
- package/lib/esm/components/LiveStreamRoom/LiveStreamRoom.js +26 -40
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.d.ts +7 -2
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.js +5 -5
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.d.ts +39 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +108 -0
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.js +3 -17
- package/lib/esm/index.d.ts +3 -1
- package/lib/esm/index.js +3 -1
- package/lib/esm/shared/LiveStreamInfoDetails/index.d.ts +17 -0
- package/lib/esm/shared/LiveStreamInfoDetails/index.js +42 -0
- package/lib/esm/types/liveStream.d.ts +5 -0
- package/lib/esm/types/liveStream.js +6 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
|
@@ -12,11 +12,6 @@ export interface CreateLiveStreamButtonProps extends ButtonProps {
|
|
|
12
12
|
* @default empty object
|
|
13
13
|
*/
|
|
14
14
|
CreateLiveStreamDialogComponentProps?: CreateLiveStreamDialogProps;
|
|
15
|
-
/**
|
|
16
|
-
* On click callback function
|
|
17
|
-
* @default null
|
|
18
|
-
*/
|
|
19
|
-
onButtonClick?: (event: any, reason: any) => void;
|
|
20
15
|
/**
|
|
21
16
|
* On success callback function
|
|
22
17
|
* @default null
|
|
@@ -52,21 +52,7 @@ function CreateLiveStreamButton(inProps) {
|
|
|
52
52
|
const [open, setOpen] = react_1.default.useState(false);
|
|
53
53
|
// CONST
|
|
54
54
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
55
|
-
const {
|
|
56
|
-
// TODO
|
|
57
|
-
const liveStreamEnabled = true;
|
|
58
|
-
/* const liveStreamEnabled = useMemo(
|
|
59
|
-
() =>
|
|
60
|
-
preferences &&
|
|
61
|
-
features &&
|
|
62
|
-
features.includes(SCFeatureName.LIVE_STREAM) &&
|
|
63
|
-
SCPreferences.CONFIGURATIONS_LIVE_STREAM_ENABLED in preferences &&
|
|
64
|
-
preferences[SCPreferences.CONFIGURATIONS_LIVE_STREAM_ENABLED].value,
|
|
65
|
-
[preferences, features]
|
|
66
|
-
); */
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
68
|
-
// @ts-ignore
|
|
69
|
-
const canCreateLiveStream = (0, react_1.useMemo)(() => true /* scUserContext?.user?.permission?.create_livestream */, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
|
|
55
|
+
const canCreateLiveStream = (0, react_1.useMemo)(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
|
|
70
56
|
/**
|
|
71
57
|
* Handle close
|
|
72
58
|
*/
|
|
@@ -83,7 +69,7 @@ function CreateLiveStreamButton(inProps) {
|
|
|
83
69
|
/**
|
|
84
70
|
* If there's no authUserId, component is hidden.
|
|
85
71
|
*/
|
|
86
|
-
if (!
|
|
72
|
+
if (!canCreateLiveStream || !authUserId) {
|
|
87
73
|
return null;
|
|
88
74
|
}
|
|
89
75
|
/**
|
|
@@ -44,8 +44,6 @@ export interface CreateLiveStreamDialogProps extends BaseDialogProps {
|
|
|
44
44
|
|root|.SCCreateLivestreamDialog-root|Styles applied to the root element.|
|
|
45
45
|
|content|.SCCreateLivestreamDialog-content|Styles applied to the content element.|
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
47
|
* @param inProps
|
|
50
48
|
*/
|
|
51
49
|
export default function CreateLiveStreamDialog(inProps: CreateLiveStreamDialogProps): JSX.Element;
|
|
@@ -6,14 +6,13 @@ const react_1 = tslib_1.__importStar(require("react"));
|
|
|
6
6
|
const styles_1 = require("@mui/material/styles");
|
|
7
7
|
const system_1 = require("@mui/system");
|
|
8
8
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
9
|
-
const types_1 = require("@selfcommunity/types");
|
|
10
9
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
11
10
|
const react_intl_1 = require("react-intl");
|
|
12
11
|
const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
|
|
13
12
|
const constants_1 = require("./constants");
|
|
14
13
|
const EventForm_1 = tslib_1.__importDefault(require("../EventForm"));
|
|
15
14
|
const LiveStreamSelector_1 = tslib_1.__importDefault(require("./LiveStreamSelector/LiveStreamSelector"));
|
|
16
|
-
const
|
|
15
|
+
const types_1 = require("./types");
|
|
17
16
|
const LiveStreamForm_1 = tslib_1.__importDefault(require("../LiveStreamForm"));
|
|
18
17
|
const Slide_1 = tslib_1.__importDefault(require("@mui/material/Slide"));
|
|
19
18
|
const material_1 = require("@mui/material");
|
|
@@ -55,11 +54,10 @@ const Transition = react_1.default.forwardRef(function Transition(props, ref) {
|
|
|
55
54
|
|root|.SCCreateLivestreamDialog-root|Styles applied to the root element.|
|
|
56
55
|
|content|.SCCreateLivestreamDialog-content|Styles applied to the content element.|
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
57
|
* @param inProps
|
|
61
58
|
*/
|
|
62
59
|
function CreateLiveStreamDialog(inProps) {
|
|
60
|
+
var _a, _b;
|
|
63
61
|
//PROPS
|
|
64
62
|
const props = (0, system_1.useThemeProps)({
|
|
65
63
|
props: inProps,
|
|
@@ -67,54 +65,38 @@ function CreateLiveStreamDialog(inProps) {
|
|
|
67
65
|
});
|
|
68
66
|
const { className, open = true, onClose, onSuccess } = props, rest = tslib_1.__rest(props, ["className", "open", "onClose", "onSuccess"]);
|
|
69
67
|
// CONTEXT
|
|
70
|
-
const scContext = (0, react_core_1.useSCContext)();
|
|
71
68
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
72
|
-
const {
|
|
73
|
-
const
|
|
74
|
-
/* preferences &&
|
|
75
|
-
features &&
|
|
76
|
-
features.includes(SCFeatureName.LIVE_STREAM) &&
|
|
77
|
-
SCPreferences.CONFIGURATIONS_LIVE_STREAM_ENABLED in preferences &&
|
|
78
|
-
preferences[SCPreferences.CONFIGURATIONS_LIVE_STREAM_ENABLED].value*/ [preferences, features]);
|
|
79
|
-
const onlyStaffLiveStreamEnabled = (0, react_1.useMemo)(() => true /* preferences[SCPreferences.CONFIGURATIONS_LIVESTREAM_ONLY_STAFF_ENABLED].value */, [preferences]);
|
|
80
|
-
const canCreateLiveStream = (0, react_1.useMemo)(() => true /* liveStreamEnabled && (scUserContext?.user?.permission?.create_livestream || (onlyStaffLiveStreamEnabled && UserUtils.isStaff(scUserContext.user)))*/, [scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user, onlyStaffLiveStreamEnabled]);
|
|
81
|
-
const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
82
|
-
features &&
|
|
83
|
-
features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
84
|
-
react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
85
|
-
preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
86
|
-
const onlyStaffEventEnabled = (0, react_1.useMemo)(() => preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED].value, [preferences]);
|
|
87
|
-
const canCreateEvent = (0, react_1.useMemo)(() => { var _a, _b; return eventsEnabled && (((_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_event) || true || (onlyStaffEventEnabled && react_core_1.UserUtils.isStaff(scUserContext.user))); }, [scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user, eventsEnabled, onlyStaffEventEnabled]);
|
|
88
|
-
const canCreateLiveStreamEvent = (0, react_1.useMemo)(() => Boolean(canCreateLiveStream && canCreateEvent), [canCreateEvent, canCreateLiveStream]);
|
|
69
|
+
const canCreateLiveStream = (0, react_1.useMemo)(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
|
|
70
|
+
const canCreateEvent = (0, react_1.useMemo)(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_event; }, [(_b = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _b === void 0 ? void 0 : _b.permission]);
|
|
89
71
|
// STATE
|
|
90
|
-
const [step, setStep] = (0, react_1.useState)(
|
|
91
|
-
const [liveType, setLiveType] = (0, react_1.useState)(
|
|
72
|
+
const [step, setStep] = (0, react_1.useState)(canCreateEvent ? types_1.CreateLiveStreamStep.SELECT_TYPE : types_1.CreateLiveStreamStep.CREATE_LIVE);
|
|
73
|
+
const [liveType, setLiveType] = (0, react_1.useState)(canCreateEvent ? null : types_1.LiveStreamType.DIRECT_LIVE);
|
|
92
74
|
// HANDLER
|
|
93
75
|
const handleLiveTypeSelected = (0, react_1.useCallback)((l) => {
|
|
94
76
|
setLiveType(l);
|
|
95
77
|
}, []);
|
|
96
78
|
const handleLiveTypeSelectedNext = (0, react_1.useCallback)((l) => {
|
|
97
79
|
setLiveType(l);
|
|
98
|
-
setStep(
|
|
80
|
+
setStep(types_1.CreateLiveStreamStep.CREATE_LIVE);
|
|
99
81
|
}, []);
|
|
100
82
|
const handleBack = (0, react_1.useCallback)((l) => {
|
|
101
|
-
setStep(
|
|
83
|
+
setStep(types_1.CreateLiveStreamStep.SELECT_TYPE);
|
|
102
84
|
}, []);
|
|
103
85
|
const handleSubmit = (0, react_1.useCallback)((e) => {
|
|
104
86
|
onSuccess && onSuccess(e);
|
|
105
87
|
}, []);
|
|
106
88
|
(0, react_1.useEffect)(() => {
|
|
107
|
-
if (!
|
|
108
|
-
setLiveType(
|
|
89
|
+
if (!canCreateEvent) {
|
|
90
|
+
setLiveType(types_1.LiveStreamType.DIRECT_LIVE);
|
|
109
91
|
}
|
|
110
|
-
}, [
|
|
92
|
+
}, [canCreateEvent]);
|
|
111
93
|
// user must be logged
|
|
112
|
-
if (!scUserContext.user) {
|
|
94
|
+
if (!scUserContext.user || !canCreateLiveStream) {
|
|
113
95
|
return null;
|
|
114
96
|
}
|
|
115
97
|
/**
|
|
116
98
|
* Renders root object
|
|
117
99
|
*/
|
|
118
|
-
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ DialogContentProps: { dividers: false }, maxWidth: 'md', title: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.title, component: 'span' }, { children: [Boolean(step ===
|
|
100
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ DialogContentProps: { dividers: false }, maxWidth: 'md', title: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.title, component: 'span' }, { children: [Boolean(step === types_1.CreateLiveStreamStep.CREATE_LIVE && canCreateEvent) && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "text", onClick: handleBack, startIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "arrow_back" }) }, { children: "Back" }))), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ component: 'span' }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.createLivestreamDialog.title", defaultMessage: "ui.createLivestreamDialog.title" }) }))] })), fullWidth: true, open: open, scroll: 'paper', onClose: onClose, className: (0, classnames_1.default)(classes.root, className), TransitionComponent: Transition, PaperProps: { elevation: 0 } }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.content }, { children: [step === types_1.CreateLiveStreamStep.SELECT_TYPE && ((0, jsx_runtime_1.jsx)(LiveStreamSelector_1.default, { liveSelected: liveType, onLiveSelected: handleLiveTypeSelected, onNext: handleLiveTypeSelectedNext })), step === types_1.CreateLiveStreamStep.CREATE_LIVE && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: liveType === types_1.LiveStreamType.EVENT_LIVE ? (0, jsx_runtime_1.jsx)(EventForm_1.default, { onSuccess: handleSubmit }) : (0, jsx_runtime_1.jsx)(LiveStreamForm_1.default, { onSuccess: handleSubmit }) }))] })) })));
|
|
119
101
|
}
|
|
120
102
|
exports.default = CreateLiveStreamDialog;
|
|
@@ -25,8 +25,15 @@ const Root = (0, styles_1.styled)(material_1.Container, {
|
|
|
25
25
|
display: 'flex',
|
|
26
26
|
justifyContent: 'center',
|
|
27
27
|
alignItems: 'center',
|
|
28
|
+
[theme.breakpoints.down('sm')]: {
|
|
29
|
+
display: 'block'
|
|
30
|
+
},
|
|
28
31
|
'& > div': {
|
|
29
|
-
width: '
|
|
32
|
+
width: '290px',
|
|
33
|
+
[theme.breakpoints.down('sm')]: {
|
|
34
|
+
margin: '0px auto',
|
|
35
|
+
marginBottom: theme.spacing(2)
|
|
36
|
+
}
|
|
30
37
|
}
|
|
31
38
|
},
|
|
32
39
|
[`& .${classes.actions}`]: {
|
|
@@ -40,7 +47,8 @@ const Root = (0, styles_1.styled)(material_1.Container, {
|
|
|
40
47
|
const OptionCard = (0, styles_1.styled)(material_1.Paper, {
|
|
41
48
|
shouldForwardProp: (prop) => prop !== 'selected'
|
|
42
49
|
})(({ theme, selected }) => ({
|
|
43
|
-
maxWidth:
|
|
50
|
+
maxWidth: 300,
|
|
51
|
+
height: 350,
|
|
44
52
|
padding: theme.spacing(3),
|
|
45
53
|
margin: theme.spacing(0, 3),
|
|
46
54
|
cursor: 'pointer',
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SCEventType } from '@selfcommunity/types';
|
|
2
2
|
import { Geolocation } from './types';
|
|
3
3
|
export interface EventAddressProps {
|
|
4
|
-
event?: SCEventType
|
|
4
|
+
event?: SCEventType | Partial<SCEventType>;
|
|
5
5
|
forwardGeolocationData: (data: Geolocation) => void;
|
|
6
|
+
forwardLivestreamSettingsData: (settings: any) => void;
|
|
6
7
|
className?: string;
|
|
7
8
|
}
|
|
8
9
|
export default function EventAddress(inProps: EventAddressProps): JSX.Element;
|
|
@@ -16,10 +16,19 @@ const react_intl_1 = require("react-intl");
|
|
|
16
16
|
const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/HiddenPlaceholder"));
|
|
17
17
|
const UrlTextField_1 = tslib_1.__importDefault(require("../../shared/UrlTextField"));
|
|
18
18
|
const constants_1 = require("./constants");
|
|
19
|
+
const LiveStream_1 = tslib_1.__importDefault(require("../LiveStream"));
|
|
20
|
+
const LiveStreamFormSettings_1 = tslib_1.__importDefault(require("../LiveStreamForm/LiveStreamFormSettings"));
|
|
21
|
+
const liveStream_1 = require("../../types/liveStream");
|
|
22
|
+
const constants_2 = require("../LiveStreamForm/constants");
|
|
23
|
+
const utils_1 = require("./utils");
|
|
19
24
|
const messages = (0, react_intl_1.defineMessages)({
|
|
20
25
|
virtualPlaceholder: {
|
|
21
26
|
id: 'ui.eventForm.address.online.placeholder',
|
|
22
27
|
defaultMessage: 'ui.eventForm.address.online.placeholder'
|
|
28
|
+
},
|
|
29
|
+
name: {
|
|
30
|
+
id: 'ui.eventForm.name.placeholder',
|
|
31
|
+
defaultMessage: 'ui.eventForm.name.placeholder'
|
|
23
32
|
}
|
|
24
33
|
});
|
|
25
34
|
const classes = {
|
|
@@ -41,13 +50,21 @@ function EventAddress(inProps) {
|
|
|
41
50
|
// INTL
|
|
42
51
|
const intl = (0, react_intl_1.useIntl)();
|
|
43
52
|
// PROPS
|
|
44
|
-
const { className, forwardGeolocationData, event } = props;
|
|
53
|
+
const { className, forwardGeolocationData, forwardLivestreamSettingsData, event } = props;
|
|
45
54
|
// STATE
|
|
46
55
|
const [location, setLocation] = (0, react_1.useState)((event === null || event === void 0 ? void 0 : event.location) || types_1.SCEventLocationType.PERSON);
|
|
47
56
|
const [geolocation, setGeoLocation] = (0, react_1.useState)(event ? { description: event.geolocation } : null);
|
|
48
57
|
const [inputValue, setInputValue] = (0, react_1.useState)('');
|
|
49
58
|
const [suggestions, setSuggestions] = (0, react_1.useState)([]);
|
|
50
59
|
const [timeoutId, setTimeoutId] = (0, react_1.useState)(null);
|
|
60
|
+
const liveStream = (0, react_1.useMemo)(() => {
|
|
61
|
+
console.log(event);
|
|
62
|
+
return {
|
|
63
|
+
title: (event === null || event === void 0 ? void 0 : event.name) || `${intl.formatMessage(messages.name)}`,
|
|
64
|
+
created_at: (event === null || event === void 0 ? void 0 : event.start_date) || (0, utils_1.getNewDate)(),
|
|
65
|
+
settings: /* event?.livestream?.settings || */ constants_2.LIVESTREAM_DEFAULT_SETTINGS
|
|
66
|
+
} /* || event.livestream? */;
|
|
67
|
+
}, [event]);
|
|
51
68
|
// CONTEXT
|
|
52
69
|
const scContext = (0, react_core_1.useSCContext)();
|
|
53
70
|
const geocodingApiKey = (0, react_1.useMemo)(() => scContext.settings.integrations && scContext.settings.integrations.geocoding.apiKey, [scContext.settings.integrations]);
|
|
@@ -88,6 +105,9 @@ function EventAddress(inProps) {
|
|
|
88
105
|
const handleLinkChange = (event) => {
|
|
89
106
|
forwardGeolocationData({ location, link: event.target.value });
|
|
90
107
|
};
|
|
108
|
+
const handleLiveStreamSettingsChange = (settings) => {
|
|
109
|
+
forwardLivestreamSettingsData(settings);
|
|
110
|
+
};
|
|
91
111
|
(0, react_1.useEffect)(() => {
|
|
92
112
|
if (timeoutId) {
|
|
93
113
|
clearTimeout(timeoutId);
|
|
@@ -114,8 +134,8 @@ function EventAddress(inProps) {
|
|
|
114
134
|
if (!geocodingApiKey && !isLoaded) {
|
|
115
135
|
return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
|
|
116
136
|
}
|
|
117
|
-
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Tabs, Object.assign({ className: classes.tabs, value: location, onChange: handleChange, indicatorColor: "secondary", textColor: "secondary", variant: "fullWidth" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.PERSON, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "add_location_alt" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.label", defaultMessage: "ui.eventForm.address.live.label" }) }), (0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.ONLINE, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "play_circle_outline" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.online.label", defaultMessage: "ui.eventForm.address.online.label" }) })] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.tabContent }, { children: [location === types_1.SCEventLocationType.PERSON && ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, { size: "small", value: geolocation, onChange: handleSelection, inputValue: inputValue, onInputChange: handleLocationChange, options: suggestions, getOptionLabel: (option) => option.description || geolocation.description, noOptionsText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.noResults", defaultMessage: "ui.eventForm.address.live.noResults" }), isOptionEqualToValue: (option, value) => option.description === value.description, renderInput: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.placeholder", defaultMessage: "ui.eventForm.address.live.placeholder" }), variant: "outlined", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "add_location_alt" }) })), params.InputProps.endAdornment] })) }) }))) })), location === types_1.SCEventLocationType.ONLINE && ((0, jsx_runtime_1.jsx)(UrlTextField_1.default, { size: "small", fullWidth: true, type: "url", placeholder: `${intl.formatMessage(messages.virtualPlaceholder)}`, helperText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.online.help", defaultMessage: "ui.eventForm.address.online.help" }), InputProps: {
|
|
137
|
+
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Tabs, Object.assign({ className: classes.tabs, value: location, onChange: handleChange, indicatorColor: "secondary", textColor: "secondary", variant: "fullWidth" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.PERSON, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "add_location_alt" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.label", defaultMessage: "ui.eventForm.address.live.label" }) }), (0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.ONLINE, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "play_circle_outline" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.online.label", defaultMessage: "ui.eventForm.address.online.label" }) }), (0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.LIVESTREAM, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "photo_camera" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.liveStream.label", defaultMessage: "ui.eventForm.address.liveStream.label" }) })] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.tabContent }, { children: [location === types_1.SCEventLocationType.PERSON && ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, { size: "small", value: geolocation, onChange: handleSelection, inputValue: inputValue, onInputChange: handleLocationChange, options: suggestions, getOptionLabel: (option) => option.description || geolocation.description, noOptionsText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.noResults", defaultMessage: "ui.eventForm.address.live.noResults" }), isOptionEqualToValue: (option, value) => option.description === value.description, renderInput: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.placeholder", defaultMessage: "ui.eventForm.address.live.placeholder" }), variant: "outlined", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "add_location_alt" }) })), params.InputProps.endAdornment] })) }) }))) })), location === types_1.SCEventLocationType.ONLINE && ((0, jsx_runtime_1.jsx)(UrlTextField_1.default, { size: "small", fullWidth: true, type: "url", placeholder: `${intl.formatMessage(messages.virtualPlaceholder)}`, helperText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.online.help", defaultMessage: "ui.eventForm.address.online.help" }), InputProps: {
|
|
118
138
|
endAdornment: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "play_circle_outline" })
|
|
119
|
-
}, onChange: handleLinkChange }))] }))] })));
|
|
139
|
+
}, onChange: handleLinkChange })), location === types_1.SCEventLocationType.LIVESTREAM && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(LiveStream_1.default, { template: liveStream_1.SCLiveStreamTemplateType.SNIPPET, liveStream: liveStream, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}) }), (0, jsx_runtime_1.jsx)(LiveStreamFormSettings_1.default, { settings: liveStream.settings, onChange: handleLiveStreamSettingsChange })] }))] }))] })));
|
|
120
140
|
}
|
|
121
141
|
exports.default = EventAddress;
|
|
@@ -186,6 +186,9 @@ function EventForm(inProps) {
|
|
|
186
186
|
const handleGeoData = (0, react_1.useCallback)((data) => {
|
|
187
187
|
setField((prev) => (Object.assign(Object.assign({}, prev), data)));
|
|
188
188
|
}, []);
|
|
189
|
+
const handleLiveStreamSettingsData = (0, react_1.useCallback)((data) => {
|
|
190
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), data)));
|
|
191
|
+
}, []);
|
|
189
192
|
const handleSubmit = (0, react_1.useCallback)(() => {
|
|
190
193
|
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: true })));
|
|
191
194
|
const formData = new FormData();
|
|
@@ -314,7 +317,11 @@ function EventForm(inProps) {
|
|
|
314
317
|
var _a;
|
|
315
318
|
return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endTime)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "access_time" }) }) }))) }), error: Boolean(error['endDateError']), helperText: ((_a = error['endDateError']) === null || _a === void 0 ? void 0 : _a.error) ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.error.invalid", defaultMessage: "ui.eventForm.time.end.error.invalid" })) : null })));
|
|
316
319
|
}
|
|
317
|
-
}, onChange: (value) => handleChangeDateTime(value, 'endTime'), shouldDisableTime: shouldDisabledTime })] })) })), (0, jsx_runtime_1.jsx)(EventAddress_1.default, { forwardGeolocationData: handleGeoData, event: event !== null && event !== void 0 ? event :
|
|
320
|
+
}, onChange: (value) => handleChangeDateTime(value, 'endTime'), shouldDisableTime: shouldDisabledTime })] })) })), (0, jsx_runtime_1.jsx)(EventAddress_1.default, { forwardGeolocationData: handleGeoData, forwardLivestreamSettingsData: handleLiveStreamSettingsData, event: event !== null && event !== void 0 ? event : {
|
|
321
|
+
name: field.name,
|
|
322
|
+
start_date: field.startDate,
|
|
323
|
+
geolocation: field.geolocation
|
|
324
|
+
} }), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.privacySection }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), (0, jsx_runtime_1.jsx)(material_1.Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: event && !field.isPublic }), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
|
|
318
325
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
319
326
|
// @ts-ignore
|
|
320
327
|
b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { SCLiveStreamType } from '@selfcommunity/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { SCLiveStreamTemplateType } from '../../types/liveStream';
|
|
4
|
+
import { WidgetProps } from '../Widget';
|
|
5
|
+
import { LiveStreamSkeletonProps } from './index';
|
|
6
|
+
export interface LiveStreamProps extends WidgetProps {
|
|
7
|
+
/**
|
|
8
|
+
* Event Object
|
|
9
|
+
* @default null
|
|
10
|
+
*/
|
|
11
|
+
liveStream?: SCLiveStreamType;
|
|
12
|
+
/**
|
|
13
|
+
* Id of the liveStream for filter the feed
|
|
14
|
+
* @default null
|
|
15
|
+
*/
|
|
16
|
+
liveStreamId?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Event template type
|
|
19
|
+
* @default 'preview'
|
|
20
|
+
*/
|
|
21
|
+
template?: SCLiveStreamTemplateType;
|
|
22
|
+
/**
|
|
23
|
+
* Actions
|
|
24
|
+
* @default null
|
|
25
|
+
*/
|
|
26
|
+
actions?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Hide in progress
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
hideInProgress?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Hide liveStream planner
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
hideLiveStreamHost?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Props to spread to EventSkeleton component
|
|
39
|
+
* @default {}
|
|
40
|
+
*/
|
|
41
|
+
LiveStreamSkeletonComponentProps?: LiveStreamSkeletonProps;
|
|
42
|
+
/**
|
|
43
|
+
* Any other properties
|
|
44
|
+
*/
|
|
45
|
+
[p: string]: any;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* > API documentation for the Community-JS Live Stream component. Learn about the available props and the CSS API.
|
|
49
|
+
*
|
|
50
|
+
*
|
|
51
|
+
* This component renders an liveStream item.
|
|
52
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/Event)
|
|
53
|
+
|
|
54
|
+
#### Import
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
import {liveStream} from '@selfcommunity/react-ui';
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### Component Name
|
|
61
|
+
|
|
62
|
+
The name `SCLiveStream` can be used when providing style overrides in the theme.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
#### CSS
|
|
66
|
+
|
|
67
|
+
|Rule Name|Global class|Description|
|
|
68
|
+
|---|---|---|
|
|
69
|
+
|root|.SCLiveStream-root|Styles applied to the root element.|
|
|
70
|
+
|avatar|.SCLiveStream-avatar|Styles applied to the avatar element.|
|
|
71
|
+
|primary|.SCLiveStream-primary|Styles applied to the primary item element section|
|
|
72
|
+
|secondary|.SCLiveStream-secondary|Styles applied to the secondary item element section|
|
|
73
|
+
|actions|.SCLiveStream-actions|Styles applied to the actions section.|
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
*
|
|
77
|
+
* @param inProps
|
|
78
|
+
*/
|
|
79
|
+
export default function LiveStream(inProps: LiveStreamProps): JSX.Element;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
|
+
const system_1 = require("@mui/system");
|
|
8
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
9
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const react_intl_1 = require("react-intl");
|
|
12
|
+
const BaseItem_1 = tslib_1.__importDefault(require("../../shared/BaseItem"));
|
|
13
|
+
const Calendar_1 = tslib_1.__importDefault(require("../../shared/Calendar"));
|
|
14
|
+
const liveStream_1 = require("../../types/liveStream");
|
|
15
|
+
const User_1 = tslib_1.__importDefault(require("../User"));
|
|
16
|
+
const Widget_1 = tslib_1.__importDefault(require("../Widget"));
|
|
17
|
+
const constants_1 = require("./constants");
|
|
18
|
+
const index_1 = require("./index");
|
|
19
|
+
const LiveStreamInfoDetails_1 = tslib_1.__importDefault(require("../../shared/LiveStreamInfoDetails"));
|
|
20
|
+
const classes = {
|
|
21
|
+
root: `${constants_1.PREFIX}-root`,
|
|
22
|
+
detailRoot: `${constants_1.PREFIX}-detail-root`,
|
|
23
|
+
previewRoot: `${constants_1.PREFIX}-preview-root`,
|
|
24
|
+
snippetRoot: `${constants_1.PREFIX}-snippet-root`,
|
|
25
|
+
detailImageWrapper: `${constants_1.PREFIX}-detail-image-wrapper`,
|
|
26
|
+
detailImage: `${constants_1.PREFIX}-detail-image`,
|
|
27
|
+
detailInProgress: `${constants_1.PREFIX}-detail-in-progress`,
|
|
28
|
+
detailNameWrapper: `${constants_1.PREFIX}-detail-name-wrapper`,
|
|
29
|
+
detailName: `${constants_1.PREFIX}-detail-name`,
|
|
30
|
+
detailContent: `${constants_1.PREFIX}-detail-content`,
|
|
31
|
+
detailUser: `${constants_1.PREFIX}-detail-user`,
|
|
32
|
+
detailFirstDivider: `${constants_1.PREFIX}-detail-first-divider`,
|
|
33
|
+
detailSecondDivider: `${constants_1.PREFIX}-detail-second-divider`,
|
|
34
|
+
detailActions: `${constants_1.PREFIX}-detail-actions`,
|
|
35
|
+
previewImageWrapper: `${constants_1.PREFIX}-preview-image-wrapper`,
|
|
36
|
+
previewImage: `${constants_1.PREFIX}-preview-image`,
|
|
37
|
+
previewInProgress: `${constants_1.PREFIX}-preview-in-progress`,
|
|
38
|
+
previewNameWrapper: `${constants_1.PREFIX}-preview-name-wrapper`,
|
|
39
|
+
previewName: `${constants_1.PREFIX}-preview-name`,
|
|
40
|
+
previewContent: `${constants_1.PREFIX}-preview-content`,
|
|
41
|
+
previewActions: `${constants_1.PREFIX}-preview-actions`,
|
|
42
|
+
snippetImage: `${constants_1.PREFIX}-snippet-image`,
|
|
43
|
+
snippetAvatar: `${constants_1.PREFIX}-snippet-avatar`,
|
|
44
|
+
snippetInProgress: `${constants_1.PREFIX}-snippet-in-progress`,
|
|
45
|
+
snippetPrimary: `${constants_1.PREFIX}-snippet-primary`,
|
|
46
|
+
snippetSecondary: `${constants_1.PREFIX}-snippet-secondary`,
|
|
47
|
+
snippetActions: `${constants_1.PREFIX}-snippet-actions`
|
|
48
|
+
};
|
|
49
|
+
const Root = (0, styles_1.styled)(Widget_1.default, {
|
|
50
|
+
name: constants_1.PREFIX,
|
|
51
|
+
slot: 'Root',
|
|
52
|
+
overridesResolver: (props, styles) => styles.root
|
|
53
|
+
})(() => ({}));
|
|
54
|
+
const DetailRoot = (0, styles_1.styled)(material_1.Box, {
|
|
55
|
+
name: constants_1.PREFIX,
|
|
56
|
+
slot: 'DetailRoot',
|
|
57
|
+
overridesResolver: (props, styles) => styles.detailRoot
|
|
58
|
+
})(() => ({}));
|
|
59
|
+
const PreviewRoot = (0, styles_1.styled)(material_1.Box, {
|
|
60
|
+
name: constants_1.PREFIX,
|
|
61
|
+
slot: 'PreviewRoot',
|
|
62
|
+
overridesResolver: (props, styles) => styles.previewRoot
|
|
63
|
+
})(() => ({}));
|
|
64
|
+
const SnippetRoot = (0, styles_1.styled)(BaseItem_1.default, {
|
|
65
|
+
name: constants_1.PREFIX,
|
|
66
|
+
slot: 'SnippetRoot',
|
|
67
|
+
overridesResolver: (props, styles) => styles.snippetRoot
|
|
68
|
+
})(() => ({}));
|
|
69
|
+
/**
|
|
70
|
+
* > API documentation for the Community-JS Live Stream component. Learn about the available props and the CSS API.
|
|
71
|
+
*
|
|
72
|
+
*
|
|
73
|
+
* This component renders an liveStream item.
|
|
74
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/Event)
|
|
75
|
+
|
|
76
|
+
#### Import
|
|
77
|
+
|
|
78
|
+
```jsx
|
|
79
|
+
import {liveStream} from '@selfcommunity/react-ui';
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Component Name
|
|
83
|
+
|
|
84
|
+
The name `SCLiveStream` can be used when providing style overrides in the theme.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
#### CSS
|
|
88
|
+
|
|
89
|
+
|Rule Name|Global class|Description|
|
|
90
|
+
|---|---|---|
|
|
91
|
+
|root|.SCLiveStream-root|Styles applied to the root element.|
|
|
92
|
+
|avatar|.SCLiveStream-avatar|Styles applied to the avatar element.|
|
|
93
|
+
|primary|.SCLiveStream-primary|Styles applied to the primary item element section|
|
|
94
|
+
|secondary|.SCLiveStream-secondary|Styles applied to the secondary item element section|
|
|
95
|
+
|actions|.SCLiveStream-actions|Styles applied to the actions section.|
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
*
|
|
99
|
+
* @param inProps
|
|
100
|
+
*/
|
|
101
|
+
function LiveStream(inProps) {
|
|
102
|
+
// PROPS
|
|
103
|
+
const props = (0, system_1.useThemeProps)({
|
|
104
|
+
props: inProps,
|
|
105
|
+
name: constants_1.PREFIX
|
|
106
|
+
});
|
|
107
|
+
const { id = `live_stream_object_${props.liveStreamId ? props.liveStreamId : props.liveStream ? props.liveStream.id : ''}`, liveStreamId = null, liveStream = null, className = null, template = liveStream_1.SCLiveStreamTemplateType.SNIPPET, hideInProgress = false, hideLiveStreamHost = false, actions, EventSkeletonComponentProps = {} } = props, rest = tslib_1.__rest(props, ["id", "liveStreamId", "liveStream", "className", "template", "hideInProgress", "hideLiveStreamHost", "actions", "EventSkeletonComponentProps"]);
|
|
108
|
+
// STATE
|
|
109
|
+
const { scLiveStream } = (0, react_core_1.useSCFetchLiveStream)({ id: liveStreamId, liveStream });
|
|
110
|
+
const inProgress = (0, react_1.useMemo)(() => scLiveStream /* && scLiveStream.running */, [scLiveStream]);
|
|
111
|
+
// CONTEXT
|
|
112
|
+
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
113
|
+
// HOOKS
|
|
114
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
115
|
+
/**
|
|
116
|
+
* Renders liveStream object
|
|
117
|
+
*/
|
|
118
|
+
if (!scLiveStream) {
|
|
119
|
+
return (0, jsx_runtime_1.jsx)(index_1.LiveStreamSkeleton, Object.assign({ template: template }, EventSkeletonComponentProps, rest, { actions: actions }));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Renders liveStream object
|
|
123
|
+
*/
|
|
124
|
+
let contentObj;
|
|
125
|
+
if (template === liveStream_1.SCLiveStreamTemplateType.DETAIL) {
|
|
126
|
+
contentObj = ((0, jsx_runtime_1.jsxs)(DetailRoot, Object.assign({ className: classes.detailRoot }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.detailImageWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.CardMedia, { component: "img", image: scLiveStream.cover, alt: scLiveStream.title, className: classes.detailImage }), !hideInProgress && inProgress && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", component: "div", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStream.inProgress", defaultMessage: "ui.liveStream.inProgress" }), className: classes.detailInProgress })), (0, jsx_runtime_1.jsx)(Calendar_1.default, { day: new Date(scLiveStream.created_at).getDate() })] })), (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.detailContent }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.detailNameWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scLiveStream.title })) })), (0, jsx_runtime_1.jsx)(LiveStreamInfoDetails_1.default, { liveStream: scLiveStream }), !hideLiveStreamHost && ((0, jsx_runtime_1.jsx)(User_1.default, { user: scLiveStream.host, elevation: 0, secondary: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "caption" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.myEventsWidget.planner", defaultMessage: "ui.myEventsWidget.planner" }) })), actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), className: classes.detailUser })), (0, jsx_runtime_1.jsx)(material_1.Divider, { className: classes.detailSecondDivider })] })), actions !== null && actions !== void 0 ? actions : ((0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.detailActions }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "outlined", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.LIVESTREAM_ROUTE_NAME, scLiveStream) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.liveStream.see", id: "ui.liveStream.see" }) })) })))] })));
|
|
127
|
+
}
|
|
128
|
+
else if (template === liveStream_1.SCLiveStreamTemplateType.PREVIEW) {
|
|
129
|
+
contentObj = ((0, jsx_runtime_1.jsxs)(PreviewRoot, Object.assign({ className: classes.previewRoot }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ position: "relative", className: classes.previewImageWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.CardMedia, { component: "img", image: scLiveStream.cover, alt: scLiveStream.title, className: classes.previewImage }), !hideInProgress && inProgress && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", component: "div", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStream.inProgress", defaultMessage: "ui.liveStream.inProgress" }), className: classes.previewInProgress }))] })), (0, jsx_runtime_1.jsx)(material_1.CardContent, Object.assign({ className: classes.previewContent }, { children: (0, jsx_runtime_1.jsx)(LiveStreamInfoDetails_1.default, { liveStream: scLiveStream, hasLocationInfo: false, beforeDateInfo: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, scLiveStream), className: classes.previewNameWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.previewName }, { children: scLiveStream.title })) })) }) })), actions !== null && actions !== void 0 ? actions : ((0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.previewActions }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "outlined", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, scLiveStream) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.liveStream.see", id: "ui.liveStream.see" }) })) })))] })));
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
contentObj = ((0, jsx_runtime_1.jsx)(SnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.snippetRoot, image: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.snippetImage }, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "square", alt: scLiveStream.title, src: scLiveStream.cover, className: classes.snippetAvatar }), ' ', !hideInProgress && inProgress && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", component: "div", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStream.inProgress", defaultMessage: "ui.liveStream.inProgress" }), className: classes.snippetInProgress }))] })), primary: (0, jsx_runtime_1.jsxs)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, scLiveStream), className: classes.snippetPrimary }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "span" }, { children: `${intl.formatDate(scLiveStream.created_at, {
|
|
133
|
+
weekday: 'long',
|
|
134
|
+
month: 'long',
|
|
135
|
+
day: 'numeric'
|
|
136
|
+
})}` })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: scLiveStream.title }))] })), secondary: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "p", variant: "body2", className: classes.snippetSecondary }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.address.liveStream.label`, defaultMessage: `ui.eventForm.address.liveStream.label` }) })), actions: actions !== null && actions !== void 0 ? actions : ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.snippetActions }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "outlined", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.LIVESTREAM_ROUTE_NAME, scLiveStream) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.liveStream.see", id: "ui.liveStream.see" }) })) }))) }));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Renders root object
|
|
140
|
+
*/
|
|
141
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-${template}`) }, rest, { children: contentObj })));
|
|
142
|
+
}
|
|
143
|
+
exports.default = LiveStream;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SCLiveStreamTemplateType } from '../../types/liveStream';
|
|
3
|
+
import { WidgetProps } from '../Widget';
|
|
4
|
+
export interface LiveStreamSkeletonProps extends WidgetProps {
|
|
5
|
+
/**
|
|
6
|
+
* Overrides or extends the styles applied to the component.
|
|
7
|
+
* @default null
|
|
8
|
+
*/
|
|
9
|
+
className?: string;
|
|
10
|
+
/**
|
|
11
|
+
* LiveStream template type
|
|
12
|
+
* @default 'preview'
|
|
13
|
+
*/
|
|
14
|
+
template?: SCLiveStreamTemplateType;
|
|
15
|
+
/**
|
|
16
|
+
* Disable skeleton animation
|
|
17
|
+
*/
|
|
18
|
+
skeletonsAnimation?: false | 'wave' | 'pulse';
|
|
19
|
+
/**
|
|
20
|
+
* Prop to pass an action to be rendered next to the skeleton
|
|
21
|
+
*/
|
|
22
|
+
actions?: React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* > API documentation for the Community-JS LiveStream Skeleton component. Learn about the available props and the CSS API.
|
|
26
|
+
|
|
27
|
+
#### Import
|
|
28
|
+
|
|
29
|
+
```jsx
|
|
30
|
+
import {LiveStreamSkeleton} from '@selfcommunity/react-ui';
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
#### Component Name
|
|
34
|
+
|
|
35
|
+
The name `SCLiveStream-skeleton-root` can be used when providing style overrides in the theme.
|
|
36
|
+
|
|
37
|
+
#### CSS
|
|
38
|
+
|
|
39
|
+
|Rule Name|Global class|Description|
|
|
40
|
+
|---|---|---|
|
|
41
|
+
|root|.SCLiveStream-skeleton-root|Styles applied to the root element.|
|
|
42
|
+
|image|.SCLiveStream-skeleton-image|Styles applied to the image element.|
|
|
43
|
+
|action|.SCLiveStream-skeleton-action|Styles applied to action section.|
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
export default function LiveStreamSkeleton(inProps: LiveStreamSkeletonProps): JSX.Element;
|