@elementor/editor-interactions 4.0.0-678 → 4.0.0-679
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.js +90 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -11
- package/src/components/interactions-list.tsx +16 -3
- package/src/components/interactions-tab.tsx +3 -0
- package/src/contexts/interactions-context.tsx +2 -0
- package/src/utils/tracking.ts +42 -0
package/dist/index.mjs
CHANGED
|
@@ -81,6 +81,7 @@ var InteractionsProvider = ({ children, elementId }) => {
|
|
|
81
81
|
playElementInteractions(elementId, interactionId);
|
|
82
82
|
};
|
|
83
83
|
const contextValue = {
|
|
84
|
+
elementId,
|
|
84
85
|
interactions,
|
|
85
86
|
setInteractions,
|
|
86
87
|
playInteractions
|
|
@@ -110,32 +111,6 @@ var PopupStateProvider = ({ children }) => {
|
|
|
110
111
|
return /* @__PURE__ */ React3.createElement(PopupStateContext.Provider, { value: { openByDefault, triggerDefaultOpen, resetDefaultOpen } }, children);
|
|
111
112
|
};
|
|
112
113
|
|
|
113
|
-
// src/components/interactions-list.tsx
|
|
114
|
-
import * as React10 from "react";
|
|
115
|
-
import { useCallback as useCallback5, useEffect as useEffect2, useMemo as useMemo3, useRef as useRef3 } from "react";
|
|
116
|
-
import { Repeater } from "@elementor/editor-controls";
|
|
117
|
-
import { InfoCircleFilledIcon, PlayerPlayIcon } from "@elementor/icons";
|
|
118
|
-
import { Alert, AlertTitle, Box as Box2, IconButton, Tooltip } from "@elementor/ui";
|
|
119
|
-
import { __ as __5 } from "@wordpress/i18n";
|
|
120
|
-
|
|
121
|
-
// src/contexts/interactions-item-context.tsx
|
|
122
|
-
import * as React4 from "react";
|
|
123
|
-
import { createContext as createContext3, useContext as useContext3 } from "react";
|
|
124
|
-
var InteractionItemContext = createContext3(null);
|
|
125
|
-
function InteractionItemContextProvider({
|
|
126
|
-
value,
|
|
127
|
-
children
|
|
128
|
-
}) {
|
|
129
|
-
return /* @__PURE__ */ React4.createElement(InteractionItemContext.Provider, { value }, children);
|
|
130
|
-
}
|
|
131
|
-
function useInteractionItemContext() {
|
|
132
|
-
const context = useContext3(InteractionItemContext);
|
|
133
|
-
if (!context) {
|
|
134
|
-
throw new Error("useInteractionItemContext must be used within InteractionItemContextProvider");
|
|
135
|
-
}
|
|
136
|
-
return context;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
114
|
// src/utils/prop-value-utils.ts
|
|
140
115
|
import { sizePropTypeUtil } from "@elementor/editor-props";
|
|
141
116
|
|
|
@@ -389,6 +364,67 @@ var buildDisplayLabel = (item) => {
|
|
|
389
364
|
return `${triggerLabel}: ${effectLabel} ${typeLabel}`;
|
|
390
365
|
};
|
|
391
366
|
|
|
367
|
+
// src/utils/tracking.ts
|
|
368
|
+
import { getElementLabel } from "@elementor/editor-elements";
|
|
369
|
+
import { getMixpanel } from "@elementor/events";
|
|
370
|
+
var TRIGGER_LABELS2 = {
|
|
371
|
+
load: "On page load",
|
|
372
|
+
scrollIn: "Scroll into view",
|
|
373
|
+
scrollOut: "Scroll out of view",
|
|
374
|
+
scrollOn: "While scrolling",
|
|
375
|
+
hover: "Hover",
|
|
376
|
+
click: "Click"
|
|
377
|
+
};
|
|
378
|
+
var capitalize2 = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
379
|
+
var trackInteractionCreated = (elementId, item) => {
|
|
380
|
+
const { dispatchEvent, config } = getMixpanel();
|
|
381
|
+
if (!config?.names?.interactions?.created) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const trigger = extractString(item.value.trigger);
|
|
385
|
+
const effect = extractString(item.value.animation.value.effect);
|
|
386
|
+
const type = extractString(item.value.animation.value.type);
|
|
387
|
+
dispatchEvent?.(config.names.interactions.created, {
|
|
388
|
+
app_type: config?.appTypes?.editor,
|
|
389
|
+
window_name: config?.appTypes?.editor,
|
|
390
|
+
interaction_type: config?.triggers?.click,
|
|
391
|
+
target_name: getElementLabel(elementId),
|
|
392
|
+
interaction_result: "interaction_created",
|
|
393
|
+
target_location: config?.locations?.widgetPanel,
|
|
394
|
+
location_l1: getElementLabel(elementId),
|
|
395
|
+
location_l2: "interactions",
|
|
396
|
+
interaction_description: "interaction_created",
|
|
397
|
+
interaction_trigger: TRIGGER_LABELS2[trigger] ?? capitalize2(trigger),
|
|
398
|
+
interaction_effect: effect === "custom" ? capitalize2(effect) : `${capitalize2(effect)} ${capitalize2(type)}`
|
|
399
|
+
});
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
// src/components/interactions-list.tsx
|
|
403
|
+
import * as React10 from "react";
|
|
404
|
+
import { useCallback as useCallback5, useEffect as useEffect2, useMemo as useMemo3, useRef as useRef3 } from "react";
|
|
405
|
+
import { Repeater } from "@elementor/editor-controls";
|
|
406
|
+
import { InfoCircleFilledIcon, PlayerPlayIcon } from "@elementor/icons";
|
|
407
|
+
import { Alert, AlertTitle, Box as Box2, IconButton, Tooltip } from "@elementor/ui";
|
|
408
|
+
import { __ as __5 } from "@wordpress/i18n";
|
|
409
|
+
|
|
410
|
+
// src/contexts/interactions-item-context.tsx
|
|
411
|
+
import * as React4 from "react";
|
|
412
|
+
import { createContext as createContext3, useContext as useContext3 } from "react";
|
|
413
|
+
var InteractionItemContext = createContext3(null);
|
|
414
|
+
function InteractionItemContextProvider({
|
|
415
|
+
value,
|
|
416
|
+
children
|
|
417
|
+
}) {
|
|
418
|
+
return /* @__PURE__ */ React4.createElement(InteractionItemContext.Provider, { value }, children);
|
|
419
|
+
}
|
|
420
|
+
function useInteractionItemContext() {
|
|
421
|
+
const context = useContext3(InteractionItemContext);
|
|
422
|
+
if (!context) {
|
|
423
|
+
throw new Error("useInteractionItemContext must be used within InteractionItemContextProvider");
|
|
424
|
+
}
|
|
425
|
+
return context;
|
|
426
|
+
}
|
|
427
|
+
|
|
392
428
|
// src/components/interactions-list-item.tsx
|
|
393
429
|
import * as React9 from "react";
|
|
394
430
|
import { useCallback as useCallback4 } from "react";
|
|
@@ -830,6 +866,7 @@ var InteractionsListItem = ({
|
|
|
830
866
|
var MAX_NUMBER_OF_INTERACTIONS = 5;
|
|
831
867
|
function InteractionsList(props) {
|
|
832
868
|
const { interactions, onSelectInteractions, onPlayInteraction, triggerCreateOnShowEmpty } = props;
|
|
869
|
+
const { elementId } = useInteractionsContext();
|
|
833
870
|
const hasInitializedRef = useRef3(false);
|
|
834
871
|
const handleUpdateInteractions = useCallback5(
|
|
835
872
|
(newInteractions) => {
|
|
@@ -855,13 +892,19 @@ function InteractionsList(props) {
|
|
|
855
892
|
"elementor"
|
|
856
893
|
))) : void 0;
|
|
857
894
|
const handleRepeaterChange = useCallback5(
|
|
858
|
-
(newItems) => {
|
|
895
|
+
(newItems, _, meta) => {
|
|
859
896
|
handleUpdateInteractions({
|
|
860
897
|
...interactions,
|
|
861
898
|
items: newItems
|
|
862
899
|
});
|
|
900
|
+
if (meta?.action?.type === "add") {
|
|
901
|
+
const addedItem = meta.action.payload[0]?.item;
|
|
902
|
+
if (addedItem) {
|
|
903
|
+
trackInteractionCreated(elementId, addedItem);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
863
906
|
},
|
|
864
|
-
[interactions, handleUpdateInteractions]
|
|
907
|
+
[interactions, handleUpdateInteractions, elementId]
|
|
865
908
|
);
|
|
866
909
|
const handleInteractionChange = useCallback5(
|
|
867
910
|
(index, newInteractionValue) => {
|
|
@@ -929,6 +972,7 @@ function InteractionsTabContent({ elementId }) {
|
|
|
929
972
|
{
|
|
930
973
|
onCreateInteraction: () => {
|
|
931
974
|
firstInteractionState[1](true);
|
|
975
|
+
trackInteractionCreated(elementId, createDefaultInteractionItem());
|
|
932
976
|
}
|
|
933
977
|
}
|
|
934
978
|
));
|
|
@@ -1062,7 +1106,7 @@ var documentElementsInteractionsProvider = createInteractionsProvider({
|
|
|
1062
1106
|
import {
|
|
1063
1107
|
getContainer,
|
|
1064
1108
|
getElementInteractions as getElementInteractions3,
|
|
1065
|
-
getElementLabel,
|
|
1109
|
+
getElementLabel as getElementLabel2,
|
|
1066
1110
|
getWidgetsCache,
|
|
1067
1111
|
updateElementInteractions as updateElementInteractions2
|
|
1068
1112
|
} from "@elementor/editor-elements";
|
|
@@ -1091,7 +1135,7 @@ function isAtomicContainer(container) {
|
|
|
1091
1135
|
return Boolean(elementConfig?.atomic_props_schema);
|
|
1092
1136
|
}
|
|
1093
1137
|
function getTitleForContainers(containers) {
|
|
1094
|
-
return containers.length > 1 ? __6("Elements", "elementor") :
|
|
1138
|
+
return containers.length > 1 ? __6("Elements", "elementor") : getElementLabel2(containers[0].id);
|
|
1095
1139
|
}
|
|
1096
1140
|
function normalizeClipboardInteractions(raw) {
|
|
1097
1141
|
if (!raw) {
|