/**
* WordPress dependencies
*/
import { Popover, SlotFillProvider } from '@safe-wordpress/components';
import { useSelect } from '@safe-wordpress/data';
import { StrictMode } from '@safe-wordpress/element';
/**
* External dependencies
*/
import clsx from 'clsx';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import { store as NC_CALENDAR } from '@nelio-content/calendar';
import { store as NC_DATA } from '@nelio-content/data';
import {
getPremiumComponent,
ContextualHelp,
PremiumDialog,
} from '@nelio-content/components';
import { PostQuickEditor } from '@nelio-content/post-quick-editor';
import { SocialMessageEditor } from '@nelio-content/social-message-editor';
import { TaskEditor } from '@nelio-content/task-editor';
/**
* Internal dependencies
*/
import './style.scss';
import { walkthrough } from '../../walkthrough';
import { Header } from '../header';
import { Grid } from '../grid';
import { SidePane } from '../side-pane';
import { ExportDialog } from '../export-dialog';
import { ExternalCalendarManager } from '../external-calendar-manager';
import { RecurringDialog } from '../recurring-dialog';
import { TaskViewer } from '../task-viewer';
import { ReviewDialog } from '../review-dialog';
export const Layout = ( {
reviewNoticeUrl,
}: {
readonly reviewNoticeUrl: string | false;
} ): JSX.Element => {
const FutureActionEditor = getPremiumComponent(
'calendar/future-action-editor',
'null'
);
const isRefreshing = useIsRefreshing();
const columnCount = useSelect(
( select ) =>
'agenda' === select( NC_CALENDAR ).getCalendarMode() ? 4 : 7,
[]
);
return (
{ reviewNoticeUrl && }
null }
autostart={ true }
walkthrough={ walkthrough }
/>
);
};
// =====
// HOOKS
// =====
// NOTE: This is a TS workaround.
const DndProviderHelper = ( { children }: { children: JSX.Element } ) => (
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore:next-line
{ children }
);
const useIsRefreshing = () =>
useSelect( ( select ) => {
const firstDayOfWeek = select( NC_DATA ).getFirstDayOfWeek();
const firstDay = select( NC_CALENDAR ).getFirstDay( firstDayOfWeek );
const lastDay = select( NC_CALENDAR ).getLastDay( firstDayOfWeek );
return select( NC_CALENDAR ).hasPeriodCachedContent(
firstDay,
lastDay
);
}, [] );