@elementor/editor-variables 4.0.0-676 → 4.0.0-677

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-676",
3
+ "version": "4.0.0-677",
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-676",
43
- "@elementor/editor-canvas": "4.0.0-676",
44
- "@elementor/editor-controls": "4.0.0-676",
45
- "@elementor/editor-current-user": "4.0.0-676",
46
- "@elementor/editor-mcp": "4.0.0-676",
47
- "@elementor/editor-panels": "4.0.0-676",
48
- "@elementor/editor-props": "4.0.0-676",
49
- "@elementor/editor-ui": "4.0.0-676",
50
- "@elementor/editor-v1-adapters": "4.0.0-676",
51
- "@elementor/menus": "4.0.0-676",
52
- "@elementor/http-client": "4.0.0-676",
42
+ "@elementor/editor": "4.0.0-677",
43
+ "@elementor/editor-canvas": "4.0.0-677",
44
+ "@elementor/editor-controls": "4.0.0-677",
45
+ "@elementor/editor-current-user": "4.0.0-677",
46
+ "@elementor/editor-mcp": "4.0.0-677",
47
+ "@elementor/editor-panels": "4.0.0-677",
48
+ "@elementor/editor-props": "4.0.0-677",
49
+ "@elementor/editor-ui": "4.0.0-677",
50
+ "@elementor/editor-v1-adapters": "4.0.0-677",
51
+ "@elementor/menus": "4.0.0-677",
52
+ "@elementor/http-client": "4.0.0-677",
53
53
  "@elementor/icons": "^1.68.0",
54
- "@elementor/events": "4.0.0-676",
55
- "@elementor/schema": "4.0.0-676",
54
+ "@elementor/events": "4.0.0-677",
55
+ "@elementor/schema": "4.0.0-677",
56
56
  "@elementor/ui": "1.37.2",
57
- "@elementor/utils": "4.0.0-676",
57
+ "@elementor/utils": "4.0.0-677",
58
58
  "@wordpress/i18n": "^5.13.0"
59
59
  },
60
60
  "peerDependencies": {
@@ -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 ) => {
@@ -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>
@@ -1,5 +1,6 @@
1
- import { useState } from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
  import * as React from 'react';
3
+ import { 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
@@ -1,4 +1,5 @@
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
5
  import { isExperimentActive } from '@elementor/editor-v1-adapters';
@@ -69,7 +70,15 @@ export function registerVariableTypes() {
69
70
  styleTransformer: EmptyTransformer,
70
71
  variableType: 'size',
71
72
  selectionFilter: () => [],
72
- emptyState: <CtaButton size="small" href={ 'https://go.elementor.com/go-pro-panel-size-variable/' } />,
73
+ emptyState: (
74
+ <CtaButton
75
+ size="small"
76
+ href={ 'https://go.elementor.com/go-pro-panel-size-variable/' }
77
+ onClick={ () =>
78
+ trackUpgradePromotionClick( { target_name: 'variables_popover', location_l1: 'variables_list' } )
79
+ }
80
+ />
81
+ ),
73
82
  };
74
83
 
75
84
  registerVariableType( {