@elementor/editor-editing-panel 4.5.0-1202 → 4.5.0-1203

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-editing-panel",
3
- "version": "4.5.0-1202",
3
+ "version": "4.5.0-1203",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,32 +39,32 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "4.5.0-1202",
43
- "@elementor/editor-canvas": "4.5.0-1202",
44
- "@elementor/editor-controls": "4.5.0-1202",
45
- "@elementor/editor-current-user": "4.5.0-1202",
46
- "@elementor/editor-documents": "4.5.0-1202",
47
- "@elementor/editor-elements": "4.5.0-1202",
48
- "@elementor/editor-interactions": "4.5.0-1202",
49
- "@elementor/editor-notifications": "4.5.0-1202",
50
- "@elementor/editor-panels": "4.5.0-1202",
51
- "@elementor/editor-props": "4.5.0-1202",
52
- "@elementor/editor-responsive": "4.5.0-1202",
53
- "@elementor/editor-styles": "4.5.0-1202",
54
- "@elementor/editor-styles-repository": "4.5.0-1202",
55
- "@elementor/editor-ui": "4.5.0-1202",
56
- "@elementor/editor-v1-adapters": "4.5.0-1202",
57
- "@elementor/http-client": "4.5.0-1202",
42
+ "@elementor/editor": "4.5.0-1203",
43
+ "@elementor/editor-canvas": "4.5.0-1203",
44
+ "@elementor/editor-controls": "4.5.0-1203",
45
+ "@elementor/editor-current-user": "4.5.0-1203",
46
+ "@elementor/editor-documents": "4.5.0-1203",
47
+ "@elementor/editor-elements": "4.5.0-1203",
48
+ "@elementor/editor-interactions": "4.5.0-1203",
49
+ "@elementor/editor-notifications": "4.5.0-1203",
50
+ "@elementor/editor-panels": "4.5.0-1203",
51
+ "@elementor/editor-props": "4.5.0-1203",
52
+ "@elementor/editor-responsive": "4.5.0-1203",
53
+ "@elementor/editor-styles": "4.5.0-1203",
54
+ "@elementor/editor-styles-repository": "4.5.0-1203",
55
+ "@elementor/editor-ui": "4.5.0-1203",
56
+ "@elementor/editor-v1-adapters": "4.5.0-1203",
57
+ "@elementor/http-client": "4.5.0-1203",
58
58
  "@elementor/icons": "~1.78.1",
59
- "@elementor/editor-variables": "4.5.0-1202",
60
- "@elementor/locations": "4.5.0-1202",
61
- "@elementor/menus": "4.5.0-1202",
62
- "@elementor/query": "4.5.0-1202",
63
- "@elementor/schema": "4.5.0-1202",
64
- "@elementor/session": "4.5.0-1202",
59
+ "@elementor/editor-variables": "4.5.0-1203",
60
+ "@elementor/locations": "4.5.0-1203",
61
+ "@elementor/menus": "4.5.0-1203",
62
+ "@elementor/query": "4.5.0-1203",
63
+ "@elementor/schema": "4.5.0-1203",
64
+ "@elementor/session": "4.5.0-1203",
65
65
  "@elementor/ui": "1.41.4",
66
- "@elementor/utils": "4.5.0-1202",
67
- "@elementor/wp-media": "4.5.0-1202",
66
+ "@elementor/utils": "4.5.0-1203",
67
+ "@elementor/wp-media": "4.5.0-1203",
68
68
  "@wordpress/i18n": "^5.13.0"
69
69
  },
70
70
  "peerDependencies": {
@@ -18,6 +18,7 @@ import { __ } from '@wordpress/i18n';
18
18
  import { SettingsControl } from '../../../components/settings-control';
19
19
  import { ElementProvider, useElement } from '../../../contexts/element-context';
20
20
  import { getElementByType } from '../get-element-by-type';
21
+ import { getSubmenuToggle } from './submenu-toggle-registry';
21
22
  import {
22
23
  MENU_ENTRY_ELEMENT_TYPE,
23
24
  MENU_ITEM_ELEMENT_TYPE,
@@ -124,6 +125,7 @@ const ItemContent = ( { value }: { value: MenuItem } ) => {
124
125
  <Stack p={ 2 } gap={ 1.5 }>
125
126
  <ItemNameControl elementId={ value.id } />
126
127
  <ItemLinkControl entryId={ value.id } />
128
+ <SubmenuToggleSlot entryId={ value.id } />
127
129
  </Stack>
128
130
  );
129
131
  };
@@ -186,3 +188,9 @@ const findControlByBind = ( items: ControlItem[], bind: string ): Control | null
186
188
 
187
189
  return null;
188
190
  };
191
+
192
+ const SubmenuToggleSlot = ( { entryId }: { entryId: string } ) => {
193
+ const Toggle = getSubmenuToggle();
194
+
195
+ return <Toggle entryId={ entryId } />;
196
+ };
@@ -0,0 +1,15 @@
1
+ import { type ComponentType } from 'react';
2
+
3
+ import { SubmenuToggle } from './submenu-toggle';
4
+
5
+ export type SubmenuToggleProps = {
6
+ entryId: string | null;
7
+ };
8
+
9
+ let submenuToggle: ComponentType< SubmenuToggleProps > = SubmenuToggle;
10
+
11
+ export const registerSubmenuToggle = ( component: ComponentType< SubmenuToggleProps > ) => {
12
+ submenuToggle = component;
13
+ };
14
+
15
+ export const getSubmenuToggle = () => submenuToggle;
@@ -0,0 +1,64 @@
1
+ import * as React from 'react';
2
+ import { useRef, useState } from 'react';
3
+ import { ControlFormLabel } from '@elementor/editor-controls';
4
+ import { PromotionChip, PromotionPopover } from '@elementor/editor-ui';
5
+ import { Box, Stack, Switch } from '@elementor/ui';
6
+ import { __ } from '@wordpress/i18n';
7
+
8
+ import { getSubmenuPromotion } from './use-submenu';
9
+
10
+ export const SubmenuToggle = ( { entryId }: { entryId: string | null } ) => {
11
+ const [ isPromotionOpen, setIsPromotionOpen ] = useState( false );
12
+ const anchorRef = useRef< HTMLDivElement >( null );
13
+ const promotion = getSubmenuPromotion();
14
+
15
+ if ( ! entryId || ! promotion ) {
16
+ return null;
17
+ }
18
+
19
+ return (
20
+ <Stack
21
+ direction="row"
22
+ alignItems="center"
23
+ justifyContent="space-between"
24
+ ref={ anchorRef }
25
+ data-testid="submenu-toggle-row"
26
+ >
27
+ <Stack direction="row" alignItems="center">
28
+ <ControlFormLabel>{ __( 'Enable Submenu', 'elementor' ) }</ControlFormLabel>
29
+ <PromotionPopover
30
+ open={ isPromotionOpen }
31
+ title={ promotion.title }
32
+ content={ promotion.content }
33
+ ctaUrl={ promotion.ctaUrl }
34
+ ctaText={ __( 'Upgrade Now', 'elementor' ) }
35
+ onClose={ () => setIsPromotionOpen( false ) }
36
+ anchorRef={ anchorRef }
37
+ >
38
+ <Box
39
+ component="span"
40
+ onMouseDown={ ( e: React.MouseEvent ) => e.stopPropagation() }
41
+ onClick={ () => setIsPromotionOpen( ( open ) => ! open ) }
42
+ sx={ { display: 'inline-flex', cursor: 'pointer' } }
43
+ >
44
+ <PromotionChip />
45
+ </Box>
46
+ </PromotionPopover>
47
+ </Stack>
48
+ <Box sx={ { marginInlineEnd: -1 } } onMouseDown={ ( e: React.MouseEvent ) => e.stopPropagation() }>
49
+ <Switch
50
+ size="small"
51
+ checked={ false }
52
+ onChange={ () => setIsPromotionOpen( ( open ) => ! open ) }
53
+ sx={ { cursor: 'pointer' } }
54
+ inputProps={ {
55
+ 'aria-label': __( 'Enable Submenu', 'elementor' ),
56
+ 'aria-haspopup': 'dialog',
57
+ 'aria-expanded': isPromotionOpen,
58
+ style: { cursor: 'pointer' },
59
+ } }
60
+ />
61
+ </Box>
62
+ </Stack>
63
+ );
64
+ };
@@ -0,0 +1,28 @@
1
+ import { type ElementID, getContainer, getWidgetsCache } from '@elementor/editor-elements';
2
+
3
+ import { MENU_ENTRY_ELEMENT_TYPE } from './use-actions';
4
+
5
+ export type SubmenuPromotion = {
6
+ title: string;
7
+ content: string;
8
+ ctaUrl: string;
9
+ };
10
+
11
+ type SubmenuEntitlement = {
12
+ locked: boolean;
13
+ promotion: SubmenuPromotion;
14
+ };
15
+
16
+ export const getSubmenuPromotion = (): SubmenuPromotion | null => {
17
+ const entitlement = getWidgetsCache()?.[ MENU_ENTRY_ELEMENT_TYPE ]?.meta?.submenu_entitlement as
18
+ | SubmenuEntitlement
19
+ | undefined;
20
+
21
+ return entitlement?.locked ? entitlement.promotion : null;
22
+ };
23
+
24
+ export const getParentEntryId = ( elementId: ElementID ): ElementID | null => {
25
+ const parent = getContainer( elementId )?.parent;
26
+
27
+ return parent?.model.get( 'elType' ) === MENU_ENTRY_ELEMENT_TYPE ? parent.id : null;
28
+ };
@@ -4,11 +4,13 @@ import { type ControlRegistry, controlsRegistry } from '../controls-registry';
4
4
  import { AccordionItemsControl } from './accordion-items-control/accordion-items-control';
5
5
  import { ListItemsControl } from './list-items-control/list-items-control';
6
6
  import { MenuItemsControl } from './menu-items-control/menu-items-control';
7
+ import { SubmenuToggleControl } from './submenu-toggle-control/submenu-toggle-control';
7
8
  import { TabsControl } from './tabs-control/tabs-control';
8
9
 
9
10
  const controlTypes = {
10
11
  'list-items': { component: ListItemsControl as ControlComponent, layout: 'full' },
11
12
  'menu-items': { component: MenuItemsControl as ControlComponent, layout: 'full' },
13
+ 'submenu-toggle': { component: SubmenuToggleControl as unknown as ControlComponent, layout: 'full' },
12
14
  tabs: { component: TabsControl as ControlComponent, layout: 'full' },
13
15
  'accordion-items': { component: AccordionItemsControl as ControlComponent, layout: 'full' },
14
16
  } as const satisfies ControlRegistry;
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+
3
+ import { useElement } from '../../../contexts/element-context';
4
+ import { getSubmenuToggle } from '../menu-items-control/submenu-toggle-registry';
5
+ import { getParentEntryId } from '../menu-items-control/use-submenu';
6
+
7
+ export const SubmenuToggleControl = () => {
8
+ const { element } = useElement();
9
+ const Toggle = getSubmenuToggle();
10
+
11
+ return <Toggle entryId={ getParentEntryId( element.id ) } />;
12
+ };
package/src/index.ts CHANGED
@@ -69,3 +69,8 @@ export {
69
69
  getUpdatedValues,
70
70
  extractOrderedDependencies,
71
71
  } from './utils/prop-dependency-utils';
72
+ export {
73
+ registerSubmenuToggle,
74
+ type SubmenuToggleProps,
75
+ } from './controls-registry/element-controls/menu-items-control/submenu-toggle-registry';
76
+ export { SubmenuToggle } from './controls-registry/element-controls/menu-items-control/submenu-toggle';