@elementor/editor-variables 4.0.0-manual → 4.0.0

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-variables",
3
- "version": "4.0.0-manual",
3
+ "version": "4.0.0",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,22 +39,22 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "4.0.0-manual",
43
- "@elementor/editor-canvas": "4.0.0-manual",
44
- "@elementor/editor-controls": "4.0.0-manual",
45
- "@elementor/editor-current-user": "4.0.0-manual",
46
- "@elementor/editor-mcp": "4.0.0-manual",
47
- "@elementor/editor-panels": "4.0.0-manual",
48
- "@elementor/editor-props": "4.0.0-manual",
49
- "@elementor/editor-ui": "4.0.0-manual",
50
- "@elementor/editor-v1-adapters": "4.0.0-manual",
51
- "@elementor/menus": "4.0.0-manual",
52
- "@elementor/http-client": "4.0.0-manual",
53
- "@elementor/icons": "^1.68.0",
54
- "@elementor/events": "4.0.0-manual",
55
- "@elementor/schema": "4.0.0-manual",
42
+ "@elementor/editor": "4.0.0",
43
+ "@elementor/editor-canvas": "4.0.0",
44
+ "@elementor/editor-controls": "4.0.0",
45
+ "@elementor/editor-current-user": "4.0.0",
46
+ "@elementor/editor-mcp": "4.0.0",
47
+ "@elementor/editor-panels": "4.0.0",
48
+ "@elementor/editor-props": "4.0.0",
49
+ "@elementor/editor-ui": "4.0.0",
50
+ "@elementor/editor-v1-adapters": "4.0.0",
51
+ "@elementor/menus": "4.0.0",
52
+ "@elementor/http-client": "4.0.0",
53
+ "@elementor/icons": "^1.72.0",
54
+ "@elementor/events": "4.0.0",
55
+ "@elementor/schema": "4.0.0",
56
56
  "@elementor/ui": "1.37.2",
57
- "@elementor/utils": "4.0.0-manual",
57
+ "@elementor/utils": "4.0.0",
58
58
  "@wordpress/i18n": "^5.13.0"
59
59
  },
60
60
  "peerDependencies": {
@@ -0,0 +1,33 @@
1
+ import { useEffect } from 'react';
2
+
3
+ import { service } from '../service';
4
+ import { styleVariablesRepository } from '../style-variables-repository';
5
+
6
+ export function GlobalStylesImportListener() {
7
+ useEffect( () => {
8
+ const handleGlobalStylesImported = ( event: CustomEvent ) => {
9
+ const importedVars = event.detail?.global_variables;
10
+
11
+ if ( ! importedVars ) {
12
+ return;
13
+ }
14
+
15
+ if ( importedVars.data && typeof importedVars.data === 'object' ) {
16
+ styleVariablesRepository.update( importedVars.data );
17
+ }
18
+
19
+ service.load();
20
+ };
21
+
22
+ window.addEventListener( 'elementor/global-styles/imported', handleGlobalStylesImported as EventListener );
23
+
24
+ return () => {
25
+ window.removeEventListener(
26
+ 'elementor/global-styles/imported',
27
+ handleGlobalStylesImported as EventListener
28
+ );
29
+ };
30
+ }, [] );
31
+
32
+ return null;
33
+ }
@@ -0,0 +1,46 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import {
3
+ __privateListenTo as listenTo,
4
+ __privateOpenRoute as openRoute,
5
+ routeOpenEvent,
6
+ } from '@elementor/editor-v1-adapters';
7
+
8
+ import { usePanelActions } from './variables-manager/variables-manager-panel';
9
+
10
+ const EVENT_NAME = 'elementor/open-variables-manager';
11
+ const DEFAULT_PANEL_ROUTE = 'panel/elements/categories';
12
+
13
+ export function OpenPanelFromEvent() {
14
+ const { open } = usePanelActions();
15
+ const pendingRef = useRef( false );
16
+ const [ readyToOpen, setReadyToOpen ] = useState( false );
17
+
18
+ useEffect( () => {
19
+ if ( readyToOpen ) {
20
+ setReadyToOpen( false );
21
+ open();
22
+ }
23
+ }, [ readyToOpen, open ] );
24
+
25
+ useEffect( () => {
26
+ return listenTo( routeOpenEvent( DEFAULT_PANEL_ROUTE ), () => {
27
+ if ( pendingRef.current ) {
28
+ pendingRef.current = false;
29
+ setReadyToOpen( true );
30
+ }
31
+ } );
32
+ }, [] );
33
+
34
+ useEffect( () => {
35
+ const handler = () => {
36
+ pendingRef.current = true;
37
+ openRoute( DEFAULT_PANEL_ROUTE );
38
+ };
39
+
40
+ window.addEventListener( EVENT_NAME, handler );
41
+
42
+ return () => window.removeEventListener( EVENT_NAME, handler );
43
+ }, [] );
44
+
45
+ return null;
46
+ }
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
- import { forwardRef, type MouseEvent, useImperativeHandle, useState } from 'react';
2
+ import { forwardRef, type MouseEvent, useCallback, useImperativeHandle, useState } from 'react';
3
+ import { type PromotionTrackingData, trackUpgradePromotionClick, trackViewPromotion } from '@elementor/editor-controls';
3
4
  import { PromotionChip, PromotionPopover, useCanvasClickHandler } from '@elementor/editor-ui';
4
5
  import { Box } from '@elementor/ui';
5
6
  import { capitalize } from '@elementor/utils';
@@ -8,6 +9,7 @@ import { __, sprintf } from '@wordpress/i18n';
8
9
  type VariablePromotionChipProps = {
9
10
  variableType: string;
10
11
  upgradeUrl: string;
12
+ trackingData: PromotionTrackingData;
11
13
  };
12
14
 
13
15
  export type VariablePromotionChipRef = {
@@ -15,14 +17,21 @@ export type VariablePromotionChipRef = {
15
17
  };
16
18
 
17
19
  export const VariablePromotionChip = forwardRef< VariablePromotionChipRef, VariablePromotionChipProps >(
18
- ( { variableType, upgradeUrl }, ref ) => {
20
+ ( { variableType, upgradeUrl, trackingData }, ref ) => {
19
21
  const [ isOpen, setIsOpen ] = useState( false );
20
22
 
21
23
  useCanvasClickHandler( isOpen, () => setIsOpen( false ) );
22
24
 
23
- const toggle = () => setIsOpen( ( prev ) => ! prev );
25
+ const toggle = useCallback( () => {
26
+ setIsOpen( ( prev ) => {
27
+ if ( ! prev ) {
28
+ trackViewPromotion( trackingData );
29
+ }
30
+ return ! prev;
31
+ } );
32
+ }, [ trackingData ] );
24
33
 
25
- useImperativeHandle( ref, () => ( { toggle } ), [] );
34
+ useImperativeHandle( ref, () => ( { toggle } ), [ toggle ] );
26
35
 
27
36
  const title = sprintf(
28
37
  /* translators: %s: Variable Type. */
@@ -47,6 +56,7 @@ export const VariablePromotionChip = forwardRef< VariablePromotionChipRef, Varia
47
56
  e.stopPropagation();
48
57
  setIsOpen( false );
49
58
  } }
59
+ onCtaClick={ () => trackUpgradePromotionClick( trackingData ) }
50
60
  >
51
61
  <Box
52
62
  onClick={ ( e: MouseEvent ) => {
@@ -142,11 +142,12 @@ export const VariableCreation = ( { onGoBack, onClose }: Props ) => {
142
142
  } }
143
143
  onErrorChange={ ( errorMsg ) => {
144
144
  setLabelFieldError( {
145
- value: label,
145
+ value: '',
146
146
  message: errorMsg,
147
147
  } );
148
148
  } }
149
149
  onKeyDown={ handleKeyDown }
150
+ focusOnShow
150
151
  />
151
152
  </FormField>
152
153
  { ValueField && (
@@ -208,11 +208,12 @@ export const VariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Props ) =
208
208
  } }
209
209
  onErrorChange={ ( errorMsg ) => {
210
210
  setLabelFieldError( {
211
- value: label,
211
+ value: '',
212
212
  message: errorMsg,
213
213
  } );
214
214
  } }
215
215
  onKeyDown={ handleKeyDown }
216
+ focusOnShow
216
217
  />
217
218
  </FormField>
218
219
  { ValueField && (
@@ -127,11 +127,12 @@ export const VariableRestore = ( { variableId, onClose, onSubmit }: Props ) => {
127
127
  } }
128
128
  onErrorChange={ ( errorMsg ) => {
129
129
  setLabelFieldError( {
130
- value: label,
130
+ value: '',
131
131
  message: errorMsg,
132
132
  } );
133
133
  } }
134
134
  onKeyDown={ handleKeyDown }
135
+ focusOnShow
135
136
  />
136
137
  </FormField>
137
138
  { ValueField && (
@@ -13,6 +13,8 @@ import { VariableEditableCell } from '../variable-editable-cell';
13
13
  import { VariableEditMenu, type VariableManagerMenuAction } from './variable-edit-menu';
14
14
  import { VariableTableCell } from './variable-table-cell';
15
15
 
16
+ const TRACKING_DATA = { target_name: 'variables_manager', target_location: 'variables_manager' } as const;
17
+
16
18
  export type Row = ReturnType< typeof getVariableType > & {
17
19
  id: string;
18
20
  type: string;
@@ -200,6 +202,7 @@ export const VariableRow = (
200
202
  variableType={ row.variableType }
201
203
  upgradeUrl={ `https://go.elementor.com/renew-license-manager-${ row.variableType }-variable` }
202
204
  ref={ promotionRef }
205
+ trackingData={ TRACKING_DATA }
203
206
  />
204
207
  ) }
205
208
  <VariableEditMenu menuActions={ menuActions( row.id ) } disabled={ isSorting } itemId={ row.id } />
@@ -11,6 +11,12 @@ import { trackVariablesManagerEvent } from '../../utils/tracking';
11
11
  import { getVariableTypes } from '../../variables-registry/variable-type-registry';
12
12
  import { VariablePromotionChip, type VariablePromotionChipRef } from '../ui/variable-promotion-chip';
13
13
 
14
+ const TRACKING_DATA = {
15
+ target_name: 'variables_manager',
16
+ target_location: 'variables_manager',
17
+ location_l1: 'create variable menu',
18
+ } as const;
19
+
14
20
  export const SIZE = 'tiny';
15
21
 
16
22
  type MenuOptionConfig = {
@@ -133,6 +139,7 @@ const MenuOption = ( {
133
139
  variableType={ config.variableType }
134
140
  upgradeUrl={ `https://go.elementor.com/go-pro-manager-${ config.variableType }-variable/` }
135
141
  ref={ promotionRef }
142
+ trackingData={ TRACKING_DATA }
136
143
  />
137
144
  ) }
138
145
  </MenuItem>
@@ -142,13 +149,19 @@ const MenuOption = ( {
142
149
  export const getDefaultName = ( variables: TVariablesList, baseName: string ) => {
143
150
  const pattern = new RegExp( `^${ baseName }-(\\d+)$`, 'i' );
144
151
 
145
- let counter = 1;
152
+ const takenNumbers = new Set< number >();
146
153
 
147
154
  Object.values( variables ).forEach( ( variable ) => {
148
- if ( pattern.test( variable.label ) ) {
149
- counter = Math.max( counter, parseInt( variable.label.match( pattern )?.[ 1 ] ?? '0', 10 ) + 1 );
155
+ const match = variable.label.match( pattern );
156
+ if ( match ) {
157
+ takenNumbers.add( parseInt( match[ 1 ], 10 ) );
150
158
  }
151
159
  } );
152
160
 
161
+ let counter = 1;
162
+ while ( takenNumbers.has( counter ) ) {
163
+ counter++;
164
+ }
165
+
153
166
  return `${ baseName }-${ counter }`;
154
167
  };
@@ -25,7 +25,7 @@ import {
25
25
  } from '@elementor/ui';
26
26
  import { __ } from '@wordpress/i18n';
27
27
 
28
- import { trackVariablesManagerEvent } from '../../utils/tracking';
28
+ import { trackVariablesManagerEvent, trackVariableSyncToV3 } from '../../utils/tracking';
29
29
  import { type ErrorResponse, type MappedError, mapServerError } from '../../utils/validations';
30
30
  import { getMenuActionsForVariable, getVariableType } from '../../variables-registry/variable-type-registry';
31
31
  import { DeleteConfirmationDialog } from '../ui/delete-confirmation-dialog';
@@ -76,8 +76,8 @@ export function VariablesManagerPanel() {
76
76
  handleOnChange,
77
77
  createVariable,
78
78
  handleDeleteVariable,
79
- handleStartSync,
80
- handleStopSync,
79
+ handleStartSync: startSyncFromState,
80
+ handleStopSync: stopSyncFromState,
81
81
  handleSave,
82
82
  isSaving,
83
83
  handleSearch,
@@ -151,23 +151,37 @@ export function VariablesManagerPanel() {
151
151
  [ handleDeleteVariable ]
152
152
  );
153
153
 
154
- const handleStopSyncWithConfirmation = useCallback(
154
+ const commitStopSync = useCallback(
155
155
  ( itemId: string ) => {
156
- handleStopSync( itemId );
157
- setStopSyncConfirmation( null );
156
+ stopSyncFromState( itemId );
157
+ const variable = variables[ itemId ];
158
+ if ( variable ) {
159
+ trackVariableSyncToV3( { variableLabel: variable.label, action: 'unsync' } );
160
+ }
158
161
  },
159
- [ handleStopSync ]
162
+ [ stopSyncFromState, variables ]
160
163
  );
161
164
 
162
- const handleShowStopSyncDialog = useCallback(
165
+ const handleStartSync = useCallback(
166
+ ( itemId: string ) => {
167
+ startSyncFromState( itemId );
168
+ const variable = variables[ itemId ];
169
+ if ( variable ) {
170
+ trackVariableSyncToV3( { variableLabel: variable.label, action: 'sync' } );
171
+ }
172
+ },
173
+ [ startSyncFromState, variables ]
174
+ );
175
+
176
+ const handleStopSync = useCallback(
163
177
  ( itemId: string ) => {
164
178
  if ( ! isStopSyncSuppressed ) {
165
179
  setStopSyncConfirmation( itemId );
166
180
  } else {
167
- handleStopSync( itemId );
181
+ commitStopSync( itemId );
168
182
  }
169
183
  },
170
- [ isStopSyncSuppressed, handleStopSync ]
184
+ [ isStopSyncSuppressed, commitStopSync ]
171
185
  );
172
186
 
173
187
  const buildMenuActions = useCallback(
@@ -182,7 +196,7 @@ export function VariablesManagerPanel() {
182
196
  variableId,
183
197
  handlers: {
184
198
  onStartSync: handleStartSync,
185
- onStopSync: handleShowStopSyncDialog,
199
+ onStopSync: handleStopSync,
186
200
  },
187
201
  } );
188
202
 
@@ -203,7 +217,7 @@ export function VariablesManagerPanel() {
203
217
 
204
218
  return [ ...typeActions, deleteAction ];
205
219
  },
206
- [ variables, handleStartSync, handleShowStopSyncDialog ]
220
+ [ variables, handleStartSync, handleStopSync ]
207
221
  );
208
222
 
209
223
  const hasVariables = Object.keys( variables ).length > 0;
@@ -368,7 +382,10 @@ export function VariablesManagerPanel() {
368
382
  <StopSyncConfirmationDialog
369
383
  open
370
384
  onClose={ () => setStopSyncConfirmation( null ) }
371
- onConfirm={ () => handleStopSyncWithConfirmation( stopSyncConfirmation ) }
385
+ onConfirm={ () => {
386
+ commitStopSync( stopSyncConfirmation );
387
+ setStopSyncConfirmation( null );
388
+ } }
372
389
  />
373
390
  ) }
374
391
 
@@ -436,7 +453,7 @@ const StopSyncConfirmationDialog = ( { open, onClose, onConfirm }: StopSyncConfi
436
453
  <ConfirmationDialog.Content>
437
454
  <ConfirmationDialog.ContentText>
438
455
  { __(
439
- 'This will disconnect the variable color from version 3. Existing uses on your site will automatically switch to a default color.',
456
+ 'This will disconnect the variable color from Global Colors. Existing uses on your site will automatically switch to a default color.',
440
457
  'elementor'
441
458
  ) }
442
459
  </ConfirmationDialog.ContentText>
@@ -1,5 +1,6 @@
1
- import { useState } from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
  import * as React from 'react';
3
+ import { trackUpgradePromotionClick, trackViewPromotion } from '@elementor/editor-controls';
3
4
  import {
4
5
  PopoverHeader,
5
6
  PopoverMenuList,
@@ -132,6 +133,16 @@ export const VariablesSelection = ( { closePopover, onAdd, onEdit, onSettings, d
132
133
  setSearchValue( '' );
133
134
  };
134
135
 
136
+ useEffect( () => {
137
+ if ( disabled ) {
138
+ trackViewPromotion( {
139
+ target_name: 'variables_popover',
140
+ target_location: 'widget_panel',
141
+ location_l1: 'variables_list',
142
+ } );
143
+ }
144
+ }, [ disabled ] );
145
+
135
146
  return (
136
147
  <SectionPopoverBody>
137
148
  <PopoverHeader
@@ -172,6 +183,12 @@ export const VariablesSelection = ( { closePopover, onAdd, onEdit, onSettings, d
172
183
  variableType
173
184
  ) }
174
185
  upgradeUrl={ getProUpgradeUrl( variableType ) }
186
+ onCtaClick={ () =>
187
+ trackUpgradePromotionClick( {
188
+ target_name: 'variables_popover',
189
+ location_l1: 'variables_list',
190
+ } )
191
+ }
175
192
  />
176
193
  ) }
177
194
  </>
package/src/init.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  import { injectIntoLogic, injectIntoTop } from '@elementor/editor';
2
2
  import { registerControlReplacement } from '@elementor/editor-controls';
3
+ import { getMCPByDomain } from '@elementor/editor-mcp';
3
4
  import { __registerPanel as registerPanel } from '@elementor/editor-panels';
4
5
  import { isTransformable, type PropValue } from '@elementor/editor-props';
5
6
  import { controlActionsMenu } from '@elementor/menus';
6
7
 
8
+ import { GlobalStylesImportListener } from './components/global-styles-import-listener';
9
+ import { OpenPanelFromEvent } from './components/open-panel-from-event';
7
10
  import { OpenPanelFromUrl } from './components/open-panel-from-url';
8
11
  import { panel } from './components/variables-manager/variables-manager-panel';
9
12
  import { VariableControl } from './controls/variable-control';
@@ -43,7 +46,7 @@ export function init() {
43
46
  } );
44
47
 
45
48
  variablesService.init().then( () => {
46
- initMcp();
49
+ initMcp( getMCPByDomain( 'variables' ), getMCPByDomain( 'canvas' ) );
47
50
  } );
48
51
 
49
52
  injectIntoTop( {
@@ -51,11 +54,21 @@ export function init() {
51
54
  component: StyleVariablesRenderer,
52
55
  } );
53
56
 
57
+ injectIntoLogic( {
58
+ id: 'variables-import-listener',
59
+ component: GlobalStylesImportListener,
60
+ } );
61
+
54
62
  injectIntoLogic( {
55
63
  id: 'variables-open-panel-from-url',
56
64
  component: OpenPanelFromUrl,
57
65
  } );
58
66
 
67
+ injectIntoLogic( {
68
+ id: 'variables-open-panel-from-event',
69
+ component: OpenPanelFromEvent,
70
+ } );
71
+
59
72
  registerPanel( panel );
60
73
  }
61
74
 
package/src/mcp/index.ts CHANGED
@@ -1,12 +1,18 @@
1
- import { isAngieAvailable } from '@elementor/editor-mcp';
1
+ import { type MCPRegistryEntry } from '@elementor/editor-mcp';
2
2
 
3
3
  import { initManageVariableTool } from './manage-variable-tool';
4
4
  import { initVariablesResource } from './variables-resource';
5
5
 
6
- export function initMcp() {
7
- if ( ! isAngieAvailable() ) {
8
- return;
9
- }
10
- initManageVariableTool();
11
- initVariablesResource();
6
+ export function initMcp( reg: MCPRegistryEntry, canvasMcpEntry: MCPRegistryEntry ) {
7
+ const { setMCPDescription } = reg;
8
+ setMCPDescription(
9
+ `Everything related to V4 ( Atomic ) variables.
10
+ # Global variables
11
+ - Create/update/delete global variables
12
+ - Get list of global variables
13
+ - Get details of a global variable
14
+ `
15
+ );
16
+ initManageVariableTool( reg );
17
+ initVariablesResource( reg, canvasMcpEntry );
12
18
  }
@@ -1,11 +1,12 @@
1
- import { getMCPByDomain } from '@elementor/editor-mcp';
1
+ import { type MCPRegistryEntry } from '@elementor/editor-mcp';
2
2
  import { z } from '@elementor/schema';
3
3
 
4
4
  import { service } from '../service';
5
5
  import { GLOBAL_VARIABLES_URI } from './variables-resource';
6
6
 
7
- export const initManageVariableTool = () => {
8
- getMCPByDomain( 'variables' ).addTool( {
7
+ export const initManageVariableTool = ( reg: MCPRegistryEntry ) => {
8
+ const { addTool } = reg;
9
+ addTool( {
9
10
  name: 'manage-global-variable',
10
11
  schema: {
11
12
  action: z.enum( [ 'create', 'update', 'delete' ] ).describe( 'Operation to perform' ),
@@ -1,17 +1,14 @@
1
- import { getMCPByDomain } from '@elementor/editor-mcp';
1
+ import { type MCPRegistryEntry } from '@elementor/editor-mcp';
2
2
 
3
3
  import { service } from '../service';
4
4
  import { type TVariable } from '../storage';
5
5
 
6
6
  export const GLOBAL_VARIABLES_URI = 'elementor://global-variables';
7
7
 
8
- export const initVariablesResource = () => {
9
- const canvasMcpEntry = getMCPByDomain( 'canvas' );
10
- const variablesMcpEntry = getMCPByDomain( 'variables' );
11
-
8
+ export const initVariablesResource = ( variablesMcpEntry: MCPRegistryEntry, canvasMcpEntry: MCPRegistryEntry ) => {
12
9
  [ canvasMcpEntry, variablesMcpEntry ].forEach( ( entry ) => {
13
- const { mcpServer } = entry;
14
- mcpServer.resource(
10
+ const { resource, sendResourceUpdated } = entry;
11
+ resource(
15
12
  'global-variables',
16
13
  GLOBAL_VARIABLES_URI,
17
14
  {
@@ -33,7 +30,7 @@ export const initVariablesResource = () => {
33
30
  );
34
31
 
35
32
  window.addEventListener( 'variables:updated', () => {
36
- mcpServer.server.sendResourceUpdated( {
33
+ sendResourceUpdated( {
37
34
  uri: GLOBAL_VARIABLES_URI,
38
35
  } );
39
36
  } );
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
+ import { trackUpgradePromotionClick } from '@elementor/editor-controls';
2
3
  import { colorPropTypeUtil, sizePropTypeUtil, stringPropTypeUtil } from '@elementor/editor-props';
3
4
  import { CtaButton } from '@elementor/editor-ui';
4
- import { isExperimentActive } from '@elementor/editor-v1-adapters';
5
- import { BrushIcon, ExpandDiagonalIcon, ResetIcon, TextIcon } from '@elementor/icons';
5
+ import { BrushIcon, ExpandDiagonalIcon, RefreshIcon, RefreshOffIcon, TextIcon } from '@elementor/icons';
6
6
  import { __ } from '@wordpress/i18n';
7
7
 
8
8
  import { ColorField } from './components/fields/color-field';
@@ -27,21 +27,17 @@ export function registerVariableTypes() {
27
27
  menuActionsFactory: ( { variable, variableId, handlers } ) => {
28
28
  const actions = [];
29
29
 
30
- if ( ! isExperimentActive( 'e_design_system_sync' ) ) {
31
- return [];
32
- }
33
-
34
30
  if ( variable.sync_to_v3 ) {
35
31
  actions.push( {
36
- name: __( 'Stop syncing to Version 3', 'elementor' ),
37
- icon: ResetIcon,
32
+ name: __( 'Stop syncing to Global Colors', 'elementor' ),
33
+ icon: RefreshOffIcon,
38
34
  color: 'text.primary',
39
35
  onClick: () => handlers.onStopSync( variableId ),
40
36
  } );
41
37
  } else {
42
38
  actions.push( {
43
- name: __( 'Sync to Version 3', 'elementor' ),
44
- icon: ResetIcon,
39
+ name: __( 'Sync to Global Colors', 'elementor' ),
40
+ icon: RefreshIcon,
45
41
  color: 'text.primary',
46
42
  onClick: () => handlers.onStartSync( variableId ),
47
43
  } );
@@ -69,7 +65,15 @@ export function registerVariableTypes() {
69
65
  styleTransformer: EmptyTransformer,
70
66
  variableType: 'size',
71
67
  selectionFilter: () => [],
72
- emptyState: <CtaButton size="small" href={ 'https://go.elementor.com/go-pro-panel-size-variable/' } />,
68
+ emptyState: (
69
+ <CtaButton
70
+ size="small"
71
+ href={ 'https://go.elementor.com/go-pro-panel-size-variable/' }
72
+ onClick={ () =>
73
+ trackUpgradePromotionClick( { target_name: 'variables_popover', location_l1: 'variables_list' } )
74
+ }
75
+ />
76
+ ),
73
77
  };
74
78
 
75
79
  registerVariableType( {
@@ -10,7 +10,7 @@ import { Portal } from '@elementor/ui';
10
10
  import { styleVariablesRepository } from '../style-variables-repository';
11
11
  import { type StyleVariables, type Variable } from '../types';
12
12
 
13
- const VARIABLES_WRAPPER = 'body';
13
+ const VARIABLES_WRAPPER = ':root';
14
14
 
15
15
  export function StyleVariablesRenderer() {
16
16
  const container = usePortalContainer();
package/src/service.ts CHANGED
@@ -216,17 +216,17 @@ export const service = {
216
216
 
217
217
  if ( results ) {
218
218
  results.forEach( ( result: OperationResult ) => {
219
- if ( result.variable ) {
220
- const { id: variableId, ...variableData } = result.variable;
219
+ const variableId = result.id;
221
220
 
221
+ if ( result.variable ) {
222
222
  if ( result.type === 'create' ) {
223
- storage.add( variableId, variableData );
223
+ storage.add( variableId, result.variable );
224
224
  } else {
225
- storage.update( variableId, variableData );
225
+ storage.update( variableId, result.variable );
226
226
  }
227
227
 
228
228
  styleVariablesRepository.update( {
229
- [ variableId ]: variableData,
229
+ [ variableId ]: result.variable,
230
230
  } );
231
231
  }
232
232
  } );
@@ -52,3 +52,32 @@ export const trackVariablesManagerEvent = ( { action, varType, controlPath }: Va
52
52
 
53
53
  dispatchEvent?.( name, eventData );
54
54
  };
55
+
56
+ type VariableSyncToV3Data = {
57
+ variableLabel: string;
58
+ action: 'sync' | 'unsync';
59
+ };
60
+
61
+ export const trackVariableSyncToV3 = ( { variableLabel, action }: VariableSyncToV3Data ) => {
62
+ try {
63
+ const { dispatchEvent, config } = getMixpanel();
64
+ if ( ! config?.names?.variables?.variableSyncToV3 ) {
65
+ return;
66
+ }
67
+
68
+ const name = config.names.variables.variableSyncToV3;
69
+ const isSync = action === 'sync';
70
+
71
+ dispatchEvent?.( name, {
72
+ interaction_type: 'click',
73
+ target_type: variableLabel,
74
+ target_name: isSync ? 'sync_to_v3' : 'unsync_to_v3',
75
+ interaction_result: isSync ? 'var_is_synced_to_V3' : 'var_is_unsynced_from_V3',
76
+ target_location: 'widget_panel',
77
+ location_l1: 'var_manager',
78
+ interaction_description: isSync
79
+ ? `user_synced_${ variableLabel }_to_v3`
80
+ : `user_unsync_${ variableLabel }_from_v3`,
81
+ } );
82
+ } catch {}
83
+ };