@elementor/editor-site-navigation 4.5.0-1216 → 4.5.0-1218
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 +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +830 -344
- package/dist/index.mjs +782 -288
- package/package.json +11 -10
- package/src/api/post.ts +21 -5
- package/src/components/panel/actions-menu/action-menu-item.tsx +4 -3
- package/src/components/panel/actions-menu/actions/force-delete.tsx +99 -0
- package/src/components/panel/actions-menu/actions/restore.tsx +33 -0
- package/src/components/panel/content-panel-active-filters.tsx +53 -0
- package/src/components/panel/content-panel-chrome.ts +19 -0
- package/src/components/panel/content-panel-clear-filters-button.tsx +22 -0
- package/src/components/panel/content-panel-search.tsx +1 -2
- package/src/components/panel/content-panel-status-filter-list.tsx +70 -0
- package/src/components/panel/content-panel-status-filter.tsx +75 -0
- package/src/components/panel/content-panel-toolbar.tsx +23 -0
- package/src/components/panel/posts-list/collapsible-list.tsx +7 -4
- package/src/components/panel/posts-list/list-items/list-item-view.tsx +80 -47
- package/src/components/panel/posts-list/list-items/site-content-list-item-actions-location.tsx +14 -0
- package/src/components/panel/posts-list/posts-collapsible-list.tsx +30 -9
- package/src/components/panel/shell.tsx +6 -2
- package/src/components/shared/page-title-and-status.tsx +2 -0
- package/src/contexts/content-panel-coordinator.tsx +34 -3
- package/src/hooks/use-posts-actions.ts +20 -1
- package/src/hooks/use-posts-baseline-total.ts +22 -0
- package/src/hooks/use-posts.ts +19 -13
- package/src/hooks/use-site-content-status-filter-counts.ts +56 -0
- package/src/index.ts +5 -0
- package/src/site-content-restore.ts +1 -0
- package/src/site-content-status-filter.ts +111 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { __ } from '@wordpress/i18n';
|
|
2
|
+
|
|
3
|
+
export type SiteContentSelectableStatus = 'draft' | 'future' | 'pending' | 'private' | 'publish' | 'trash';
|
|
4
|
+
|
|
5
|
+
export type SiteContentStatusFilters = Record< SiteContentSelectableStatus, boolean >;
|
|
6
|
+
|
|
7
|
+
export const SITE_CONTENT_SELECTABLE_STATUS_FILTERS: SiteContentSelectableStatus[] = [
|
|
8
|
+
'publish',
|
|
9
|
+
'draft',
|
|
10
|
+
'pending',
|
|
11
|
+
'private',
|
|
12
|
+
'future',
|
|
13
|
+
'trash',
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
export const EMPTY_SITE_CONTENT_STATUS_FILTERS: SiteContentStatusFilters = {
|
|
17
|
+
draft: false,
|
|
18
|
+
future: false,
|
|
19
|
+
pending: false,
|
|
20
|
+
private: false,
|
|
21
|
+
publish: false,
|
|
22
|
+
trash: false,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const filterLabels: Record< SiteContentSelectableStatus, string > = {
|
|
26
|
+
publish: __( 'Published', 'elementor' ),
|
|
27
|
+
draft: __( 'Drafts', 'elementor' ),
|
|
28
|
+
pending: __( 'Pending', 'elementor' ),
|
|
29
|
+
private: __( 'Private', 'elementor' ),
|
|
30
|
+
future: __( 'Scheduled', 'elementor' ),
|
|
31
|
+
trash: __( 'Trash', 'elementor' ),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const SITE_CONTENT_ALL_FILTER_LABEL = __( 'All', 'elementor' );
|
|
35
|
+
|
|
36
|
+
export const SITE_CONTENT_FILTER_POPOVER_WIDTH_PX = 280;
|
|
37
|
+
|
|
38
|
+
export function getSiteContentStatusFilterLabel( filter: SiteContentSelectableStatus ): string {
|
|
39
|
+
return filterLabels[ filter ];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function hasActiveSiteContentStatusFilters( filters: SiteContentStatusFilters ): boolean {
|
|
43
|
+
return SITE_CONTENT_SELECTABLE_STATUS_FILTERS.some( ( key ) => filters[ key ] );
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function getActiveSiteContentStatusFilterKeys(
|
|
47
|
+
filters: SiteContentStatusFilters
|
|
48
|
+
): SiteContentSelectableStatus[] {
|
|
49
|
+
return SITE_CONTENT_SELECTABLE_STATUS_FILTERS.filter( ( key ) => filters[ key ] );
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const serializeSiteContentStatusFilters = ( statusFilters: SiteContentStatusFilters ): string =>
|
|
53
|
+
SITE_CONTENT_SELECTABLE_STATUS_FILTERS.map( ( key ) => ( statusFilters[ key ] ? key : '' ) ).join( '|' );
|
|
54
|
+
|
|
55
|
+
export function getRestStatusForSiteContentFilters( filters: SiteContentStatusFilters ): string {
|
|
56
|
+
if ( filters.trash ) {
|
|
57
|
+
return 'trash';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const active = getActiveSiteContentStatusFilterKeys( filters );
|
|
61
|
+
|
|
62
|
+
if ( 0 === active.length ) {
|
|
63
|
+
return 'any';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return active.join( ',' );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function isSiteContentTrashFilterActive( filters: SiteContentStatusFilters ): boolean {
|
|
70
|
+
return filters.trash;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function isSiteContentListNarrowed( filters: SiteContentStatusFilters, search: string ): boolean {
|
|
74
|
+
return hasActiveSiteContentStatusFilters( filters ) || search.trim().length > 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function toggleSiteContentStatusFilter(
|
|
78
|
+
filters: SiteContentStatusFilters,
|
|
79
|
+
filter: SiteContentSelectableStatus
|
|
80
|
+
): SiteContentStatusFilters {
|
|
81
|
+
if ( 'trash' === filter ) {
|
|
82
|
+
const isTrashOn = ! filters.trash;
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
...EMPTY_SITE_CONTENT_STATUS_FILTERS,
|
|
86
|
+
trash: isTrashOn,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
...filters,
|
|
92
|
+
trash: false,
|
|
93
|
+
[ filter ]: ! filters[ filter ],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function shouldShowSiteContentStatusFilterRow(
|
|
98
|
+
count: number | undefined,
|
|
99
|
+
isLoadingCounts: boolean,
|
|
100
|
+
isSelected: boolean
|
|
101
|
+
): boolean {
|
|
102
|
+
if ( isSelected ) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if ( isLoadingCounts || undefined === count ) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return count > 0;
|
|
111
|
+
}
|