@elementor/editor-controls 3.32.0-95 → 3.33.0-97

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-controls",
3
3
  "description": "This package contains the controls model and utils for the Elementor editor",
4
- "version": "3.32.0-95",
4
+ "version": "3.33.0-97",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,21 +40,21 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor-current-user": "3.32.0-95",
44
- "@elementor/editor-elements": "3.32.0-95",
45
- "@elementor/editor-props": "3.32.0-95",
46
- "@elementor/editor-responsive": "3.32.0-95",
47
- "@elementor/editor-ui": "3.32.0-95",
48
- "@elementor/editor-v1-adapters": "3.32.0-95",
49
- "@elementor/env": "3.32.0-95",
50
- "@elementor/http-client": "3.32.0-95",
43
+ "@elementor/editor-current-user": "3.33.0-97",
44
+ "@elementor/editor-elements": "3.33.0-97",
45
+ "@elementor/editor-props": "3.33.0-97",
46
+ "@elementor/editor-responsive": "3.33.0-97",
47
+ "@elementor/editor-ui": "3.33.0-97",
48
+ "@elementor/editor-v1-adapters": "3.33.0-97",
49
+ "@elementor/env": "3.33.0-97",
50
+ "@elementor/http-client": "3.33.0-97",
51
51
  "@elementor/icons": "^1.51.1",
52
- "@elementor/locations": "3.32.0-95",
53
- "@elementor/query": "3.32.0-95",
54
- "@elementor/session": "3.32.0-95",
52
+ "@elementor/locations": "3.33.0-97",
53
+ "@elementor/query": "3.33.0-97",
54
+ "@elementor/session": "3.33.0-97",
55
55
  "@elementor/ui": "1.36.12",
56
- "@elementor/utils": "3.32.0-95",
57
- "@elementor/wp-media": "3.32.0-95",
56
+ "@elementor/utils": "3.33.0-97",
57
+ "@elementor/wp-media": "3.33.0-97",
58
58
  "@wordpress/i18n": "^5.13.0",
59
59
  "@monaco-editor/react": "^4.7.0"
60
60
  },
@@ -5,6 +5,7 @@ import { type PopupState, usePopupState } from '@elementor/ui';
5
5
 
6
6
  import { useBoundProp } from '../../../bound-prop-context/use-bound-prop';
7
7
  import { useSyncExternalState } from '../../../hooks/use-sync-external-state';
8
+ import { eventBus } from '../../../services/event-bus';
8
9
  import { type Item, type RepeatablePropValue } from '../types';
9
10
 
10
11
  type SetterFn< T > = ( prevItems: T ) => T;
@@ -46,7 +47,11 @@ export const RepeaterContextProvider = < T extends RepeatablePropValue = Repeata
46
47
  children,
47
48
  initial,
48
49
  propTypeUtil,
49
- }: React.PropsWithChildren< { initial: T; propTypeUtil: PropTypeUtil< string, T[] >; isSortable?: boolean } > ) => {
50
+ }: React.PropsWithChildren< {
51
+ initial: T;
52
+ propTypeUtil: PropTypeUtil< string, T[] >;
53
+ isSortable?: boolean;
54
+ } > ) => {
50
55
  const { value: repeaterValues, setValue: setRepeaterValues } = useBoundProp( propTypeUtil );
51
56
 
52
57
  const [ items, setItems ] = useSyncExternalState( {
@@ -92,10 +97,20 @@ export const RepeaterContextProvider = < T extends RepeatablePropValue = Repeata
92
97
 
93
98
  setOpenItemIndex( newIndex );
94
99
  popoverState.open( rowRef ?? ev );
100
+
101
+ eventBus.emit( `${ propTypeUtil.key }-item-added`, {
102
+ itemValue: initial.value,
103
+ } );
95
104
  };
96
105
 
97
106
  const removeItem = ( index: number ) => {
107
+ const itemToRemove = items[ index ];
108
+
98
109
  setItems( items.filter( ( _, pos ) => pos !== index ) );
110
+
111
+ eventBus.emit( `${ propTypeUtil.key }-item-removed`, {
112
+ itemValue: itemToRemove?.value,
113
+ } );
99
114
  };
100
115
 
101
116
  const updateItem = ( updatedItem: T, index: number ) => {
@@ -0,0 +1,28 @@
1
+ import { getSelectedElements } from '@elementor/editor-elements';
2
+ import { sendMixpanelEvent } from '@elementor/utils';
3
+
4
+ import { eventBus } from '../../services/event-bus';
5
+ import { type initialTransitionValue } from './data';
6
+
7
+ type TransitionItemValue = typeof initialTransitionValue;
8
+
9
+ const transitionRepeaterMixpanelEvent = {
10
+ eventName: 'click_added_transition',
11
+ location: 'V4 Style Tab',
12
+ secondaryLocation: 'Transition control',
13
+ trigger: 'click',
14
+ };
15
+
16
+ export function subscribeToTransitionEvent() {
17
+ eventBus.subscribe( 'transition-item-added', ( data ) => {
18
+ const payload = data as { itemValue?: TransitionItemValue };
19
+ const value = payload?.itemValue?.selection?.value?.value?.value;
20
+ const selectedElements = getSelectedElements();
21
+ const widgetType = selectedElements[ 0 ]?.type ?? null;
22
+ sendMixpanelEvent( {
23
+ transition_type: value ?? 'unknown',
24
+ ...transitionRepeaterMixpanelEvent,
25
+ widget_type: widgetType,
26
+ } );
27
+ } );
28
+ }
@@ -10,6 +10,7 @@ import { createControl } from '../../create-control';
10
10
  import { RepeatableControl } from '../repeatable-control';
11
11
  import { SelectionSizeControl } from '../selection-size-control';
12
12
  import { initialTransitionValue, transitionProperties } from './data';
13
+ import { subscribeToTransitionEvent } from './trainsition-events';
13
14
  import { TransitionSelector } from './transition-selector';
14
15
 
15
16
  const DURATION_CONFIG = {
@@ -70,6 +71,8 @@ const disableAddItemTooltipContent = (
70
71
  </Alert>
71
72
  );
72
73
 
74
+ subscribeToTransitionEvent();
75
+
73
76
  export const TransitionRepeaterControl = createControl(
74
77
  ( {
75
78
  recentlyUsedListGetter,
@@ -0,0 +1,38 @@
1
+ class EventBus {
2
+ private listeners = new Map< string, Set< ( data?: unknown ) => void > >();
3
+
4
+ subscribe( eventName: string, callback: ( data?: unknown ) => void ) {
5
+ if ( ! this.listeners.has( eventName ) ) {
6
+ this.listeners.set( eventName, new Set() );
7
+ }
8
+ const eventListeners = this.listeners.get( eventName );
9
+ if ( eventListeners ) {
10
+ eventListeners.add( callback );
11
+ }
12
+ }
13
+
14
+ unsubscribe( eventName: string, callback: ( data?: unknown ) => void ) {
15
+ const eventListeners = this.listeners.get( eventName );
16
+ if ( ! eventListeners ) {
17
+ return;
18
+ }
19
+
20
+ eventListeners.delete( callback );
21
+ if ( eventListeners.size === 0 ) {
22
+ this.listeners.delete( eventName );
23
+ }
24
+ }
25
+
26
+ emit( eventName: string, data?: unknown ) {
27
+ const eventListeners = this.listeners.get( eventName );
28
+ if ( eventListeners ) {
29
+ eventListeners.forEach( ( callback ) => callback( data ) );
30
+ }
31
+ }
32
+
33
+ clearAll(): void {
34
+ this.listeners.clear();
35
+ }
36
+ }
37
+
38
+ export const eventBus = new EventBus();