@elementor/editor-site-navigation 4.5.0-1251 → 4.5.0-1253
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/dist/index.d.mts +30 -13
- package/dist/index.d.ts +30 -13
- package/dist/index.js +1215 -1018
- package/dist/index.mjs +1146 -955
- package/package.json +12 -12
- package/src/components/panel/content-panel-chrome.ts +32 -8
- package/src/components/panel/content-panel-section-header-actions.tsx +22 -0
- package/src/components/panel/content-panel-section-toolbar.tsx +33 -3
- package/src/components/panel/posts-list/list-items/list-item-view.tsx +18 -8
- package/src/components/panel/posts-list/posts-collapsible-list.tsx +54 -21
- package/src/components/panel/shell-panel-body-content.tsx +21 -29
- package/src/components/panel/shell.tsx +103 -35
- package/src/components/panel/site-content-home.tsx +149 -0
- package/src/components/panel/site-content-section-header.tsx +60 -0
- package/src/contexts/content-panel-coordinator.tsx +65 -11
- package/src/index.ts +9 -0
- package/src/site-content-sections.ts +8 -0
- package/src/site-content-view.ts +47 -0
- package/src/utils/keyboard-click.ts +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-site-navigation",
|
|
3
|
-
"version": "4.5.0-
|
|
3
|
+
"version": "4.5.0-1253",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,18 +39,18 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor-controls": "4.5.0-
|
|
43
|
-
"@elementor/editor-app-bar": "4.5.0-
|
|
44
|
-
"@elementor/editor-documents": "4.5.0-
|
|
45
|
-
"@elementor/editor-panels": "4.5.0-
|
|
46
|
-
"@elementor/editor-sidebar": "4.5.0-
|
|
47
|
-
"@elementor/editor-ui": "4.5.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "4.5.0-
|
|
49
|
-
"@elementor/env": "4.5.0-
|
|
50
|
-
"@elementor/events": "4.5.0-
|
|
42
|
+
"@elementor/editor-controls": "4.5.0-1253",
|
|
43
|
+
"@elementor/editor-app-bar": "4.5.0-1253",
|
|
44
|
+
"@elementor/editor-documents": "4.5.0-1253",
|
|
45
|
+
"@elementor/editor-panels": "4.5.0-1253",
|
|
46
|
+
"@elementor/editor-sidebar": "4.5.0-1253",
|
|
47
|
+
"@elementor/editor-ui": "4.5.0-1253",
|
|
48
|
+
"@elementor/editor-v1-adapters": "4.5.0-1253",
|
|
49
|
+
"@elementor/env": "4.5.0-1253",
|
|
50
|
+
"@elementor/events": "4.5.0-1253",
|
|
51
51
|
"@elementor/icons": "~1.78.1",
|
|
52
|
-
"@elementor/locations": "4.5.0-
|
|
53
|
-
"@elementor/query": "4.5.0-
|
|
52
|
+
"@elementor/locations": "4.5.0-1253",
|
|
53
|
+
"@elementor/query": "4.5.0-1253",
|
|
54
54
|
"@elementor/ui": "1.41.4",
|
|
55
55
|
"@wordpress/api-fetch": "^6.42.0",
|
|
56
56
|
"@wordpress/i18n": "^5.13.0"
|
|
@@ -6,7 +6,11 @@ const CONTENT_PANEL_LIST_ROW_TITLE_FONT_SIZE = '0.75rem';
|
|
|
6
6
|
const CONTENT_PANEL_LIST_SECTION_BOTTOM_SPACING = 1;
|
|
7
7
|
|
|
8
8
|
const CONTENT_PANEL_SECTION_HEADER_PADDING_BLOCK = 1.25;
|
|
9
|
+
const CONTENT_PANEL_SHELL_HEADER_PADDING_BLOCK = 1;
|
|
10
|
+
const CONTENT_PANEL_SIDEBAR_PANEL_HEADER_PADDING_INLINE = 1;
|
|
11
|
+
const CONTENT_PANEL_SIDEBAR_PANEL_HEADER_PADDING_START = 2;
|
|
9
12
|
const CONTENT_PANEL_SECTION_HEADER_TRAILING_GAP = 0.75;
|
|
13
|
+
const CONTENT_PANEL_FLAT_SECTION_TOOLBAR_PADDING_BLOCK = 1.25;
|
|
10
14
|
const CONTENT_PANEL_SEARCH_PADDING_BLOCK = 1.5;
|
|
11
15
|
|
|
12
16
|
export const contentPanelInsetPaddingSx = {
|
|
@@ -34,23 +38,21 @@ export function getContentPanelListItemSx( trailingActionCount: number ) {
|
|
|
34
38
|
export function getContentPanelListItemRowStateSx( isActive: boolean, allowRowHover: boolean ) {
|
|
35
39
|
if ( isActive ) {
|
|
36
40
|
return {
|
|
37
|
-
|
|
38
|
-
backgroundColor: 'action.selected',
|
|
39
|
-
'&:hover': {
|
|
41
|
+
'&&': {
|
|
40
42
|
backgroundColor: 'action.selected',
|
|
43
|
+
'&:hover': {
|
|
44
|
+
backgroundColor: 'action.selected',
|
|
45
|
+
},
|
|
41
46
|
},
|
|
42
47
|
};
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
if ( ! allowRowHover ) {
|
|
46
|
-
return {
|
|
47
|
-
borderRadius: 1,
|
|
48
|
-
};
|
|
51
|
+
return {};
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
return {
|
|
52
|
-
|
|
53
|
-
'&:hover': {
|
|
55
|
+
'&&:hover': {
|
|
54
56
|
backgroundColor: 'action.hover',
|
|
55
57
|
},
|
|
56
58
|
};
|
|
@@ -60,6 +62,28 @@ export const contentPanelHeaderStackSx = {
|
|
|
60
62
|
width: '100%',
|
|
61
63
|
};
|
|
62
64
|
|
|
65
|
+
export function getContentPanelShellHeaderStackSx( sidebarPanelChrome: boolean ) {
|
|
66
|
+
if ( sidebarPanelChrome ) {
|
|
67
|
+
return {
|
|
68
|
+
...contentPanelHeaderStackSx,
|
|
69
|
+
paddingInlineEnd: CONTENT_PANEL_INSET_SPACING - CONTENT_PANEL_SIDEBAR_PANEL_HEADER_PADDING_INLINE,
|
|
70
|
+
paddingInlineStart: CONTENT_PANEL_INSET_SPACING - CONTENT_PANEL_SIDEBAR_PANEL_HEADER_PADDING_START,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
...contentPanelHeaderStackSx,
|
|
76
|
+
paddingInline: CONTENT_PANEL_INSET_SPACING,
|
|
77
|
+
py: CONTENT_PANEL_SHELL_HEADER_PADDING_BLOCK,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const contentPanelFlatSectionToolbarRowSx = {
|
|
82
|
+
flexShrink: 0,
|
|
83
|
+
px: CONTENT_PANEL_INSET_SPACING,
|
|
84
|
+
py: CONTENT_PANEL_FLAT_SECTION_TOOLBAR_PADDING_BLOCK,
|
|
85
|
+
};
|
|
86
|
+
|
|
63
87
|
export const contentPanelSearchBoxSx = {
|
|
64
88
|
...contentPanelInsetPaddingSx,
|
|
65
89
|
py: CONTENT_PANEL_SEARCH_PADDING_BLOCK,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Stack } from '@elementor/ui';
|
|
3
|
+
|
|
4
|
+
import ContentPanelSort from './content-panel-sort';
|
|
5
|
+
import ContentPanelStatusFilter from './content-panel-status-filter';
|
|
6
|
+
|
|
7
|
+
export default function ContentPanelSectionHeaderActions() {
|
|
8
|
+
return (
|
|
9
|
+
<Stack
|
|
10
|
+
alignItems="center"
|
|
11
|
+
direction="row"
|
|
12
|
+
spacing={ 0.5 }
|
|
13
|
+
sx={ {
|
|
14
|
+
flexShrink: 0,
|
|
15
|
+
marginInlineStart: 'auto',
|
|
16
|
+
} }
|
|
17
|
+
>
|
|
18
|
+
<ContentPanelStatusFilter />
|
|
19
|
+
<ContentPanelSort />
|
|
20
|
+
</Stack>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -1,19 +1,49 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
|
-
import { Box, Stack } from '@elementor/ui';
|
|
3
|
+
import { Box, Divider, Stack } from '@elementor/ui';
|
|
4
4
|
|
|
5
5
|
import ContentPanelActiveFilters from './content-panel-active-filters';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
contentPanelFlatSectionToolbarRowSx,
|
|
8
|
+
contentPanelFullBleedDividerSx,
|
|
9
|
+
contentPanelSearchBoxSx,
|
|
10
|
+
} from './content-panel-chrome';
|
|
7
11
|
import ContentPanelSearch from './content-panel-search';
|
|
8
12
|
import ContentPanelSort from './content-panel-sort';
|
|
9
13
|
import ContentPanelStatusFilter from './content-panel-status-filter';
|
|
10
14
|
|
|
11
15
|
type Props = {
|
|
12
16
|
addAction?: ReactNode;
|
|
17
|
+
actionsInHeader?: boolean;
|
|
13
18
|
searchAriaLabel?: string;
|
|
14
19
|
};
|
|
15
20
|
|
|
16
|
-
export default function ContentPanelSectionToolbar( { addAction, searchAriaLabel }: Props ) {
|
|
21
|
+
export default function ContentPanelSectionToolbar( { addAction, actionsInHeader, searchAriaLabel }: Props ) {
|
|
22
|
+
if ( actionsInHeader ) {
|
|
23
|
+
return (
|
|
24
|
+
<Box sx={ { display: 'flex', flexDirection: 'column', flexShrink: 0, width: '100%' } }>
|
|
25
|
+
<Stack
|
|
26
|
+
alignItems="center"
|
|
27
|
+
direction="row"
|
|
28
|
+
spacing={ 1 }
|
|
29
|
+
width="100%"
|
|
30
|
+
sx={ contentPanelFlatSectionToolbarRowSx }
|
|
31
|
+
>
|
|
32
|
+
<Box sx={ { flex: 1, minWidth: 0 } }>
|
|
33
|
+
<ContentPanelSearch searchAriaLabel={ searchAriaLabel } />
|
|
34
|
+
</Box>
|
|
35
|
+
{ addAction ? (
|
|
36
|
+
<Box sx={ { alignItems: 'center', display: 'flex', flexShrink: 0 } }>{ addAction }</Box>
|
|
37
|
+
) : null }
|
|
38
|
+
</Stack>
|
|
39
|
+
<Box sx={ { px: 2, pb: 0.75 } }>
|
|
40
|
+
<ContentPanelActiveFilters />
|
|
41
|
+
</Box>
|
|
42
|
+
<Divider sx={ { ...contentPanelFullBleedDividerSx, width: '100%' } } />
|
|
43
|
+
</Box>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
17
47
|
return (
|
|
18
48
|
<Box sx={ contentPanelSearchBoxSx }>
|
|
19
49
|
<Stack gap={ 0.75 } width="100%">
|
|
@@ -99,16 +99,22 @@ export default function ListItemView( { post }: { post: Post } ) {
|
|
|
99
99
|
const listRow = (
|
|
100
100
|
<ListItem
|
|
101
101
|
disablePadding
|
|
102
|
-
sx={
|
|
103
|
-
...getContentPanelListItemSx( trailingActionCount ),
|
|
104
|
-
...getContentPanelListItemRowStateSx( isActive, allowRowHover ),
|
|
105
|
-
} }
|
|
102
|
+
sx={ getContentPanelListItemSx( trailingActionCount ) }
|
|
106
103
|
secondaryAction={
|
|
107
104
|
<Stack alignItems="center" direction="row" spacing={ 0 }>
|
|
108
105
|
{ showListItemActions && <SiteContentListItemActionsSlot post={ post } title={ title } /> }
|
|
109
|
-
{ isHome
|
|
110
|
-
<
|
|
111
|
-
|
|
106
|
+
{ isHome ? (
|
|
107
|
+
<IconButton
|
|
108
|
+
aria-label={ __( 'Homepage', 'elementor' ) }
|
|
109
|
+
disableRipple
|
|
110
|
+
disabled
|
|
111
|
+
size="tiny"
|
|
112
|
+
sx={ { pointerEvents: 'none' } }
|
|
113
|
+
tabIndex={ -1 }
|
|
114
|
+
>
|
|
115
|
+
<HomeIcon color="disabled" fontSize="tiny" />
|
|
116
|
+
</IconButton>
|
|
117
|
+
) : null }
|
|
112
118
|
<IconButton
|
|
113
119
|
aria-label={ __( 'More actions', 'elementor' ) }
|
|
114
120
|
size="tiny"
|
|
@@ -136,7 +142,11 @@ export default function ListItemView( { post }: { post: Post } ) {
|
|
|
136
142
|
} }
|
|
137
143
|
selected={ isActive }
|
|
138
144
|
shape="rounded"
|
|
139
|
-
sx={
|
|
145
|
+
sx={ {
|
|
146
|
+
...contentPanelListItemButtonSx,
|
|
147
|
+
...getContentPanelListItemRowStateSx( isActive, allowRowHover ),
|
|
148
|
+
borderRadius: 1,
|
|
149
|
+
} }
|
|
140
150
|
>
|
|
141
151
|
<ListItemText disableTypography sx={ { flex: 1, minWidth: 0 } }>
|
|
142
152
|
<PageTitleAndStatus title={ title } status={ status } />
|
|
@@ -30,13 +30,15 @@ import PostListPaginationActions from './post-list-pagination-actions';
|
|
|
30
30
|
|
|
31
31
|
type Props = {
|
|
32
32
|
isOpenByDefault?: boolean;
|
|
33
|
+
layout?: 'accordion' | 'flat';
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
function PostsCollapsibleListContent( { isOpenByDefault = false }: Props ) {
|
|
36
|
+
function PostsCollapsibleListContent( { isOpenByDefault = false, layout = 'accordion' }: Props ) {
|
|
37
|
+
const isFlatLayout = layout === 'flat';
|
|
36
38
|
const { type, editMode, resetEditMode, setEditMode } = usePostListContext();
|
|
37
39
|
const { registerSection, unregisterSection } = useContentPanelCoordinator();
|
|
38
40
|
const { clearStatusFilters, debouncedSearch, siteContentSort, statusFilters } = useSiteContentSectionToolbar();
|
|
39
|
-
const [ isOpen, setIsOpen ] = useState( isOpenByDefault );
|
|
41
|
+
const [ isOpen, setIsOpen ] = useState( isFlatLayout || isOpenByDefault );
|
|
40
42
|
const focusAfterShowLessRef = useRef( false );
|
|
41
43
|
const listTopRef = useRef< HTMLDivElement | null >( null );
|
|
42
44
|
const loadMoreButtonRef = useRef< HTMLButtonElement | null >( null );
|
|
@@ -150,10 +152,14 @@ function PostsCollapsibleListContent( { isOpenByDefault = false }: Props ) {
|
|
|
150
152
|
}, [ pagination.canLoadMore, pagination.visibleCount ] );
|
|
151
153
|
|
|
152
154
|
useEffect( () => {
|
|
155
|
+
if ( isFlatLayout ) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
153
159
|
if ( ( debouncedSearch || hasActiveSiteContentStatusFilters( statusFilters ) ) && filteredPosts.length > 0 ) {
|
|
154
160
|
setIsOpen( true );
|
|
155
161
|
}
|
|
156
|
-
}, [ debouncedSearch, filteredPosts.length, statusFilters ] );
|
|
162
|
+
}, [ debouncedSearch, filteredPosts.length, isFlatLayout, statusFilters ] );
|
|
157
163
|
|
|
158
164
|
if ( postsError ) {
|
|
159
165
|
return <ErrorState />;
|
|
@@ -184,23 +190,8 @@ function PostsCollapsibleListContent( { isOpenByDefault = false }: Props ) {
|
|
|
184
190
|
sectionTitle
|
|
185
191
|
);
|
|
186
192
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
count={ displayCount }
|
|
190
|
-
countChipLabel={ countChipLabel }
|
|
191
|
-
headerRef={ sectionHeaderRef }
|
|
192
|
-
isOpen={ isOpen }
|
|
193
|
-
onOpenChange={ setIsOpen }
|
|
194
|
-
sectionToolbar={
|
|
195
|
-
<ContentPanelSectionToolbar
|
|
196
|
-
addAction={
|
|
197
|
-
isTrashFilter ? undefined : <SectionAddButton onBeforeCreate={ () => setIsOpen( true ) } />
|
|
198
|
-
}
|
|
199
|
-
searchAriaLabel={ searchAriaLabel }
|
|
200
|
-
/>
|
|
201
|
-
}
|
|
202
|
-
title={ sectionTitle }
|
|
203
|
-
>
|
|
193
|
+
const listBody = (
|
|
194
|
+
<>
|
|
204
195
|
{ showNoResults && (
|
|
205
196
|
<Box sx={ { py: 2, px: 2 } }>
|
|
206
197
|
<Typography variant="body2" color="text.secondary">
|
|
@@ -221,16 +212,58 @@ function PostsCollapsibleListContent( { isOpenByDefault = false }: Props ) {
|
|
|
221
212
|
onLoadMore={ pagination.handleLoadMore }
|
|
222
213
|
onShowLess={ handleShowLess }
|
|
223
214
|
/>
|
|
215
|
+
</>
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
const flatSectionAddAction = isTrashFilter ? undefined : <SectionAddButton />;
|
|
219
|
+
const accordionSectionAddAction = isTrashFilter ? undefined : (
|
|
220
|
+
<SectionAddButton onBeforeCreate={ () => setIsOpen( true ) } />
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
const sectionToolbar = (
|
|
224
|
+
<ContentPanelSectionToolbar
|
|
225
|
+
addAction={ isFlatLayout ? flatSectionAddAction : accordionSectionAddAction }
|
|
226
|
+
actionsInHeader={ isFlatLayout }
|
|
227
|
+
searchAriaLabel={ searchAriaLabel }
|
|
228
|
+
/>
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
if ( isFlatLayout ) {
|
|
232
|
+
return (
|
|
233
|
+
<Box sx={ { display: 'flex', flexDirection: 'column', flex: 1, minHeight: 0, width: '100%' } }>
|
|
234
|
+
{ sectionToolbar }
|
|
235
|
+
<Box sx={ { flex: 1, minHeight: 0, overflow: 'auto' } }>{ listBody }</Box>
|
|
236
|
+
</Box>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<CollapsibleList
|
|
242
|
+
count={ displayCount }
|
|
243
|
+
countChipLabel={ countChipLabel }
|
|
244
|
+
headerRef={ sectionHeaderRef }
|
|
245
|
+
isOpen={ isOpen }
|
|
246
|
+
onOpenChange={ setIsOpen }
|
|
247
|
+
sectionToolbar={ sectionToolbar }
|
|
248
|
+
title={ sectionTitle }
|
|
249
|
+
>
|
|
250
|
+
{ listBody }
|
|
224
251
|
</CollapsibleList>
|
|
225
252
|
);
|
|
226
253
|
}
|
|
227
254
|
|
|
228
255
|
export default function PostsCollapsibleList( props: Props ) {
|
|
229
256
|
const { type } = usePostListContext();
|
|
257
|
+
const isFlatLayout = props.layout === 'flat';
|
|
258
|
+
const content = <PostsCollapsibleListContent { ...props } />;
|
|
259
|
+
|
|
260
|
+
if ( isFlatLayout ) {
|
|
261
|
+
return content;
|
|
262
|
+
}
|
|
230
263
|
|
|
231
264
|
return (
|
|
232
265
|
<SiteContentSectionToolbarProvider statusFilterCountSlugs={ [ type ] }>
|
|
233
|
-
|
|
266
|
+
{ content }
|
|
234
267
|
</SiteContentSectionToolbarProvider>
|
|
235
268
|
);
|
|
236
269
|
}
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Box, Skeleton, Stack } from '@elementor/ui';
|
|
3
3
|
|
|
4
4
|
import { type Slug } from '../../api/post';
|
|
5
|
-
import { PostListContextProvider } from '../../contexts/post-list-context';
|
|
6
|
-
import { useSiteContentPanelSectionsFilter } from '../../contexts/site-content-panel-sections-filter';
|
|
7
5
|
import { getSiteContentSections } from '../../site-content-sections';
|
|
6
|
+
import { type SiteContentView } from '../../site-content-view';
|
|
8
7
|
import PostsCollapsibleList from './posts-list/posts-collapsible-list';
|
|
8
|
+
import { SiteContentHome } from './site-content-home';
|
|
9
9
|
import UserLoadError from './user-load-error';
|
|
10
10
|
|
|
11
11
|
type ShellPanelBodyContentProps = {
|
|
12
12
|
accessiblePostTypes: Slug[];
|
|
13
|
+
currentView: SiteContentView;
|
|
13
14
|
isUserPending: boolean;
|
|
14
|
-
|
|
15
|
+
onSelectSection: ( sectionId: string ) => void;
|
|
15
16
|
showUserLoadError: boolean;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
export default function ShellPanelBodyContent( {
|
|
19
20
|
accessiblePostTypes,
|
|
21
|
+
currentView,
|
|
20
22
|
isUserPending,
|
|
21
|
-
|
|
23
|
+
onSelectSection,
|
|
22
24
|
showUserLoadError,
|
|
23
25
|
}: ShellPanelBodyContentProps ) {
|
|
24
26
|
if ( isUserPending ) {
|
|
@@ -34,31 +36,21 @@ export default function ShellPanelBodyContent( {
|
|
|
34
36
|
return <UserLoadError />;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
+
if ( currentView === null ) {
|
|
40
|
+
return <SiteContentHome accessiblePostTypes={ accessiblePostTypes } onSelect={ onSelectSection } />;
|
|
41
|
+
}
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
accessiblePostTypes,
|
|
42
|
-
onListError,
|
|
43
|
-
}: {
|
|
44
|
-
accessiblePostTypes: Slug[];
|
|
45
|
-
onListError: () => void;
|
|
46
|
-
} ) {
|
|
47
|
-
const { isSectionVisible } = useSiteContentPanelSectionsFilter();
|
|
43
|
+
const isPostTypeSection = accessiblePostTypes.includes( currentView as Slug );
|
|
48
44
|
const extraSections = getSiteContentSections();
|
|
49
|
-
const
|
|
50
|
-
|
|
45
|
+
const registeredSection = extraSections.find( ( section ) => section.id === currentView );
|
|
46
|
+
|
|
47
|
+
if ( isPostTypeSection ) {
|
|
48
|
+
return <PostsCollapsibleList layout="flat" />;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if ( registeredSection ) {
|
|
52
|
+
return <Box sx={ { width: '100%', flex: 1, minHeight: 0 } }>{ registeredSection.render() }</Box>;
|
|
53
|
+
}
|
|
51
54
|
|
|
52
|
-
return
|
|
53
|
-
<List dense disablePadding sx={ { py: 0, width: '100%' } }>
|
|
54
|
-
{ visiblePostTypes.map( ( postTypeSlug, index ) => (
|
|
55
|
-
<PostListContextProvider key={ postTypeSlug } type={ postTypeSlug } setError={ onListError }>
|
|
56
|
-
<PostsCollapsibleList isOpenByDefault={ index === 0 } />
|
|
57
|
-
</PostListContextProvider>
|
|
58
|
-
) ) }
|
|
59
|
-
{ visibleSections.map( ( section ) => (
|
|
60
|
-
<React.Fragment key={ section.id }>{ section.render() }</React.Fragment>
|
|
61
|
-
) ) }
|
|
62
|
-
</List>
|
|
63
|
-
);
|
|
55
|
+
return <SiteContentHome accessiblePostTypes={ accessiblePostTypes } onSelect={ onSelectSection } />;
|
|
64
56
|
}
|
|
@@ -1,57 +1,125 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useState } from 'react';
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { Panel, PanelBody, PanelHeader, PanelHeaderTitle } from '@elementor/editor-panels';
|
|
4
4
|
import { isSidebarEnabled } from '@elementor/editor-sidebar';
|
|
5
|
-
import { Divider, Stack } from '@elementor/ui';
|
|
5
|
+
import { Box, Divider, Stack } from '@elementor/ui';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { type Slug } from '../../api/post';
|
|
9
|
+
import { ContentPanelCoordinatorProvider, type ContentPanelSectionId } from '../../contexts/content-panel-coordinator';
|
|
10
|
+
import { PostListContextProvider } from '../../contexts/post-list-context';
|
|
11
|
+
import { SiteContentSectionToolbarProvider } from '../../contexts/site-content-section-toolbar';
|
|
10
12
|
import useAccessiblePanelPostTypes from '../../hooks/use-accessible-panel-post-types';
|
|
11
|
-
import {
|
|
13
|
+
import { getSiteContentSectionById } from '../../site-content-sections';
|
|
14
|
+
import { getInitialSiteContentView, notifySiteContentViewChange, type SiteContentView } from '../../site-content-view';
|
|
15
|
+
import { getContentPanelShellHeaderStackSx } from './content-panel-chrome';
|
|
12
16
|
import ContentPanelHeaderAdd from './content-panel-header-add';
|
|
13
|
-
import
|
|
17
|
+
import ContentPanelSectionHeaderActions from './content-panel-section-header-actions';
|
|
14
18
|
import ErrorSnackbar from './error-snackbar';
|
|
15
19
|
import ShellPanelBodyContent from './shell-panel-body-content';
|
|
20
|
+
import { SiteContentSectionHeader } from './site-content-section-header';
|
|
21
|
+
|
|
22
|
+
function isPostTypeSectionView( view: SiteContentView, accessiblePostTypes: Slug[] ): view is Slug {
|
|
23
|
+
return view !== null && accessiblePostTypes.includes( view as Slug );
|
|
24
|
+
}
|
|
16
25
|
|
|
17
26
|
const Shell = () => {
|
|
18
27
|
const sidebarPanelChrome = isSidebarEnabled();
|
|
19
28
|
const [ isErrorSnackbarOpen, setIsErrorSnackbarOpen ] = useState( false );
|
|
20
29
|
const { accessiblePostTypes, isUserPending, showUserLoadError } = useAccessiblePanelPostTypes();
|
|
30
|
+
const [ currentView, setCurrentView ] = useState< SiteContentView >( () => getInitialSiteContentView() );
|
|
31
|
+
const clearPendingCreateRef = useRef< ( () => void ) | undefined >();
|
|
21
32
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const openSection = useCallback( ( sectionId: ContentPanelSectionId ) => {
|
|
34
|
+
clearPendingCreateRef.current?.();
|
|
35
|
+
setCurrentView( sectionId );
|
|
36
|
+
notifySiteContentViewChange( sectionId );
|
|
37
|
+
}, [] );
|
|
38
|
+
|
|
39
|
+
const goHome = useCallback( () => {
|
|
40
|
+
clearPendingCreateRef.current?.();
|
|
41
|
+
setCurrentView( null );
|
|
42
|
+
notifySiteContentViewChange( null );
|
|
43
|
+
}, [] );
|
|
44
|
+
|
|
45
|
+
useEffect( () => {
|
|
46
|
+
notifySiteContentViewChange( currentView );
|
|
47
|
+
}, [ currentView ] );
|
|
48
|
+
|
|
49
|
+
const showHome = currentView === null;
|
|
50
|
+
const postTypeSection = isPostTypeSectionView( currentView, accessiblePostTypes as Slug[] );
|
|
51
|
+
const registeredSection = currentView ? getSiteContentSectionById( currentView ) : undefined;
|
|
52
|
+
const usesDrillInToolbarShell = postTypeSection || Boolean( registeredSection?.usesDrillInToolbarShell );
|
|
53
|
+
const panel = (
|
|
54
|
+
<Panel>
|
|
55
|
+
<PanelHeader>
|
|
56
|
+
<Stack
|
|
57
|
+
alignItems="center"
|
|
58
|
+
direction="row"
|
|
59
|
+
spacing={ 0.5 }
|
|
60
|
+
sx={ getContentPanelShellHeaderStackSx( sidebarPanelChrome ) }
|
|
61
|
+
>
|
|
62
|
+
{ showHome ? (
|
|
63
|
+
<>
|
|
36
64
|
<PanelHeaderTitle sx={ { flex: 1, minWidth: 0, textAlign: 'start' } }>
|
|
37
65
|
{ __( 'Site content', 'elementor' ) }
|
|
38
66
|
</PanelHeaderTitle>
|
|
39
|
-
<ContentPanelSectionsFilter />
|
|
40
67
|
<ContentPanelHeaderAdd />
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
</>
|
|
69
|
+
) : (
|
|
70
|
+
<>
|
|
71
|
+
<SiteContentSectionHeader sectionId={ currentView } onBack={ goHome } />
|
|
72
|
+
{ usesDrillInToolbarShell ? <ContentPanelSectionHeaderActions /> : null }
|
|
73
|
+
</>
|
|
74
|
+
) }
|
|
75
|
+
</Stack>
|
|
76
|
+
</PanelHeader>
|
|
77
|
+
<Divider />
|
|
78
|
+
<PanelBody
|
|
79
|
+
sx={ {
|
|
80
|
+
display: 'flex',
|
|
81
|
+
flexDirection: 'column',
|
|
82
|
+
height: '100%',
|
|
83
|
+
overflow: 'hidden',
|
|
84
|
+
minHeight: 0,
|
|
85
|
+
} }
|
|
86
|
+
>
|
|
87
|
+
<Box sx={ { display: 'flex', flexDirection: 'column', flex: 1, minHeight: 0, overflow: 'hidden' } }>
|
|
88
|
+
<ShellPanelBodyContent
|
|
89
|
+
accessiblePostTypes={ accessiblePostTypes as Slug[] }
|
|
90
|
+
currentView={ currentView }
|
|
91
|
+
isUserPending={ isUserPending }
|
|
92
|
+
onSelectSection={ openSection }
|
|
93
|
+
showUserLoadError={ showUserLoadError }
|
|
94
|
+
/>
|
|
95
|
+
</Box>
|
|
96
|
+
<ErrorSnackbar open={ isErrorSnackbarOpen } onClose={ () => setIsErrorSnackbarOpen( false ) } />
|
|
97
|
+
</PanelBody>
|
|
98
|
+
</Panel>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const panelWithProviders = ( () => {
|
|
102
|
+
let resolvedPanel = registeredSection?.wrapDrillInPanel ? registeredSection.wrapDrillInPanel( panel ) : panel;
|
|
103
|
+
|
|
104
|
+
if ( postTypeSection ) {
|
|
105
|
+
resolvedPanel = (
|
|
106
|
+
<PostListContextProvider type={ currentView } setError={ () => setIsErrorSnackbarOpen( true ) }>
|
|
107
|
+
<SiteContentSectionToolbarProvider statusFilterCountSlugs={ [ currentView ] }>
|
|
108
|
+
{ resolvedPanel }
|
|
109
|
+
</SiteContentSectionToolbarProvider>
|
|
110
|
+
</PostListContextProvider>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return resolvedPanel;
|
|
115
|
+
} )();
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<ContentPanelCoordinatorProvider
|
|
119
|
+
clearPendingCreateRef={ clearPendingCreateRef }
|
|
120
|
+
onNavigateToSection={ openSection }
|
|
121
|
+
>
|
|
122
|
+
{ panelWithProviders }
|
|
55
123
|
</ContentPanelCoordinatorProvider>
|
|
56
124
|
);
|
|
57
125
|
};
|