@elementor/editor-interactions 4.1.0-763 → 4.1.0-765

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
@@ -559,41 +559,6 @@ var PopupStateProvider = ({ children }) => {
559
559
  return /* @__PURE__ */ React3.createElement(PopupStateContext.Provider, { value: { openByDefault, triggerDefaultOpen, resetDefaultOpen } }, children);
560
560
  };
561
561
 
562
- // src/utils/tracking.ts
563
- import { getElementLabel as getElementLabel2 } from "@elementor/editor-elements";
564
- import { getMixpanel } from "@elementor/events";
565
- var TRIGGER_LABELS2 = {
566
- load: "On page load",
567
- scrollIn: "Scroll into view",
568
- scrollOut: "Scroll out of view",
569
- scrollOn: "While scrolling",
570
- hover: "Hover",
571
- click: "Click"
572
- };
573
- var capitalize2 = (s) => s.charAt(0).toUpperCase() + s.slice(1);
574
- var trackInteractionCreated = (elementId, item) => {
575
- const { dispatchEvent, config } = getMixpanel();
576
- if (!config?.names?.interactions?.created) {
577
- return;
578
- }
579
- const trigger = extractString(item.value.trigger);
580
- const effect = extractString(item.value.animation.value.effect);
581
- const type = extractString(item.value.animation.value.type);
582
- dispatchEvent?.(config.names.interactions.created, {
583
- app_type: config?.appTypes?.editor,
584
- window_name: config?.appTypes?.editor,
585
- interaction_type: config?.triggers?.click,
586
- target_name: getElementLabel2(elementId),
587
- interaction_result: "interaction_created",
588
- target_location: config?.locations?.widgetPanel,
589
- location_l1: getElementLabel2(elementId),
590
- location_l2: "interactions",
591
- interaction_description: "interaction_created",
592
- interaction_trigger: TRIGGER_LABELS2[trigger] ?? capitalize2(trigger),
593
- interaction_effect: effect === "custom" ? capitalize2(effect) : `${capitalize2(effect)} ${capitalize2(type)}`
594
- });
595
- };
596
-
597
562
  // src/components/interactions-list.tsx
598
563
  import * as React10 from "react";
599
564
  import { useCallback as useCallback5, useEffect as useEffect2, useMemo as useMemo4, useRef as useRef2 } from "react";
@@ -641,6 +606,41 @@ function syncGridOverlay(trigger, start, end, relativeTo) {
641
606
  }
642
607
  }
643
608
 
609
+ // src/utils/tracking.ts
610
+ import { getElementLabel as getElementLabel2 } from "@elementor/editor-elements";
611
+ import { getMixpanel } from "@elementor/events";
612
+ var TRIGGER_LABELS2 = {
613
+ load: "On page load",
614
+ scrollIn: "Scroll into view",
615
+ scrollOut: "Scroll out of view",
616
+ scrollOn: "While scrolling",
617
+ hover: "Hover",
618
+ click: "Click"
619
+ };
620
+ var capitalize2 = (s) => s.charAt(0).toUpperCase() + s.slice(1);
621
+ var trackInteractionCreated = (elementId, item) => {
622
+ const { dispatchEvent, config } = getMixpanel();
623
+ if (!config?.names?.interactions?.created) {
624
+ return;
625
+ }
626
+ const trigger = extractString(item.value.trigger);
627
+ const effect = extractString(item.value.animation.value.effect);
628
+ const type = extractString(item.value.animation.value.type);
629
+ dispatchEvent?.(config.names.interactions.created, {
630
+ app_type: config?.appTypes?.editor,
631
+ window_name: config?.appTypes?.editor,
632
+ interaction_type: config?.triggers?.click,
633
+ target_name: getElementLabel2(elementId),
634
+ interaction_result: "interaction_created",
635
+ target_location: config?.locations?.widgetPanel,
636
+ location_l1: getElementLabel2(elementId),
637
+ location_l2: "interactions",
638
+ interaction_description: "interaction_created",
639
+ interaction_trigger: TRIGGER_LABELS2[trigger] ?? capitalize2(trigger),
640
+ interaction_effect: effect === "custom" ? capitalize2(effect) : `${capitalize2(effect)} ${capitalize2(type)}`
641
+ });
642
+ };
643
+
644
644
  // src/components/interaction-details.tsx
645
645
  import * as React7 from "react";
646
646
  import { useMemo as useMemo2 } from "react";
@@ -1069,6 +1069,7 @@ function InteractionsList(props) {
1069
1069
  const { interactions, onSelectInteractions, onPlayInteraction, triggerCreateOnShowEmpty } = props;
1070
1070
  const { elementId } = useInteractionsContext();
1071
1071
  const hasInitializedRef = useRef2(false);
1072
+ const newlyCreatedIdsRef = useRef2(/* @__PURE__ */ new Set());
1072
1073
  const handleUpdateInteractions = useCallback5(
1073
1074
  (newInteractions) => {
1074
1075
  onSelectInteractions(newInteractions);
@@ -1078,9 +1079,11 @@ function InteractionsList(props) {
1078
1079
  useEffect2(() => {
1079
1080
  if (triggerCreateOnShowEmpty && !hasInitializedRef.current && (!interactions.items || interactions.items?.length === 0)) {
1080
1081
  hasInitializedRef.current = true;
1082
+ const newItem = createDefaultInteractionItem();
1083
+ newlyCreatedIdsRef.current.add(extractString(newItem.value.interaction_id));
1081
1084
  const newState = {
1082
1085
  version: 1,
1083
- items: [createDefaultInteractionItem()]
1086
+ items: [newItem]
1084
1087
  };
1085
1088
  handleUpdateInteractions(newState);
1086
1089
  }
@@ -1101,11 +1104,11 @@ function InteractionsList(props) {
1101
1104
  if (meta?.action?.type === "add") {
1102
1105
  const addedItem = meta.action.payload[0]?.item;
1103
1106
  if (addedItem) {
1104
- trackInteractionCreated(elementId, addedItem);
1107
+ newlyCreatedIdsRef.current.add(extractString(addedItem.value.interaction_id));
1105
1108
  }
1106
1109
  }
1107
1110
  },
1108
- [interactions, handleUpdateInteractions, elementId]
1111
+ [interactions, handleUpdateInteractions]
1109
1112
  );
1110
1113
  const handleInteractionChange = useCallback5(
1111
1114
  (index, newInteractionValue) => {
@@ -1153,7 +1156,14 @@ function InteractionsList(props) {
1153
1156
  );
1154
1157
  syncGridOverlay(trigger, start, end, relativeTo);
1155
1158
  },
1156
- onPopoverClose: () => dispatchScrollInteraction(null),
1159
+ onPopoverClose: (value) => {
1160
+ dispatchScrollInteraction(null);
1161
+ const id = extractString(value.value.interaction_id);
1162
+ if (newlyCreatedIdsRef.current.has(id)) {
1163
+ newlyCreatedIdsRef.current.delete(id);
1164
+ trackInteractionCreated(elementId, value);
1165
+ }
1166
+ },
1157
1167
  actions: (value) => /* @__PURE__ */ React10.createElement(Tooltip, { key: "preview", placement: "top", title: __6("Preview", "elementor") }, /* @__PURE__ */ React10.createElement(
1158
1168
  IconButton,
1159
1169
  {
@@ -1181,7 +1191,6 @@ function InteractionsTabContent({ elementId }) {
1181
1191
  {
1182
1192
  onCreateInteraction: () => {
1183
1193
  firstInteractionState[1](true);
1184
- trackInteractionCreated(elementId, createDefaultInteractionItem());
1185
1194
  }
1186
1195
  }
1187
1196
  ));