@elementor/editor-variables 4.1.0-720 → 4.1.0-721

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/dist/index.mjs CHANGED
@@ -515,6 +515,26 @@ var trackVariablesManagerEvent = ({ action, varType, controlPath }) => {
515
515
  }
516
516
  dispatchEvent?.(name, eventData);
517
517
  };
518
+ var trackVariableSyncToV3 = ({ variableLabel, action }) => {
519
+ try {
520
+ const { dispatchEvent, config } = getMixpanel();
521
+ if (!config?.names?.variables?.variableSyncToV3) {
522
+ return;
523
+ }
524
+ const name = config.names.variables.variableSyncToV3;
525
+ const isSync = action === "sync";
526
+ dispatchEvent?.(name, {
527
+ interaction_type: "click",
528
+ target_type: variableLabel,
529
+ target_name: isSync ? "sync_to_v3" : "unsync_to_v3",
530
+ interaction_result: isSync ? "var_is_synced_to_V3" : "var_is_unsynced_from_V3",
531
+ target_location: "widget_panel",
532
+ location_l1: "var_manager",
533
+ interaction_description: isSync ? `user_synced_${variableLabel}_to_v3` : `user_unsync_${variableLabel}_from_v3`
534
+ });
535
+ } catch {
536
+ }
537
+ };
518
538
 
519
539
  // src/utils/validations.ts
520
540
  import { AlertTriangleFilledIcon, InfoCircleFilledIcon } from "@elementor/icons";
@@ -1920,8 +1940,8 @@ function VariablesManagerPanel() {
1920
1940
  handleOnChange,
1921
1941
  createVariable: createVariable2,
1922
1942
  handleDeleteVariable,
1923
- handleStartSync,
1924
- handleStopSync,
1943
+ handleStartSync: startSyncFromState,
1944
+ handleStopSync: stopSyncFromState,
1925
1945
  handleSave,
1926
1946
  isSaving,
1927
1947
  handleSearch,
@@ -1982,22 +2002,35 @@ function VariablesManagerPanel() {
1982
2002
  },
1983
2003
  [handleDeleteVariable]
1984
2004
  );
1985
- const handleStopSyncWithConfirmation = useCallback6(
2005
+ const commitStopSync = useCallback6(
1986
2006
  (itemId) => {
1987
- handleStopSync(itemId);
1988
- setStopSyncConfirmation(null);
2007
+ stopSyncFromState(itemId);
2008
+ const variable = variables[itemId];
2009
+ if (variable) {
2010
+ trackVariableSyncToV3({ variableLabel: variable.label, action: "unsync" });
2011
+ }
2012
+ },
2013
+ [stopSyncFromState, variables]
2014
+ );
2015
+ const handleStartSync = useCallback6(
2016
+ (itemId) => {
2017
+ startSyncFromState(itemId);
2018
+ const variable = variables[itemId];
2019
+ if (variable) {
2020
+ trackVariableSyncToV3({ variableLabel: variable.label, action: "sync" });
2021
+ }
1989
2022
  },
1990
- [handleStopSync]
2023
+ [startSyncFromState, variables]
1991
2024
  );
1992
- const handleShowStopSyncDialog = useCallback6(
2025
+ const handleStopSync = useCallback6(
1993
2026
  (itemId) => {
1994
2027
  if (!isStopSyncSuppressed) {
1995
2028
  setStopSyncConfirmation(itemId);
1996
2029
  } else {
1997
- handleStopSync(itemId);
2030
+ commitStopSync(itemId);
1998
2031
  }
1999
2032
  },
2000
- [isStopSyncSuppressed, handleStopSync]
2033
+ [isStopSyncSuppressed, commitStopSync]
2001
2034
  );
2002
2035
  const buildMenuActions = useCallback6(
2003
2036
  (variableId) => {
@@ -2010,7 +2043,7 @@ function VariablesManagerPanel() {
2010
2043
  variableId,
2011
2044
  handlers: {
2012
2045
  onStartSync: handleStartSync,
2013
- onStopSync: handleShowStopSyncDialog
2046
+ onStopSync: handleStopSync
2014
2047
  }
2015
2048
  });
2016
2049
  const deleteAction = {
@@ -2028,7 +2061,7 @@ function VariablesManagerPanel() {
2028
2061
  };
2029
2062
  return [...typeActions, deleteAction];
2030
2063
  },
2031
- [variables, handleStartSync, handleShowStopSyncDialog]
2064
+ [variables, handleStartSync, handleStopSync]
2032
2065
  );
2033
2066
  const hasVariables = Object.keys(variables).length > 0;
2034
2067
  return /* @__PURE__ */ React14.createElement(ThemeProvider, null, /* @__PURE__ */ React14.createElement(Panel, null, /* @__PURE__ */ React14.createElement(
@@ -2163,7 +2196,10 @@ function VariablesManagerPanel() {
2163
2196
  {
2164
2197
  open: true,
2165
2198
  onClose: () => setStopSyncConfirmation(null),
2166
- onConfirm: () => handleStopSyncWithConfirmation(stopSyncConfirmation)
2199
+ onConfirm: () => {
2200
+ commitStopSync(stopSyncConfirmation);
2201
+ setStopSyncConfirmation(null);
2202
+ }
2167
2203
  }
2168
2204
  ), isSaveChangesDialogOpen && /* @__PURE__ */ React14.createElement(SaveChangesDialog, null, /* @__PURE__ */ React14.createElement(SaveChangesDialog.Title, { onClose: closeSaveChangesDialog }, __10("You have unsaved changes", "elementor")), /* @__PURE__ */ React14.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React14.createElement(SaveChangesDialog.ContentText, null, __10("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React14.createElement(
2169
2205
  SaveChangesDialog.Actions,