@elementor/editor-site-navigation 4.5.0-1229 → 4.5.0-1231

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-site-navigation",
3
- "version": "4.5.0-1229",
3
+ "version": "4.5.0-1231",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,17 +39,18 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor-app-bar": "4.5.0-1229",
43
- "@elementor/editor-documents": "4.5.0-1229",
44
- "@elementor/editor-panels": "4.5.0-1229",
45
- "@elementor/editor-sidebar": "4.5.0-1229",
46
- "@elementor/editor-ui": "4.5.0-1229",
47
- "@elementor/editor-v1-adapters": "4.5.0-1229",
48
- "@elementor/env": "4.5.0-1229",
49
- "@elementor/events": "4.5.0-1229",
42
+ "@elementor/editor-controls": "4.5.0-1231",
43
+ "@elementor/editor-app-bar": "4.5.0-1231",
44
+ "@elementor/editor-documents": "4.5.0-1231",
45
+ "@elementor/editor-panels": "4.5.0-1231",
46
+ "@elementor/editor-sidebar": "4.5.0-1231",
47
+ "@elementor/editor-ui": "4.5.0-1231",
48
+ "@elementor/editor-v1-adapters": "4.5.0-1231",
49
+ "@elementor/env": "4.5.0-1231",
50
+ "@elementor/events": "4.5.0-1231",
50
51
  "@elementor/icons": "~1.78.1",
51
- "@elementor/locations": "4.5.0-1229",
52
- "@elementor/query": "4.5.0-1229",
52
+ "@elementor/locations": "4.5.0-1231",
53
+ "@elementor/query": "4.5.0-1231",
53
54
  "@elementor/ui": "1.41.4",
54
55
  "@wordpress/api-fetch": "^6.42.0",
55
56
  "@wordpress/i18n": "^5.13.0"
@@ -1,7 +1,10 @@
1
1
  const CONTENT_PANEL_INSET_SPACING = 2;
2
2
  const CONTENT_PANEL_LIST_ROW_GAP = 0.5;
3
3
  const CONTENT_PANEL_LIST_ROW_INSET_INLINE = 0.75;
4
- const CONTENT_PANEL_LIST_ROW_ACTIVE_SECONDARY_INSET = 10;
4
+ const CONTENT_PANEL_LIST_ROW_ACTIVE_SECONDARY_ACTIONS_COUNT = 2;
5
+ const CONTENT_PANEL_LIST_ROW_ACTIVE_SECONDARY_ACTION_SLOT_WIDTH = 5.5;
6
+ const CONTENT_PANEL_LIST_ROW_ACTIVE_SECONDARY_INSET =
7
+ CONTENT_PANEL_LIST_ROW_ACTIVE_SECONDARY_ACTIONS_COUNT * CONTENT_PANEL_LIST_ROW_ACTIVE_SECONDARY_ACTION_SLOT_WIDTH;
5
8
  const CONTENT_PANEL_LIST_ROW_TITLE_FONT_SIZE = '0.75rem';
6
9
  const CONTENT_PANEL_LIST_SECTION_BOTTOM_SPACING = 1;
7
10
 
@@ -7,7 +7,10 @@ import { postTypesMap, type Slug } from '../../api/post';
7
7
  import { useContentPanelCoordinator } from '../../contexts/content-panel-coordinator';
8
8
  import useAccessiblePanelPostTypes from '../../hooks/use-accessible-panel-post-types';
9
9
  import useCanCreate from '../../hooks/use-can-create';
10
+ import { POPUPS_SITE_CONTENT_SECTION_ID } from '../../popups/constants';
11
+ import { getSiteContentHeaderCreateItems } from '../../site-content-header-create-items';
10
12
  import ContentPanelAddIconButton from './content-panel-add-icon-button';
13
+ import PopupHeaderCreateMenuItem from './popups/popup-header-create-menu-item';
11
14
 
12
15
  const typeIcons: Record< Slug, typeof PageTypeIcon > = {
13
16
  page: PageTypeIcon,
@@ -36,7 +39,8 @@ export default function ContentPanelHeaderAdd() {
36
39
  variant: 'popover',
37
40
  popupId: 'elementor-content-panel-header-add',
38
41
  } );
39
- const canAddAny = accessibleSlugs.length > 0;
42
+ const headerCreateItems = getSiteContentHeaderCreateItems();
43
+ const canAddAny = true;
40
44
 
41
45
  const buttonProps = bindTrigger( popupState );
42
46
  const menuProps = bindMenu( popupState );
@@ -48,6 +52,13 @@ export default function ContentPanelHeaderAdd() {
48
52
  } );
49
53
  };
50
54
 
55
+ const handleSelectPopup = () => {
56
+ popupState.close();
57
+ requestAnimationFrame( () => {
58
+ requestCreate( POPUPS_SITE_CONTENT_SECTION_ID );
59
+ } );
60
+ };
61
+
51
62
  return (
52
63
  <>
53
64
  <ContentPanelAddIconButton
@@ -59,6 +70,17 @@ export default function ContentPanelHeaderAdd() {
59
70
  { accessibleSlugs.map( ( slug ) => (
60
71
  <HeaderAddMenuItem key={ slug } onSelect={ handleSelectType } slug={ slug } />
61
72
  ) ) }
73
+ <PopupHeaderCreateMenuItem onSelect={ handleSelectPopup } />
74
+ { headerCreateItems.map( ( item ) => (
75
+ <React.Fragment key={ item.id }>
76
+ { item.renderMenuItem( () => {
77
+ popupState.close();
78
+ requestAnimationFrame( () => {
79
+ requestCreate( item.id );
80
+ } );
81
+ } ) }
82
+ </React.Fragment>
83
+ ) ) }
62
84
  </Menu>
63
85
  </>
64
86
  );
@@ -0,0 +1,50 @@
1
+ import * as React from 'react';
2
+ import { useRef } from 'react';
3
+ import { PopupTemplateIcon } from '@elementor/icons';
4
+ import { Box, ListItemIcon, ListItemText, MenuItem } from '@elementor/ui';
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ import { env } from '../../../env';
8
+ import {
9
+ SiteContentPopupsPromotionChip,
10
+ type SiteContentPopupsPromotionChipRef,
11
+ } from './site-content-popups-promotion-chip';
12
+
13
+ type PopupHeaderCreateMenuItemProps = {
14
+ onSelect: () => void;
15
+ };
16
+
17
+ export default function PopupHeaderCreateMenuItem( { onSelect }: PopupHeaderCreateMenuItemProps ) {
18
+ const promotionRef = useRef< SiteContentPopupsPromotionChipRef >( null );
19
+ const canCreate = env.popups?.can_use ?? false;
20
+ const label = __( 'Popup', 'elementor' );
21
+
22
+ const handleClick = () => {
23
+ if ( ! canCreate ) {
24
+ promotionRef.current?.toggle();
25
+ return;
26
+ }
27
+
28
+ onSelect();
29
+ };
30
+
31
+ return (
32
+ <MenuItem onClick={ handleClick }>
33
+ <ListItemIcon>
34
+ <PopupTemplateIcon fontSize="small" color={ canCreate ? 'action' : 'disabled' } />
35
+ </ListItemIcon>
36
+ <ListItemText
37
+ primary={ label }
38
+ primaryTypographyProps={ {
39
+ variant: 'body2',
40
+ color: canCreate ? 'text.primary' : 'text.disabled',
41
+ } }
42
+ />
43
+ { ! canCreate && (
44
+ <Box sx={ { flexShrink: 0, ml: 'auto', pl: 1 } }>
45
+ <SiteContentPopupsPromotionChip ref={ promotionRef } />
46
+ </Box>
47
+ ) }
48
+ </MenuItem>
49
+ );
50
+ }
@@ -0,0 +1,70 @@
1
+ import * as React from 'react';
2
+ import { forwardRef, type MouseEvent, useCallback, useImperativeHandle, useRef } from 'react';
3
+ import { Stack } from '@elementor/ui';
4
+ import { __, sprintf } from '@wordpress/i18n';
5
+
6
+ import { env } from '../../../env';
7
+ import ContentPanelAddIconButton from '../content-panel-add-icon-button';
8
+ import {
9
+ SiteContentPopupsPromotionChip,
10
+ type SiteContentPopupsPromotionChipRef,
11
+ } from './site-content-popups-promotion-chip';
12
+
13
+ export type PopupSectionAddButtonRef = {
14
+ togglePromotion: () => void;
15
+ };
16
+
17
+ type PopupSectionAddButtonProps = {
18
+ disabled?: boolean;
19
+ onBeforeCreate?: () => void;
20
+ onCreate: () => void;
21
+ };
22
+
23
+ export const PopupSectionAddButton = forwardRef< PopupSectionAddButtonRef, PopupSectionAddButtonProps >(
24
+ ( { disabled, onBeforeCreate, onCreate }, ref ) => {
25
+ const promotionRef = useRef< SiteContentPopupsPromotionChipRef >( null );
26
+ const canCreate = env.popups?.can_use ?? false;
27
+
28
+ const togglePromotion = useCallback( () => {
29
+ promotionRef.current?.toggle();
30
+ }, [] );
31
+
32
+ useImperativeHandle( ref, () => ( { togglePromotion } ), [ togglePromotion ] );
33
+
34
+ const ariaLabel = sprintf(
35
+ /* translators: %s: Document type singular name. */
36
+ __( 'New %s', 'elementor' ),
37
+ __( 'Popup', 'elementor' )
38
+ );
39
+
40
+ if ( canCreate ) {
41
+ return (
42
+ <ContentPanelAddIconButton
43
+ aria-label={ ariaLabel }
44
+ disabled={ disabled }
45
+ onClick={ ( event: MouseEvent ) => {
46
+ event.stopPropagation();
47
+ onBeforeCreate?.();
48
+ onCreate();
49
+ } }
50
+ />
51
+ );
52
+ }
53
+
54
+ return (
55
+ <Stack
56
+ alignItems="center"
57
+ direction="row"
58
+ onClick={ ( event: MouseEvent ) => {
59
+ event.stopPropagation();
60
+ onBeforeCreate?.();
61
+ togglePromotion();
62
+ } }
63
+ sx={ { cursor: 'pointer' } }
64
+ >
65
+ <ContentPanelAddIconButton aria-label={ ariaLabel } tabIndex={ -1 } />
66
+ <SiteContentPopupsPromotionChip ref={ promotionRef } />
67
+ </Stack>
68
+ );
69
+ }
70
+ );
@@ -0,0 +1,62 @@
1
+ import * as React from 'react';
2
+ import { forwardRef, type MouseEvent, useCallback, useImperativeHandle, useState } from 'react';
3
+ import { type PromotionTrackingData, trackUpgradePromotionClick, trackViewPromotion } from '@elementor/editor-controls';
4
+ import { PromotionChip, PromotionPopover, useCanvasClickHandler } from '@elementor/editor-ui';
5
+ import { Box } from '@elementor/ui';
6
+ import { __ } from '@wordpress/i18n';
7
+
8
+ import { env } from '../../../env';
9
+ import { POPUP_SITE_CONTENT_UPGRADE_URL } from '../../../popups/constants';
10
+
11
+ const TRACKING_DATA: PromotionTrackingData = {
12
+ target_name: 'popups',
13
+ target_location: 'widget_panel',
14
+ };
15
+
16
+ export type SiteContentPopupsPromotionChipRef = {
17
+ toggle: () => void;
18
+ };
19
+
20
+ export const SiteContentPopupsPromotionChip = forwardRef< SiteContentPopupsPromotionChipRef >( ( _, ref ) => {
21
+ const [ isOpen, setIsOpen ] = useState( false );
22
+ const upgradeUrl = env.popups?.upgrade_url ?? POPUP_SITE_CONTENT_UPGRADE_URL;
23
+
24
+ useCanvasClickHandler( isOpen, () => setIsOpen( false ) );
25
+
26
+ const toggle = useCallback( () => {
27
+ setIsOpen( ( previous ) => {
28
+ if ( ! previous ) {
29
+ trackViewPromotion( TRACKING_DATA );
30
+ }
31
+
32
+ return ! previous;
33
+ } );
34
+ }, [] );
35
+
36
+ useImperativeHandle( ref, () => ( { toggle } ), [ toggle ] );
37
+
38
+ return (
39
+ <PromotionPopover
40
+ open={ isOpen }
41
+ title={ __( 'Popups', 'elementor' ) }
42
+ content={ __( 'Upgrade to continue creating and editing popups.', 'elementor' ) }
43
+ ctaText={ __( 'Upgrade now', 'elementor' ) }
44
+ ctaUrl={ upgradeUrl }
45
+ onClose={ ( event: MouseEvent ) => {
46
+ event.stopPropagation();
47
+ setIsOpen( false );
48
+ } }
49
+ onCtaClick={ () => trackUpgradePromotionClick( TRACKING_DATA ) }
50
+ >
51
+ <Box
52
+ onClick={ ( event: MouseEvent ) => {
53
+ event.stopPropagation();
54
+ toggle();
55
+ } }
56
+ sx={ { cursor: 'pointer', display: 'inline-flex' } }
57
+ >
58
+ <PromotionChip />
59
+ </Box>
60
+ </PromotionPopover>
61
+ );
62
+ } );
@@ -15,6 +15,7 @@ type Props = {
15
15
  postTitle: string;
16
16
  isLoading: boolean;
17
17
  callback: ( inputValue: string ) => void;
18
+ onDismiss?: () => void;
18
19
  };
19
20
 
20
21
  const EDIT_ROW_FOCUS_BORDER_WIDTH_PX = 2;
@@ -57,8 +58,9 @@ const editRowInputSx = {
57
58
  width: '100%',
58
59
  };
59
60
 
60
- export default function EditModeTemplate( { postTitle, isLoading, callback }: Props ) {
61
+ export default function EditModeTemplate( { postTitle, isLoading, callback, onDismiss }: Props ) {
61
62
  const { resetEditMode } = usePostListContext();
63
+ const dismissEditMode = onDismiss ?? resetEditMode;
62
64
  const [ title, setTitle ] = useState( postTitle );
63
65
  const [ touched, setTouched ] = useState( false );
64
66
  const [ inputError, setInputError ] = useState< string | null >( null );
@@ -70,7 +72,7 @@ export default function EditModeTemplate( { postTitle, isLoading, callback }: Pr
70
72
  }
71
73
 
72
74
  if ( ! touched ) {
73
- resetEditMode();
75
+ dismissEditMode();
74
76
  return;
75
77
  }
76
78
 
@@ -113,7 +115,9 @@ export default function EditModeTemplate( { postTitle, isLoading, callback }: Pr
113
115
  <ListItem
114
116
  disablePadding
115
117
  sx={ contentPanelListRowPaddingSx }
116
- secondaryAction={ <CloseButton isLoading={ isLoading } closeButton={ closeButton } /> }
118
+ secondaryAction={
119
+ <CloseButton isLoading={ isLoading } closeButton={ closeButton } onDismiss={ dismissEditMode } />
120
+ }
117
121
  >
118
122
  <Box
119
123
  component="form"
@@ -150,13 +154,12 @@ export default function EditModeTemplate( { postTitle, isLoading, callback }: Pr
150
154
  type CloseButtonProps = {
151
155
  isLoading: boolean;
152
156
  closeButton: MutableRefObject< HTMLButtonElement | undefined >;
157
+ onDismiss: () => void;
153
158
  };
154
159
 
155
- function CloseButton( { isLoading, closeButton }: CloseButtonProps ) {
156
- const { resetEditMode } = usePostListContext();
157
-
160
+ function CloseButton( { isLoading, closeButton, onDismiss }: CloseButtonProps ) {
158
161
  return (
159
- <IconButton size="tiny" color="secondary" onClick={ resetEditMode } ref={ closeButton } disabled={ isLoading }>
162
+ <IconButton size="tiny" color="secondary" onClick={ onDismiss } ref={ closeButton } disabled={ isLoading }>
160
163
  { isLoading ? <CircularProgress size="1rem" /> : <XIcon fontSize="tiny" /> }
161
164
  </IconButton>
162
165
  );
@@ -3,6 +3,7 @@ import { List, Skeleton, Stack } from '@elementor/ui';
3
3
 
4
4
  import { type Slug } from '../../api/post';
5
5
  import { PostListContextProvider } from '../../contexts/post-list-context';
6
+ import { getSiteContentSections } from '../../site-content-sections';
6
7
  import PostsCollapsibleList from './posts-list/posts-collapsible-list';
7
8
  import UserLoadError from './user-load-error';
8
9
 
@@ -32,6 +33,8 @@ export default function ShellPanelBodyContent( {
32
33
  return <UserLoadError />;
33
34
  }
34
35
 
36
+ const extraSections = getSiteContentSections();
37
+
35
38
  return (
36
39
  <List dense disablePadding sx={ { py: 0, width: '100%' } }>
37
40
  { accessiblePostTypes.map( ( postTypeSlug, index ) => (
@@ -39,6 +42,9 @@ export default function ShellPanelBodyContent( {
39
42
  <PostsCollapsibleList isOpenByDefault={ index === 0 } />
40
43
  </PostListContextProvider>
41
44
  ) ) }
45
+ { extraSections.map( ( section ) => (
46
+ <React.Fragment key={ section.id }>{ section.render() }</React.Fragment>
47
+ ) ) }
42
48
  </List>
43
49
  );
44
50
  }
@@ -92,9 +92,11 @@ const PageTitle = ( { title }: { title: string } ) => {
92
92
  noWrap
93
93
  sx={ {
94
94
  ...contentPanelListRowTitleSx,
95
- flex: 1,
96
95
  flexBasis: 'auto',
96
+ flexShrink: 1,
97
97
  minWidth: 0,
98
+ overflow: 'hidden',
99
+ textOverflow: 'ellipsis',
98
100
  } }
99
101
  >
100
102
  { modifiedTitle }
@@ -104,7 +106,7 @@ const PageTitle = ( { title }: { title: string } ) => {
104
106
 
105
107
  export default function PageTitleAndStatus( { title, status }: { title: string; status: string } ) {
106
108
  return (
107
- <Box alignItems="center" display="flex" minWidth={ 0 }>
109
+ <Box alignItems="center" display="flex" minWidth={ 0 } sx={ { overflow: 'hidden' } }>
108
110
  <PageTitle title={ title } />
109
111
  <PageStatus status={ status } />
110
112
  </Box>
@@ -10,6 +10,8 @@ import {
10
10
  toggleSiteContentStatusFilter,
11
11
  } from '../site-content-status-filter';
12
12
 
13
+ export type ContentPanelSectionId = Slug | ( string & {} );
14
+
13
15
  type SectionHandlers = {
14
16
  setExpanded: ( expanded: boolean ) => void;
15
17
  startCreate: () => void;
@@ -19,36 +21,36 @@ type ContentPanelCoordinatorValue = {
19
21
  clearActiveToolbarFilters: () => void;
20
22
  clearSiteContentSort: () => void;
21
23
  clearStatusFilters: () => void;
22
- registerSection: ( type: Slug, handlers: SectionHandlers ) => void;
23
- requestCreate: ( type: Slug ) => void;
24
+ registerSection: ( type: ContentPanelSectionId, handlers: SectionHandlers ) => void;
25
+ requestCreate: ( type: ContentPanelSectionId ) => void;
24
26
  searchQuery: string;
25
27
  setSearchQuery: ( query: string ) => void;
26
28
  setSiteContentSort: ( sort: SiteContentSortOption ) => void;
27
29
  siteContentSort: SiteContentSortOption;
28
30
  statusFilters: SiteContentStatusFilters;
29
31
  toggleStatusFilter: ( filter: SiteContentSelectableStatus ) => void;
30
- unregisterSection: ( type: Slug ) => void;
32
+ unregisterSection: ( type: ContentPanelSectionId ) => void;
31
33
  };
32
34
 
33
35
  const ContentPanelCoordinatorContext = createContext< ContentPanelCoordinatorValue | null >( null );
34
36
 
35
37
  export function ContentPanelCoordinatorProvider( { children }: { children: ReactNode } ) {
36
- const sectionsRef = useRef( new Map< Slug, SectionHandlers >() );
38
+ const sectionsRef = useRef( new Map< ContentPanelSectionId, SectionHandlers >() );
37
39
  const [ searchQuery, setSearchQuery ] = useState( '' );
38
40
  const [ siteContentSort, setSiteContentSortState ] = useState< SiteContentSortOption >( DEFAULT_SITE_CONTENT_SORT );
39
41
  const [ statusFilters, setStatusFilters ] = useState< SiteContentStatusFilters >(
40
42
  EMPTY_SITE_CONTENT_STATUS_FILTERS
41
43
  );
42
44
 
43
- const registerSection = useCallback( ( type: Slug, handlers: SectionHandlers ) => {
45
+ const registerSection = useCallback( ( type: ContentPanelSectionId, handlers: SectionHandlers ) => {
44
46
  sectionsRef.current.set( type, handlers );
45
47
  }, [] );
46
48
 
47
- const unregisterSection = useCallback( ( type: Slug ) => {
49
+ const unregisterSection = useCallback( ( type: ContentPanelSectionId ) => {
48
50
  sectionsRef.current.delete( type );
49
51
  }, [] );
50
52
 
51
- const requestCreate = useCallback( ( type: Slug ) => {
53
+ const requestCreate = useCallback( ( type: ContentPanelSectionId ) => {
52
54
  const handlers = sectionsRef.current.get( type );
53
55
 
54
56
  if ( ! handlers ) {
package/src/env.ts CHANGED
@@ -1,11 +1,18 @@
1
1
  import { parseEnv } from '@elementor/env';
2
2
 
3
+ export type PopupsSiteContentEnv = {
4
+ can_use: boolean;
5
+ upgrade_url: string;
6
+ };
7
+
3
8
  export const { env } = parseEnv< {
4
9
  can_access_site_content_panel: boolean;
5
10
  is_pages_panel_active: boolean;
11
+ popups?: PopupsSiteContentEnv;
6
12
  } >( '@elementor/editor-site-navigation', ( envData ) => {
7
13
  return envData as {
8
14
  can_access_site_content_panel: boolean;
9
15
  is_pages_panel_active: boolean;
16
+ popups?: PopupsSiteContentEnv;
10
17
  };
11
18
  } );
package/src/index.ts CHANGED
@@ -1,6 +1,39 @@
1
1
  export { extendIconsMap } from './icons-map';
2
2
 
3
3
  export { init } from './init';
4
+ export {
5
+ getSiteContentSections,
6
+ registerSiteContentSection,
7
+ resetSiteContentSections,
8
+ type SiteContentSection,
9
+ } from './site-content-sections';
10
+ export {
11
+ getSiteContentHeaderCreateItems,
12
+ registerSiteContentHeaderCreateItem,
13
+ resetSiteContentHeaderCreateItems,
14
+ type SiteContentHeaderCreateItem,
15
+ } from './site-content-header-create-items';
16
+ export {
17
+ ContentPanelCoordinatorProvider,
18
+ useContentPanelCoordinator,
19
+ type ContentPanelSectionId,
20
+ } from './contexts/content-panel-coordinator';
21
+ export { default as SiteContentCollapsibleList } from './components/panel/posts-list/collapsible-list';
22
+ export { default as SiteContentListErrorState } from './components/panel/posts-list/error-state';
23
+ export { default as SiteContentPaginationActions } from './components/panel/posts-list/post-list-pagination-actions';
24
+ export { usePostListPagination } from './hooks/use-post-list-pagination';
25
+ export { POST_PER_PAGE } from './api/post';
26
+ export { type Post } from './types';
27
+ export { contentPanelListItemButtonSx, contentPanelListRowPaddingSx } from './components/panel/content-panel-chrome';
28
+ export { default as ContentPanelAddIconButton } from './components/panel/content-panel-add-icon-button';
29
+ export { default as SiteContentPageTitleAndStatus } from './components/shared/page-title-and-status';
30
+ export { default as SiteContentEditModeTemplate } from './components/panel/posts-list/list-items/edit-mode-template';
31
+ export {
32
+ PopupSectionAddButton,
33
+ type PopupSectionAddButtonRef,
34
+ } from './components/panel/popups/popup-section-add-button';
35
+ export { POPUPS_SITE_CONTENT_SECTION_ID } from './popups/constants';
36
+ export { env, type PopupsSiteContentEnv } from './env';
4
37
  export {
5
38
  injectIntoSiteContentListItemActions,
6
39
  SiteContentListItemActionsSlot,
@@ -0,0 +1,3 @@
1
+ export const POPUPS_SITE_CONTENT_SECTION_ID = 'popups';
2
+
3
+ export const POPUP_SITE_CONTENT_UPGRADE_URL = 'https://go.elementor.com/go-pro-site-content-popups/';
@@ -0,0 +1,28 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ export type SiteContentHeaderCreateItem = {
4
+ id: string;
5
+ priority?: number;
6
+ renderMenuItem: ( onSelect: () => void ) => ReactNode;
7
+ };
8
+
9
+ const registeredHeaderCreateItems = new Map< string, SiteContentHeaderCreateItem >();
10
+
11
+ const DEFAULT_HEADER_CREATE_PRIORITY = 0;
12
+
13
+ export function registerSiteContentHeaderCreateItem( item: SiteContentHeaderCreateItem ) {
14
+ registeredHeaderCreateItems.set( item.id, item );
15
+ }
16
+
17
+ export function getSiteContentHeaderCreateItems(): SiteContentHeaderCreateItem[] {
18
+ return Array.from( registeredHeaderCreateItems.values() ).sort( ( first, second ) => {
19
+ const firstPriority = first.priority ?? DEFAULT_HEADER_CREATE_PRIORITY;
20
+ const secondPriority = second.priority ?? DEFAULT_HEADER_CREATE_PRIORITY;
21
+
22
+ return firstPriority - secondPriority;
23
+ } );
24
+ }
25
+
26
+ export function resetSiteContentHeaderCreateItems() {
27
+ registeredHeaderCreateItems.clear();
28
+ }
@@ -0,0 +1,26 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ export type SiteContentSection = {
4
+ id: string;
5
+ priority?: number;
6
+ render: () => ReactNode;
7
+ };
8
+
9
+ const registeredSections = new Map< string, SiteContentSection >();
10
+
11
+ const DEFAULT_SECTION_PRIORITY = 0;
12
+
13
+ export function registerSiteContentSection( section: SiteContentSection ) {
14
+ registeredSections.set( section.id, section );
15
+ }
16
+
17
+ export function getSiteContentSections(): SiteContentSection[] {
18
+ return Array.from( registeredSections.values() ).sort(
19
+ ( first, second ) =>
20
+ ( first.priority ?? DEFAULT_SECTION_PRIORITY ) - ( second.priority ?? DEFAULT_SECTION_PRIORITY )
21
+ );
22
+ }
23
+
24
+ export function resetSiteContentSections() {
25
+ registeredSections.clear();
26
+ }