@selfcommunity/react-ui 0.8.0-embeds.16 → 0.8.0-embeds.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.
@@ -503,6 +503,8 @@ function Composer(inProps) {
503
503
  }
504
504
  else {
505
505
  onClose && onClose(e);
506
+ setLayer(null);
507
+ dispatch({ type: 'reset' });
506
508
  /*setLayer(null);
507
509
  feedType && feedType === SCFeedTypologyType.CATEGORY
508
510
  ? dispatch({type: 'resetCategoryFeed'})
@@ -26,6 +26,12 @@ const Skeleton_2 = tslib_1.__importDefault(require("./Skeleton"));
26
26
  const use_deep_compare_effect_1 = require("use-deep-compare-effect");
27
27
  const StickyBox_1 = tslib_1.__importDefault(require("../../shared/StickyBox"));
28
28
  const constants_1 = require("./constants");
29
+ const messages = (0, react_intl_1.defineMessages)({
30
+ refresh: {
31
+ id: 'ui.feed.refreshRelease',
32
+ defaultMessage: 'ui.feed.refreshRelease'
33
+ }
34
+ });
29
35
  const classes = {
30
36
  root: `${constants_1.PREFIX}-root`,
31
37
  left: `${constants_1.PREFIX}-left`,
@@ -78,7 +84,9 @@ const Feed = (inProps, ref) => {
78
84
  props: inProps,
79
85
  name: constants_1.PREFIX
80
86
  });
81
- const { id = 'feed', className, endpoint, endpointQueryParams = { limit: Pagination_1.DEFAULT_PAGINATION_LIMIT, offset: Pagination_1.DEFAULT_PAGINATION_OFFSET }, endMessage = (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.feed.noOtherFeedObject", defaultMessage: "ui.feed.noOtherFeedObject" }), refreshMessage = (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.feed.refreshRelease", defaultMessage: "ui.feed.refreshRelease" }), HeaderComponent, FooterComponent = Footer_1.default, FooterComponentProps = {}, widgets = [], ItemComponent, itemPropsGenerator, itemIdGenerator, ItemProps = {}, ItemSkeleton, ItemSkeletonProps = {}, onNextData, onPreviousData, FeedSidebarProps = {}, CustomAdvProps = {}, enabledCustomAdvPositions = [types_1.SCCustomAdvPosition.POSITION_FEED_SIDEBAR, types_1.SCCustomAdvPosition.POSITION_FEED], requireAuthentication = false, cacheStrategy = utils_1.CacheStrategies.NETWORK_ONLY, prefetchedData, scrollableTargetId, VirtualizedScrollerProps = {}, disablePaginationLinks = false, hidePaginationLinks = true, paginationLinksPageQueryParam = Pagination_1.DEFAULT_PAGINATION_QUERY_PARAM_NAME, PaginationLinkProps = {}, hideAdvs = false, emptyFeedPlaceholder } = props;
87
+ // HOOKS
88
+ const intl = (0, react_intl_1.useIntl)();
89
+ const { id = 'feed', className, endpoint, endpointQueryParams = { limit: Pagination_1.DEFAULT_PAGINATION_LIMIT, offset: Pagination_1.DEFAULT_PAGINATION_OFFSET }, endMessage = (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.feed.noOtherFeedObject", defaultMessage: "ui.feed.noOtherFeedObject" }), refreshMessage = (0, jsx_runtime_1.jsx)(material_1.Typography, { dangerouslySetInnerHTML: { __html: `${intl.formatMessage(messages.refresh)}` } }), HeaderComponent, FooterComponent = Footer_1.default, FooterComponentProps = {}, widgets = [], ItemComponent, itemPropsGenerator, itemIdGenerator, ItemProps = {}, ItemSkeleton, ItemSkeletonProps = {}, onNextData, onPreviousData, FeedSidebarProps = {}, CustomAdvProps = {}, enabledCustomAdvPositions = [types_1.SCCustomAdvPosition.POSITION_FEED_SIDEBAR, types_1.SCCustomAdvPosition.POSITION_FEED], requireAuthentication = false, cacheStrategy = utils_1.CacheStrategies.NETWORK_ONLY, prefetchedData, scrollableTargetId, VirtualizedScrollerProps = {}, disablePaginationLinks = false, hidePaginationLinks = true, paginationLinksPageQueryParam = Pagination_1.DEFAULT_PAGINATION_QUERY_PARAM_NAME, PaginationLinkProps = {}, hideAdvs = false, emptyFeedPlaceholder } = props;
82
90
  // CONTEXT
83
91
  const scPreferences = (0, react_1.useContext)(react_core_1.SCPreferencesContext);
84
92
  const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
@@ -119,7 +119,7 @@ function NavigationToolbar(inProps) {
119
119
  const eventsEnabled = (0, react_1.useMemo)(() => scPreferences.preferences &&
120
120
  scPreferences.features &&
121
121
  scPreferences.features.includes(types_1.SCFeatureName.TAGGING) &&
122
- react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
122
+ react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in scPreferences.preferences &&
123
123
  scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [scPreferences.preferences, scPreferences.features]);
124
124
  const showComposer = (0, react_1.useMemo)(() => {
125
125
  return (!disableComposer &&
@@ -53,6 +53,8 @@ function EventNotification(props) {
53
53
  }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar, classes: { root: classes.avatar } }) })) })), primary: (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
54
54
  to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
55
55
  }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.notification.event.${notificationObject.type}`, defaultMessage: `ui.notification.event.${notificationObject.type}`, values: {
56
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
57
+ // @ts-ignore
56
58
  icon: (...chunks) => (0, jsx_runtime_1.jsx)(material_1.Icon, { children: chunks }),
57
59
  event: notificationObject.event.name,
58
60
  link: (...chunks) => (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
@@ -71,6 +73,8 @@ function EventNotification(props) {
71
73
  }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { className: classes.avatar, alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar }) })) })), primary: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
72
74
  to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
73
75
  }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.notification.${notificationObject.type}`, defaultMessage: `ui.notification.${notificationObject.type}`, values: {
76
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
77
+ // @ts-ignore
74
78
  icon: (...chunks) => (0, jsx_runtime_1.jsx)(material_1.Icon, { children: chunks }),
75
79
  event: notificationObject.event.name,
76
80
  link: (...chunks) => (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
@@ -18,6 +18,11 @@ export interface OnBoardingWidgetProps extends VirtualScrollerItemProps {
18
18
  * @default null
19
19
  */
20
20
  onGeneratedContent?: (feedObjs: SCFeedObjectType[]) => void;
21
+ /**
22
+ * Force widget expanded
23
+ * @default false
24
+ */
25
+ forceExpanded?: boolean;
21
26
  }
22
27
  declare const OnBoardingWidget: (inProps: OnBoardingWidgetProps) => JSX.Element;
23
28
  export default OnBoardingWidget;
@@ -53,7 +53,7 @@ const OnBoardingWidget = (inProps) => {
53
53
  props: inProps,
54
54
  name: constants_1.PREFIX
55
55
  });
56
- const { className, GenerateContentsParams = {}, onGeneratedContent = null, onHeightChange } = props, rest = tslib_1.__rest(props, ["className", "GenerateContentsParams", "onGeneratedContent", "onHeightChange"]);
56
+ const { className, GenerateContentsParams = {}, onGeneratedContent = null, onHeightChange, onStateChange, forceExpanded = false } = props, rest = tslib_1.__rest(props, ["className", "GenerateContentsParams", "onGeneratedContent", "onHeightChange", "onStateChange", "forceExpanded"]);
57
57
  // STATE
58
58
  const [loading, setLoading] = (0, react_1.useState)(true);
59
59
  const [initialized, setInitialized] = (0, react_1.useState)(false);
@@ -65,7 +65,7 @@ const OnBoardingWidget = (inProps) => {
65
65
  const allStepsDone = (0, react_1.useMemo)(() => {
66
66
  return steps === null || steps === void 0 ? void 0 : steps.every((step) => step.status === types_1.SCOnBoardingStepStatusType.COMPLETED);
67
67
  }, [steps]);
68
- const [expanded, setExpanded] = (0, react_1.useState)(!allStepsDone);
68
+ const [expanded, setExpanded] = (0, react_1.useState)(!allStepsDone || forceExpanded);
69
69
  const [_step, setStep] = (0, react_1.useState)(nextStep);
70
70
  const currentContentsStep = steps === null || steps === void 0 ? void 0 : steps.find((s) => s.step === types_1.SCOnBoardingStepType.CONTENTS);
71
71
  const prevContentsStep = (0, react_core_1.usePreviousValue)(currentContentsStep);
@@ -86,6 +86,15 @@ const OnBoardingWidget = (inProps) => {
86
86
  const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
87
87
  const { categories, isLoading } = (0, react_core_1.useSCFetchCategories)();
88
88
  // HANDLERS
89
+ /**
90
+ * Notify changes to Feed if the Widget is contained
91
+ */
92
+ const notifyLayoutChanges = (0, react_1.useMemo)(() => (state) => {
93
+ if (onStateChange && state) {
94
+ onStateChange(state);
95
+ }
96
+ onHeightChange && onHeightChange();
97
+ }, [onStateChange, onHeightChange]);
89
98
  const completeStep = (s) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
90
99
  if (s.status !== types_1.SCOnBoardingStepStatusType.COMPLETED) {
91
100
  yield api_services_1.OnBoardingService.completeAStep(s.id)
@@ -131,8 +140,9 @@ const OnBoardingWidget = (inProps) => {
131
140
  setStep(newStep);
132
141
  };
133
142
  const handleExpand = () => {
134
- setExpanded(!expanded);
135
- onHeightChange && onHeightChange();
143
+ const _expanded = !expanded;
144
+ setExpanded(_expanded);
145
+ notifyLayoutChanges({ forceExpanded: _expanded });
136
146
  };
137
147
  const generateContent = (stepId) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
138
148
  if (!isLoading && !categories.length) {
@@ -178,11 +188,13 @@ const OnBoardingWidget = (inProps) => {
178
188
  if (!initialized && nextStep) {
179
189
  setStep(nextStep);
180
190
  setInitialized(true);
191
+ notifyLayoutChanges({ forceExpanded: expanded });
181
192
  }
182
193
  }, [initialized, nextStep]);
183
194
  (0, react_1.useEffect)(() => {
184
- setExpanded(!allStepsDone);
185
- onHeightChange && onHeightChange();
195
+ const _expanded = !allStepsDone;
196
+ setExpanded(_expanded);
197
+ notifyLayoutChanges({ forceExpanded: _expanded });
186
198
  }, [allStepsDone]);
187
199
  (0, react_1.useEffect)(() => {
188
200
  if (isAdmin) {
@@ -225,7 +225,7 @@ class InfiniteScroll extends react_1.Component {
225
225
  // because heighted infiniteScroll visualy breaks
226
226
  // on drag down as overflow becomes visible
227
227
  const outerDivStyle = this.props.pullDownToRefresh && this.props.height ? { overflow: 'auto' } : {};
228
- return ((0, jsx_runtime_1.jsx)("div", Object.assign({ style: outerDivStyle, className: "infinite-scroll-component__outerdiv" }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `infinite-scroll-component ${this.props.className || ''}`, ref: (infScroll) => (this._infScroll = infScroll), style: style }, { children: [this.props.header, this.props.pullDownToRefresh && ((0, jsx_runtime_1.jsx)("div", Object.assign({ style: { position: 'relative' }, ref: (pullDown) => (this._pullDown = pullDown) }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ style: {
228
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({ style: outerDivStyle, className: "infinite-scroll-component__outerdiv" }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `infinite-scroll-component ${this.props.className || ''}`, ref: (infScroll) => (this._infScroll = infScroll), style: style }, { children: [this.props.header, this.props.pullDownToRefresh && ((0, jsx_runtime_1.jsx)("div", Object.assign({ style: { position: 'relative', marginBottom: 16 }, ref: (pullDown) => (this._pullDown = pullDown) }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ style: {
229
229
  position: 'absolute',
230
230
  left: 0,
231
231
  right: 0,
@@ -5,8 +5,8 @@ const getRelativeTime = (date) => {
5
5
  const diffInMilliseconds = new Date().getTime() - new Date(date).getTime();
6
6
  const seconds = Math.floor(diffInMilliseconds / 1000);
7
7
  const minutes = Math.floor(seconds / 60);
8
- const hours = Math.ceil(minutes / 60);
9
- const days = Math.floor(hours / 24);
8
+ const hours = Math.floor(minutes / 60);
9
+ const days = Math.round(hours / 24);
10
10
  const weeks = Math.floor(days / 7);
11
11
  const months = Math.floor(days / 30);
12
12
  const years = Math.floor(months / 12);
@@ -501,6 +501,8 @@ export default function Composer(inProps) {
501
501
  }
502
502
  else {
503
503
  onClose && onClose(e);
504
+ setLayer(null);
505
+ dispatch({ type: 'reset' });
504
506
  /*setLayer(null);
505
507
  feedType && feedType === SCFeedTypologyType.CATEGORY
506
508
  ? dispatch({type: 'resetCategoryFeed'})
@@ -3,8 +3,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
3
3
  import React, { forwardRef, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
4
4
  import { Link, SCCache, SCPreferences, SCPreferencesContext, SCUserContext, useIsComponentMountedRef, usePreviousValue, useSCFetchFeed } from '@selfcommunity/react-core';
5
5
  import { styled, useTheme } from '@mui/material/styles';
6
- import { Box, CardContent, Grid, Hidden, useMediaQuery } from '@mui/material';
7
- import { FormattedMessage } from 'react-intl';
6
+ import { Box, CardContent, Grid, Hidden, Typography, useMediaQuery } from '@mui/material';
7
+ import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
8
8
  import { GenericSkeleton } from '../Skeleton';
9
9
  import CustomAdv from '../CustomAdv';
10
10
  import { SCCustomAdvPosition } from '@selfcommunity/types';
@@ -23,6 +23,12 @@ import FeedSkeleton from './Skeleton';
23
23
  import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
24
24
  import StickyBoxComp from '../../shared/StickyBox';
25
25
  import { PREFIX } from './constants';
26
+ const messages = defineMessages({
27
+ refresh: {
28
+ id: 'ui.feed.refreshRelease',
29
+ defaultMessage: 'ui.feed.refreshRelease'
30
+ }
31
+ });
26
32
  const classes = {
27
33
  root: `${PREFIX}-root`,
28
34
  left: `${PREFIX}-left`,
@@ -75,7 +81,9 @@ const Feed = (inProps, ref) => {
75
81
  props: inProps,
76
82
  name: PREFIX
77
83
  });
78
- const { id = 'feed', className, endpoint, endpointQueryParams = { limit: DEFAULT_PAGINATION_LIMIT, offset: DEFAULT_PAGINATION_OFFSET }, endMessage = _jsx(FormattedMessage, { id: "ui.feed.noOtherFeedObject", defaultMessage: "ui.feed.noOtherFeedObject" }), refreshMessage = _jsx(FormattedMessage, { id: "ui.feed.refreshRelease", defaultMessage: "ui.feed.refreshRelease" }), HeaderComponent, FooterComponent = Footer, FooterComponentProps = {}, widgets = [], ItemComponent, itemPropsGenerator, itemIdGenerator, ItemProps = {}, ItemSkeleton, ItemSkeletonProps = {}, onNextData, onPreviousData, FeedSidebarProps = {}, CustomAdvProps = {}, enabledCustomAdvPositions = [SCCustomAdvPosition.POSITION_FEED_SIDEBAR, SCCustomAdvPosition.POSITION_FEED], requireAuthentication = false, cacheStrategy = CacheStrategies.NETWORK_ONLY, prefetchedData, scrollableTargetId, VirtualizedScrollerProps = {}, disablePaginationLinks = false, hidePaginationLinks = true, paginationLinksPageQueryParam = DEFAULT_PAGINATION_QUERY_PARAM_NAME, PaginationLinkProps = {}, hideAdvs = false, emptyFeedPlaceholder } = props;
84
+ // HOOKS
85
+ const intl = useIntl();
86
+ const { id = 'feed', className, endpoint, endpointQueryParams = { limit: DEFAULT_PAGINATION_LIMIT, offset: DEFAULT_PAGINATION_OFFSET }, endMessage = _jsx(FormattedMessage, { id: "ui.feed.noOtherFeedObject", defaultMessage: "ui.feed.noOtherFeedObject" }), refreshMessage = _jsx(Typography, { dangerouslySetInnerHTML: { __html: `${intl.formatMessage(messages.refresh)}` } }), HeaderComponent, FooterComponent = Footer, FooterComponentProps = {}, widgets = [], ItemComponent, itemPropsGenerator, itemIdGenerator, ItemProps = {}, ItemSkeleton, ItemSkeletonProps = {}, onNextData, onPreviousData, FeedSidebarProps = {}, CustomAdvProps = {}, enabledCustomAdvPositions = [SCCustomAdvPosition.POSITION_FEED_SIDEBAR, SCCustomAdvPosition.POSITION_FEED], requireAuthentication = false, cacheStrategy = CacheStrategies.NETWORK_ONLY, prefetchedData, scrollableTargetId, VirtualizedScrollerProps = {}, disablePaginationLinks = false, hidePaginationLinks = true, paginationLinksPageQueryParam = DEFAULT_PAGINATION_QUERY_PARAM_NAME, PaginationLinkProps = {}, hideAdvs = false, emptyFeedPlaceholder } = props;
79
87
  // CONTEXT
80
88
  const scPreferences = useContext(SCPreferencesContext);
81
89
  const scUserContext = useContext(SCUserContext);
@@ -117,7 +117,7 @@ export default function NavigationToolbar(inProps) {
117
117
  const eventsEnabled = useMemo(() => scPreferences.preferences &&
118
118
  scPreferences.features &&
119
119
  scPreferences.features.includes(SCFeatureName.TAGGING) &&
120
- SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
120
+ SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in scPreferences.preferences &&
121
121
  scPreferences.preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [scPreferences.preferences, scPreferences.features]);
122
122
  const showComposer = useMemo(() => {
123
123
  return (!disableComposer &&
@@ -51,6 +51,8 @@ export default function EventNotification(props) {
51
51
  }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: _jsx(Avatar, { alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar, classes: { root: classes.avatar } }) })) })), primary: _jsxs(Box, { children: [_jsx(Link, Object.assign({}, (!notificationObject.user.deleted && {
52
52
  to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
53
53
  }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', _jsx(FormattedMessage, { id: `ui.notification.event.${notificationObject.type}`, defaultMessage: `ui.notification.event.${notificationObject.type}`, values: {
54
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
55
+ // @ts-ignore
54
56
  icon: (...chunks) => _jsx(Icon, { children: chunks }),
55
57
  event: notificationObject.event.name,
56
58
  link: (...chunks) => _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
@@ -69,6 +71,8 @@ export default function EventNotification(props) {
69
71
  }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: _jsx(Avatar, { className: classes.avatar, alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar }) })) })), primary: _jsxs(_Fragment, { children: [_jsx(Link, Object.assign({}, (!notificationObject.user.deleted && {
70
72
  to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
71
73
  }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', _jsx(FormattedMessage, { id: `ui.notification.${notificationObject.type}`, defaultMessage: `ui.notification.${notificationObject.type}`, values: {
74
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
75
+ // @ts-ignore
72
76
  icon: (...chunks) => _jsx(Icon, { children: chunks }),
73
77
  event: notificationObject.event.name,
74
78
  link: (...chunks) => _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
@@ -18,6 +18,11 @@ export interface OnBoardingWidgetProps extends VirtualScrollerItemProps {
18
18
  * @default null
19
19
  */
20
20
  onGeneratedContent?: (feedObjs: SCFeedObjectType[]) => void;
21
+ /**
22
+ * Force widget expanded
23
+ * @default false
24
+ */
25
+ forceExpanded?: boolean;
21
26
  }
22
27
  declare const OnBoardingWidget: (inProps: OnBoardingWidgetProps) => JSX.Element;
23
28
  export default OnBoardingWidget;
@@ -51,7 +51,7 @@ const OnBoardingWidget = (inProps) => {
51
51
  props: inProps,
52
52
  name: PREFIX
53
53
  });
54
- const { className, GenerateContentsParams = {}, onGeneratedContent = null, onHeightChange } = props, rest = __rest(props, ["className", "GenerateContentsParams", "onGeneratedContent", "onHeightChange"]);
54
+ const { className, GenerateContentsParams = {}, onGeneratedContent = null, onHeightChange, onStateChange, forceExpanded = false } = props, rest = __rest(props, ["className", "GenerateContentsParams", "onGeneratedContent", "onHeightChange", "onStateChange", "forceExpanded"]);
55
55
  // STATE
56
56
  const [loading, setLoading] = useState(true);
57
57
  const [initialized, setInitialized] = useState(false);
@@ -63,7 +63,7 @@ const OnBoardingWidget = (inProps) => {
63
63
  const allStepsDone = useMemo(() => {
64
64
  return steps === null || steps === void 0 ? void 0 : steps.every((step) => step.status === SCOnBoardingStepStatusType.COMPLETED);
65
65
  }, [steps]);
66
- const [expanded, setExpanded] = useState(!allStepsDone);
66
+ const [expanded, setExpanded] = useState(!allStepsDone || forceExpanded);
67
67
  const [_step, setStep] = useState(nextStep);
68
68
  const currentContentsStep = steps === null || steps === void 0 ? void 0 : steps.find((s) => s.step === SCOnBoardingStepType.CONTENTS);
69
69
  const prevContentsStep = usePreviousValue(currentContentsStep);
@@ -84,6 +84,15 @@ const OnBoardingWidget = (inProps) => {
84
84
  const isMobile = useMediaQuery(theme.breakpoints.down('md'));
85
85
  const { categories, isLoading } = useSCFetchCategories();
86
86
  // HANDLERS
87
+ /**
88
+ * Notify changes to Feed if the Widget is contained
89
+ */
90
+ const notifyLayoutChanges = useMemo(() => (state) => {
91
+ if (onStateChange && state) {
92
+ onStateChange(state);
93
+ }
94
+ onHeightChange && onHeightChange();
95
+ }, [onStateChange, onHeightChange]);
87
96
  const completeStep = (s) => __awaiter(void 0, void 0, void 0, function* () {
88
97
  if (s.status !== SCOnBoardingStepStatusType.COMPLETED) {
89
98
  yield OnBoardingService.completeAStep(s.id)
@@ -129,8 +138,9 @@ const OnBoardingWidget = (inProps) => {
129
138
  setStep(newStep);
130
139
  };
131
140
  const handleExpand = () => {
132
- setExpanded(!expanded);
133
- onHeightChange && onHeightChange();
141
+ const _expanded = !expanded;
142
+ setExpanded(_expanded);
143
+ notifyLayoutChanges({ forceExpanded: _expanded });
134
144
  };
135
145
  const generateContent = (stepId) => __awaiter(void 0, void 0, void 0, function* () {
136
146
  if (!isLoading && !categories.length) {
@@ -176,11 +186,13 @@ const OnBoardingWidget = (inProps) => {
176
186
  if (!initialized && nextStep) {
177
187
  setStep(nextStep);
178
188
  setInitialized(true);
189
+ notifyLayoutChanges({ forceExpanded: expanded });
179
190
  }
180
191
  }, [initialized, nextStep]);
181
192
  useEffect(() => {
182
- setExpanded(!allStepsDone);
183
- onHeightChange && onHeightChange();
193
+ const _expanded = !allStepsDone;
194
+ setExpanded(_expanded);
195
+ notifyLayoutChanges({ forceExpanded: _expanded });
184
196
  }, [allStepsDone]);
185
197
  useEffect(() => {
186
198
  if (isAdmin) {
@@ -223,7 +223,7 @@ class InfiniteScroll extends Component {
223
223
  // because heighted infiniteScroll visualy breaks
224
224
  // on drag down as overflow becomes visible
225
225
  const outerDivStyle = this.props.pullDownToRefresh && this.props.height ? { overflow: 'auto' } : {};
226
- return (_jsx("div", Object.assign({ style: outerDivStyle, className: "infinite-scroll-component__outerdiv" }, { children: _jsxs("div", Object.assign({ className: `infinite-scroll-component ${this.props.className || ''}`, ref: (infScroll) => (this._infScroll = infScroll), style: style }, { children: [this.props.header, this.props.pullDownToRefresh && (_jsx("div", Object.assign({ style: { position: 'relative' }, ref: (pullDown) => (this._pullDown = pullDown) }, { children: _jsx("div", Object.assign({ style: {
226
+ return (_jsx("div", Object.assign({ style: outerDivStyle, className: "infinite-scroll-component__outerdiv" }, { children: _jsxs("div", Object.assign({ className: `infinite-scroll-component ${this.props.className || ''}`, ref: (infScroll) => (this._infScroll = infScroll), style: style }, { children: [this.props.header, this.props.pullDownToRefresh && (_jsx("div", Object.assign({ style: { position: 'relative', marginBottom: 16 }, ref: (pullDown) => (this._pullDown = pullDown) }, { children: _jsx("div", Object.assign({ style: {
227
227
  position: 'absolute',
228
228
  left: 0,
229
229
  right: 0,
@@ -2,8 +2,8 @@ export const getRelativeTime = (date) => {
2
2
  const diffInMilliseconds = new Date().getTime() - new Date(date).getTime();
3
3
  const seconds = Math.floor(diffInMilliseconds / 1000);
4
4
  const minutes = Math.floor(seconds / 60);
5
- const hours = Math.ceil(minutes / 60);
6
- const days = Math.floor(hours / 24);
5
+ const hours = Math.floor(minutes / 60);
6
+ const days = Math.round(hours / 24);
7
7
  const weeks = Math.floor(days / 7);
8
8
  const months = Math.floor(days / 30);
9
9
  const years = Math.floor(months / 12);