@elementor/editor-interactions 4.0.0-660 → 4.0.0-662
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.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +78 -55
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
- package/src/components/interactions-tab.tsx +1 -1
- package/src/contexts/interactions-context.tsx +2 -1
- package/src/hooks/use-element-interactions.ts +22 -0
- package/src/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -26,8 +26,7 @@ var EmptyState = ({ onCreateInteraction }) => {
|
|
|
26
26
|
|
|
27
27
|
// src/components/interactions-tab.tsx
|
|
28
28
|
import * as React11 from "react";
|
|
29
|
-
import { useCallback as useCallback6, useState as
|
|
30
|
-
import { useElementInteractions as useElementInteractions2 } from "@elementor/editor-elements";
|
|
29
|
+
import { useCallback as useCallback6, useState as useState4 } from "react";
|
|
31
30
|
import { SessionStorageProvider } from "@elementor/session";
|
|
32
31
|
import { Stack as Stack3 } from "@elementor/ui";
|
|
33
32
|
|
|
@@ -36,9 +35,30 @@ import * as React2 from "react";
|
|
|
36
35
|
import { createContext, useContext, useEffect } from "react";
|
|
37
36
|
import {
|
|
38
37
|
playElementInteractions,
|
|
39
|
-
updateElementInteractions
|
|
40
|
-
useElementInteractions
|
|
38
|
+
updateElementInteractions
|
|
41
39
|
} from "@elementor/editor-elements";
|
|
40
|
+
|
|
41
|
+
// src/hooks/use-element-interactions.ts
|
|
42
|
+
import { useState } from "react";
|
|
43
|
+
import { getElementInteractions } from "@elementor/editor-elements";
|
|
44
|
+
import { __privateUseListenTo as useListenTo, windowEvent } from "@elementor/editor-v1-adapters";
|
|
45
|
+
var useElementInteractions = (elementId) => {
|
|
46
|
+
const [interactions, setInteractions] = useState(() => {
|
|
47
|
+
const initial = getElementInteractions(elementId);
|
|
48
|
+
return initial ?? { version: 1, items: [] };
|
|
49
|
+
});
|
|
50
|
+
useListenTo(
|
|
51
|
+
windowEvent("elementor/element/update_interactions"),
|
|
52
|
+
() => {
|
|
53
|
+
const newInteractions = getElementInteractions(elementId);
|
|
54
|
+
setInteractions(newInteractions ?? { version: 1, items: [] });
|
|
55
|
+
},
|
|
56
|
+
[elementId]
|
|
57
|
+
);
|
|
58
|
+
return interactions;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// src/contexts/interactions-context.tsx
|
|
42
62
|
var InteractionsContext = createContext(null);
|
|
43
63
|
var DEFAULT_INTERACTIONS = {
|
|
44
64
|
version: 1,
|
|
@@ -77,10 +97,10 @@ var useInteractionsContext = () => {
|
|
|
77
97
|
|
|
78
98
|
// src/contexts/popup-state-context.tsx
|
|
79
99
|
import * as React3 from "react";
|
|
80
|
-
import { createContext as createContext2, useCallback, useContext as useContext2, useState } from "react";
|
|
100
|
+
import { createContext as createContext2, useCallback, useContext as useContext2, useState as useState2 } from "react";
|
|
81
101
|
var PopupStateContext = createContext2(void 0);
|
|
82
102
|
var PopupStateProvider = ({ children }) => {
|
|
83
|
-
const [openByDefault, setOpenByDefault] =
|
|
103
|
+
const [openByDefault, setOpenByDefault] = useState2(false);
|
|
84
104
|
const triggerDefaultOpen = useCallback(() => {
|
|
85
105
|
setOpenByDefault(true);
|
|
86
106
|
}, []);
|
|
@@ -701,7 +721,7 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
701
721
|
|
|
702
722
|
// src/components/interaction-settings.tsx
|
|
703
723
|
import * as React8 from "react";
|
|
704
|
-
import { useCallback as useCallback3, useMemo as useMemo2, useState as
|
|
724
|
+
import { useCallback as useCallback3, useMemo as useMemo2, useState as useState3 } from "react";
|
|
705
725
|
import { ControlFormLabel as ControlFormLabel2, PopoverContent as PopoverContent2 } from "@elementor/editor-controls";
|
|
706
726
|
import { useBreakpoints } from "@elementor/editor-responsive";
|
|
707
727
|
import { Autocomplete, Chip, Grid as Grid3, Stack as Stack2, TextField } from "@elementor/ui";
|
|
@@ -713,7 +733,7 @@ var InteractionSettings = ({ interaction, onChange }) => {
|
|
|
713
733
|
() => breakpoints.map((breakpoint) => ({ label: breakpoint.label, value: String(breakpoint.id) })),
|
|
714
734
|
[breakpoints]
|
|
715
735
|
);
|
|
716
|
-
const [selectedBreakpoints, setSelectedBreakpoints] =
|
|
736
|
+
const [selectedBreakpoints, setSelectedBreakpoints] = useState3(() => {
|
|
717
737
|
const excluded = extractExcludedBreakpoints(interaction.breakpoints).filter((excludedBreakpoint) => {
|
|
718
738
|
return availableBreakpoints.some(({ value }) => value === excludedBreakpoint);
|
|
719
739
|
});
|
|
@@ -901,8 +921,8 @@ var InteractionsTab = ({ elementId }) => {
|
|
|
901
921
|
return /* @__PURE__ */ React11.createElement(PopupStateProvider, null, /* @__PURE__ */ React11.createElement(InteractionsTabContent, { elementId }));
|
|
902
922
|
};
|
|
903
923
|
function InteractionsTabContent({ elementId }) {
|
|
904
|
-
const existingInteractions =
|
|
905
|
-
const firstInteractionState =
|
|
924
|
+
const existingInteractions = useElementInteractions(elementId);
|
|
925
|
+
const firstInteractionState = useState4(false);
|
|
906
926
|
const hasInteractions = existingInteractions?.items?.length || firstInteractionState[0];
|
|
907
927
|
return /* @__PURE__ */ React11.createElement(SessionStorageProvider, { prefix: elementId }, hasInteractions ? /* @__PURE__ */ React11.createElement(InteractionsProvider, { elementId }, /* @__PURE__ */ React11.createElement(InteractionsContent, { firstInteractionState })) : /* @__PURE__ */ React11.createElement(
|
|
908
928
|
EmptyState,
|
|
@@ -999,8 +1019,8 @@ function createInteractionsProvider({
|
|
|
999
1019
|
}
|
|
1000
1020
|
|
|
1001
1021
|
// src/providers/document-elements-interactions-provider.ts
|
|
1002
|
-
import { getCurrentDocumentId, getElementInteractions, getElements } from "@elementor/editor-elements";
|
|
1003
|
-
import { __privateListenTo as listenTo, windowEvent } from "@elementor/editor-v1-adapters";
|
|
1022
|
+
import { getCurrentDocumentId, getElementInteractions as getElementInteractions2, getElements } from "@elementor/editor-elements";
|
|
1023
|
+
import { __privateListenTo as listenTo, windowEvent as windowEvent2 } from "@elementor/editor-v1-adapters";
|
|
1004
1024
|
var ELEMENTS_INTERACTIONS_PROVIDER_KEY_PREFIX = "document-elements-interactions-";
|
|
1005
1025
|
var documentElementsInteractionsProvider = createInteractionsProvider({
|
|
1006
1026
|
key: () => {
|
|
@@ -1014,20 +1034,20 @@ var documentElementsInteractionsProvider = createInteractionsProvider({
|
|
|
1014
1034
|
},
|
|
1015
1035
|
priority: 50,
|
|
1016
1036
|
subscribe: (cb) => {
|
|
1017
|
-
return listenTo([
|
|
1037
|
+
return listenTo([windowEvent2("elementor/element/update_interactions")], () => cb());
|
|
1018
1038
|
},
|
|
1019
1039
|
actions: {
|
|
1020
1040
|
all: () => {
|
|
1021
1041
|
const elements = getElements();
|
|
1022
1042
|
const filtered = elements.filter((element) => {
|
|
1023
|
-
const interactions =
|
|
1043
|
+
const interactions = getElementInteractions2(element.id);
|
|
1024
1044
|
if (!interactions) {
|
|
1025
1045
|
return false;
|
|
1026
1046
|
}
|
|
1027
1047
|
return interactions?.items?.length > 0;
|
|
1028
1048
|
});
|
|
1029
1049
|
return filtered.map((element) => {
|
|
1030
|
-
const interactions =
|
|
1050
|
+
const interactions = getElementInteractions2(element.id);
|
|
1031
1051
|
return {
|
|
1032
1052
|
elementId: element.id,
|
|
1033
1053
|
dataId: element.id,
|
|
@@ -1090,13 +1110,13 @@ import { __ as __8 } from "@wordpress/i18n";
|
|
|
1090
1110
|
|
|
1091
1111
|
// src/ui/interactions-promotion-chip.tsx
|
|
1092
1112
|
import * as React13 from "react";
|
|
1093
|
-
import { forwardRef, useImperativeHandle, useState as
|
|
1113
|
+
import { forwardRef, useImperativeHandle, useState as useState5 } from "react";
|
|
1094
1114
|
import { PromotionChip, PromotionPopover, useCanvasClickHandler } from "@elementor/editor-ui";
|
|
1095
1115
|
import { Box as Box3 } from "@elementor/ui";
|
|
1096
1116
|
import { __ as __7 } from "@wordpress/i18n";
|
|
1097
1117
|
var InteractionsPromotionChip = forwardRef(
|
|
1098
1118
|
({ content, upgradeUrl, anchorRef }, ref) => {
|
|
1099
|
-
const [isOpen, setIsOpen] =
|
|
1119
|
+
const [isOpen, setIsOpen] = useState5(false);
|
|
1100
1120
|
useCanvasClickHandler(isOpen, () => setIsOpen(false));
|
|
1101
1121
|
const toggle = () => setIsOpen((prev) => !prev);
|
|
1102
1122
|
useImperativeHandle(ref, () => ({ toggle }), []);
|
|
@@ -1760,6 +1780,7 @@ export {
|
|
|
1760
1780
|
isTempId,
|
|
1761
1781
|
parseSizeValue,
|
|
1762
1782
|
registerInteractionsControl,
|
|
1763
|
-
resolveDirection
|
|
1783
|
+
resolveDirection,
|
|
1784
|
+
useElementInteractions
|
|
1764
1785
|
};
|
|
1765
1786
|
//# sourceMappingURL=index.mjs.map
|