@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.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { RefObject, ComponentType } from 'react';
|
|
3
3
|
import { Unit } from '@elementor/editor-controls';
|
|
4
|
-
import { ElementInteractions, InteractionItemPropValue, AnimationPresetPropValue, BooleanPropValue, ConfigPropValue, ExcludedBreakpointsPropValue, InteractionBreakpointsPropValue, NumberPropValue, StringPropValue, TimingConfigPropValue } from '@elementor/editor-elements';
|
|
4
|
+
import { ElementInteractions, InteractionItemPropValue, AnimationPresetPropValue, BooleanPropValue, ConfigPropValue, ExcludedBreakpointsPropValue, InteractionBreakpointsPropValue, NumberPropValue, StringPropValue, TimingConfigPropValue, ElementID } from '@elementor/editor-elements';
|
|
5
5
|
export { InteractionItemPropValue } from '@elementor/editor-elements';
|
|
6
6
|
import { PropValue, SizePropValue } from '@elementor/editor-props';
|
|
7
7
|
|
|
@@ -205,4 +205,6 @@ type SizeUnit = SizeValue['unit'];
|
|
|
205
205
|
declare const parseSizeValue: (value: SizeStringValue, allowedUnits: SizeUnit[], defaultValue?: SizeStringValue, defaultUnit?: Unit) => SizeValue;
|
|
206
206
|
declare const formatSizeValue: ({ size, unit }: SizeValue) => SizeStringValue;
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
declare const useElementInteractions: (elementId: ElementID) => ElementInteractions;
|
|
209
|
+
|
|
210
|
+
export { BASE_EASINGS, BASE_EFFECTS, BASE_REPLAY, BASE_TRIGGERS, type CreateInteractionsProviderOptions, EASING_OPTIONS, EFFECT_OPTIONS, ELEMENTS_INTERACTIONS_PROVIDER_KEY_PREFIX, EmptyState, type FieldProps, InteractionsTab, REPLAY_OPTIONS, type ReplayFieldProps, TRIGGER_OPTIONS, buildDisplayLabel, convertTimeUnit, createAnimationPreset, createBoolean, createConfig, createDefaultInteractionItem, createDefaultInteractions, createExcludedBreakpoints, createInteractionBreakpoints, createInteractionItem, createInteractionsProvider, createNumber, createString, createTimingConfig, extractBoolean, extractExcludedBreakpoints, extractSize, extractString, formatSizeValue, generateTempInteractionId, getInteractionsConfig, init, interactionsRepository, isTempId, parseSizeValue, registerInteractionsControl, resolveDirection, useElementInteractions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { RefObject, ComponentType } from 'react';
|
|
3
3
|
import { Unit } from '@elementor/editor-controls';
|
|
4
|
-
import { ElementInteractions, InteractionItemPropValue, AnimationPresetPropValue, BooleanPropValue, ConfigPropValue, ExcludedBreakpointsPropValue, InteractionBreakpointsPropValue, NumberPropValue, StringPropValue, TimingConfigPropValue } from '@elementor/editor-elements';
|
|
4
|
+
import { ElementInteractions, InteractionItemPropValue, AnimationPresetPropValue, BooleanPropValue, ConfigPropValue, ExcludedBreakpointsPropValue, InteractionBreakpointsPropValue, NumberPropValue, StringPropValue, TimingConfigPropValue, ElementID } from '@elementor/editor-elements';
|
|
5
5
|
export { InteractionItemPropValue } from '@elementor/editor-elements';
|
|
6
6
|
import { PropValue, SizePropValue } from '@elementor/editor-props';
|
|
7
7
|
|
|
@@ -205,4 +205,6 @@ type SizeUnit = SizeValue['unit'];
|
|
|
205
205
|
declare const parseSizeValue: (value: SizeStringValue, allowedUnits: SizeUnit[], defaultValue?: SizeStringValue, defaultUnit?: Unit) => SizeValue;
|
|
206
206
|
declare const formatSizeValue: ({ size, unit }: SizeValue) => SizeStringValue;
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
declare const useElementInteractions: (elementId: ElementID) => ElementInteractions;
|
|
209
|
+
|
|
210
|
+
export { BASE_EASINGS, BASE_EFFECTS, BASE_REPLAY, BASE_TRIGGERS, type CreateInteractionsProviderOptions, EASING_OPTIONS, EFFECT_OPTIONS, ELEMENTS_INTERACTIONS_PROVIDER_KEY_PREFIX, EmptyState, type FieldProps, InteractionsTab, REPLAY_OPTIONS, type ReplayFieldProps, TRIGGER_OPTIONS, buildDisplayLabel, convertTimeUnit, createAnimationPreset, createBoolean, createConfig, createDefaultInteractionItem, createDefaultInteractions, createExcludedBreakpoints, createInteractionBreakpoints, createInteractionItem, createInteractionsProvider, createNumber, createString, createTimingConfig, extractBoolean, extractExcludedBreakpoints, extractSize, extractString, formatSizeValue, generateTempInteractionId, getInteractionsConfig, init, interactionsRepository, isTempId, parseSizeValue, registerInteractionsControl, resolveDirection, useElementInteractions };
|
package/dist/index.js
CHANGED
|
@@ -67,7 +67,8 @@ __export(index_exports, {
|
|
|
67
67
|
isTempId: () => isTempId,
|
|
68
68
|
parseSizeValue: () => parseSizeValue,
|
|
69
69
|
registerInteractionsControl: () => registerInteractionsControl,
|
|
70
|
-
resolveDirection: () => resolveDirection
|
|
70
|
+
resolveDirection: () => resolveDirection,
|
|
71
|
+
useElementInteractions: () => useElementInteractions
|
|
71
72
|
});
|
|
72
73
|
module.exports = __toCommonJS(index_exports);
|
|
73
74
|
|
|
@@ -99,35 +100,56 @@ var EmptyState = ({ onCreateInteraction }) => {
|
|
|
99
100
|
|
|
100
101
|
// src/components/interactions-tab.tsx
|
|
101
102
|
var React11 = __toESM(require("react"));
|
|
102
|
-
var
|
|
103
|
-
var import_editor_elements2 = require("@elementor/editor-elements");
|
|
103
|
+
var import_react10 = require("react");
|
|
104
104
|
var import_session = require("@elementor/session");
|
|
105
105
|
var import_ui7 = require("@elementor/ui");
|
|
106
106
|
|
|
107
107
|
// src/contexts/interactions-context.tsx
|
|
108
108
|
var React2 = __toESM(require("react"));
|
|
109
|
+
var import_react2 = require("react");
|
|
110
|
+
var import_editor_elements2 = require("@elementor/editor-elements");
|
|
111
|
+
|
|
112
|
+
// src/hooks/use-element-interactions.ts
|
|
109
113
|
var import_react = require("react");
|
|
110
114
|
var import_editor_elements = require("@elementor/editor-elements");
|
|
111
|
-
var
|
|
115
|
+
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
116
|
+
var useElementInteractions = (elementId) => {
|
|
117
|
+
const [interactions, setInteractions] = (0, import_react.useState)(() => {
|
|
118
|
+
const initial = (0, import_editor_elements.getElementInteractions)(elementId);
|
|
119
|
+
return initial ?? { version: 1, items: [] };
|
|
120
|
+
});
|
|
121
|
+
(0, import_editor_v1_adapters.__privateUseListenTo)(
|
|
122
|
+
(0, import_editor_v1_adapters.windowEvent)("elementor/element/update_interactions"),
|
|
123
|
+
() => {
|
|
124
|
+
const newInteractions = (0, import_editor_elements.getElementInteractions)(elementId);
|
|
125
|
+
setInteractions(newInteractions ?? { version: 1, items: [] });
|
|
126
|
+
},
|
|
127
|
+
[elementId]
|
|
128
|
+
);
|
|
129
|
+
return interactions;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// src/contexts/interactions-context.tsx
|
|
133
|
+
var InteractionsContext = (0, import_react2.createContext)(null);
|
|
112
134
|
var DEFAULT_INTERACTIONS = {
|
|
113
135
|
version: 1,
|
|
114
136
|
items: []
|
|
115
137
|
};
|
|
116
138
|
var InteractionsProvider = ({ children, elementId }) => {
|
|
117
|
-
const rawInteractions =
|
|
118
|
-
(0,
|
|
139
|
+
const rawInteractions = useElementInteractions(elementId);
|
|
140
|
+
(0, import_react2.useEffect)(() => {
|
|
119
141
|
window.dispatchEvent(new CustomEvent("elementor/element/update_interactions"));
|
|
120
142
|
}, []);
|
|
121
143
|
const interactions = rawInteractions ?? DEFAULT_INTERACTIONS;
|
|
122
144
|
const setInteractions = (value) => {
|
|
123
145
|
const normalizedValue = value && value.items?.length === 0 ? void 0 : value;
|
|
124
|
-
(0,
|
|
146
|
+
(0, import_editor_elements2.updateElementInteractions)({
|
|
125
147
|
elementId,
|
|
126
148
|
interactions: normalizedValue
|
|
127
149
|
});
|
|
128
150
|
};
|
|
129
151
|
const playInteractions = (interactionId) => {
|
|
130
|
-
(0,
|
|
152
|
+
(0, import_editor_elements2.playElementInteractions)(elementId, interactionId);
|
|
131
153
|
};
|
|
132
154
|
const contextValue = {
|
|
133
155
|
interactions,
|
|
@@ -137,7 +159,7 @@ var InteractionsProvider = ({ children, elementId }) => {
|
|
|
137
159
|
return /* @__PURE__ */ React2.createElement(InteractionsContext.Provider, { value: contextValue }, children);
|
|
138
160
|
};
|
|
139
161
|
var useInteractionsContext = () => {
|
|
140
|
-
const context = (0,
|
|
162
|
+
const context = (0, import_react2.useContext)(InteractionsContext);
|
|
141
163
|
if (!context) {
|
|
142
164
|
throw new Error("useInteractionsContext must be used within InteractionsProvider");
|
|
143
165
|
}
|
|
@@ -146,14 +168,14 @@ var useInteractionsContext = () => {
|
|
|
146
168
|
|
|
147
169
|
// src/contexts/popup-state-context.tsx
|
|
148
170
|
var React3 = __toESM(require("react"));
|
|
149
|
-
var
|
|
150
|
-
var PopupStateContext = (0,
|
|
171
|
+
var import_react3 = require("react");
|
|
172
|
+
var PopupStateContext = (0, import_react3.createContext)(void 0);
|
|
151
173
|
var PopupStateProvider = ({ children }) => {
|
|
152
|
-
const [openByDefault, setOpenByDefault] = (0,
|
|
153
|
-
const triggerDefaultOpen = (0,
|
|
174
|
+
const [openByDefault, setOpenByDefault] = (0, import_react3.useState)(false);
|
|
175
|
+
const triggerDefaultOpen = (0, import_react3.useCallback)(() => {
|
|
154
176
|
setOpenByDefault(true);
|
|
155
177
|
}, []);
|
|
156
|
-
const resetDefaultOpen = (0,
|
|
178
|
+
const resetDefaultOpen = (0, import_react3.useCallback)(() => {
|
|
157
179
|
setOpenByDefault(false);
|
|
158
180
|
}, []);
|
|
159
181
|
return /* @__PURE__ */ React3.createElement(PopupStateContext.Provider, { value: { openByDefault, triggerDefaultOpen, resetDefaultOpen } }, children);
|
|
@@ -161,7 +183,7 @@ var PopupStateProvider = ({ children }) => {
|
|
|
161
183
|
|
|
162
184
|
// src/components/interactions-list.tsx
|
|
163
185
|
var React10 = __toESM(require("react"));
|
|
164
|
-
var
|
|
186
|
+
var import_react9 = require("react");
|
|
165
187
|
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
166
188
|
var import_icons2 = require("@elementor/icons");
|
|
167
189
|
var import_ui6 = require("@elementor/ui");
|
|
@@ -169,8 +191,8 @@ var import_i18n5 = require("@wordpress/i18n");
|
|
|
169
191
|
|
|
170
192
|
// src/contexts/interactions-item-context.tsx
|
|
171
193
|
var React4 = __toESM(require("react"));
|
|
172
|
-
var
|
|
173
|
-
var InteractionItemContext = (0,
|
|
194
|
+
var import_react4 = require("react");
|
|
195
|
+
var InteractionItemContext = (0, import_react4.createContext)(null);
|
|
174
196
|
function InteractionItemContextProvider({
|
|
175
197
|
value,
|
|
176
198
|
children
|
|
@@ -178,7 +200,7 @@ function InteractionItemContextProvider({
|
|
|
178
200
|
return /* @__PURE__ */ React4.createElement(InteractionItemContext.Provider, { value }, children);
|
|
179
201
|
}
|
|
180
202
|
function useInteractionItemContext() {
|
|
181
|
-
const context = (0,
|
|
203
|
+
const context = (0, import_react4.useContext)(InteractionItemContext);
|
|
182
204
|
if (!context) {
|
|
183
205
|
throw new Error("useInteractionItemContext must be used within InteractionItemContextProvider");
|
|
184
206
|
}
|
|
@@ -440,13 +462,13 @@ var buildDisplayLabel = (item) => {
|
|
|
440
462
|
|
|
441
463
|
// src/components/interactions-list-item.tsx
|
|
442
464
|
var React9 = __toESM(require("react"));
|
|
443
|
-
var
|
|
465
|
+
var import_react8 = require("react");
|
|
444
466
|
var import_ui5 = require("@elementor/ui");
|
|
445
467
|
var import_i18n4 = require("@wordpress/i18n");
|
|
446
468
|
|
|
447
469
|
// src/components/interaction-details.tsx
|
|
448
470
|
var React7 = __toESM(require("react"));
|
|
449
|
-
var
|
|
471
|
+
var import_react6 = require("react");
|
|
450
472
|
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
451
473
|
var import_ui3 = require("@elementor/ui");
|
|
452
474
|
var import_i18n2 = require("@wordpress/i18n");
|
|
@@ -480,7 +502,7 @@ var resolveDirection = (hasDirection, newEffect, newDirection, currentDirection,
|
|
|
480
502
|
|
|
481
503
|
// src/components/controls/time-frame-indicator.tsx
|
|
482
504
|
var React5 = __toESM(require("react"));
|
|
483
|
-
var
|
|
505
|
+
var import_react5 = require("react");
|
|
484
506
|
var import_editor_controls = require("@elementor/editor-controls");
|
|
485
507
|
|
|
486
508
|
// src/utils/time-conversion.ts
|
|
@@ -499,8 +521,8 @@ function TimeFrameIndicator({
|
|
|
499
521
|
defaultValue
|
|
500
522
|
}) {
|
|
501
523
|
const sizeValue = parseSizeValue(value, TIME_UNITS, defaultValue, DEFAULT_TIME_UNIT);
|
|
502
|
-
const prevUnitRef = (0,
|
|
503
|
-
const setValue = (0,
|
|
524
|
+
const prevUnitRef = (0, import_react5.useRef)(sizeValue.unit);
|
|
525
|
+
const setValue = (0, import_react5.useCallback)(
|
|
504
526
|
(size) => {
|
|
505
527
|
const unitChanged = prevUnitRef.current !== size.unit;
|
|
506
528
|
if (unitChanged) {
|
|
@@ -589,7 +611,7 @@ function normalizeTimesValue(value, fallback) {
|
|
|
589
611
|
return Math.max(1, Math.floor(numericValue));
|
|
590
612
|
}
|
|
591
613
|
function useControlComponent(controlName, isVisible = true) {
|
|
592
|
-
return (0,
|
|
614
|
+
return (0, import_react6.useMemo)(() => {
|
|
593
615
|
if (!isVisible) {
|
|
594
616
|
return null;
|
|
595
617
|
}
|
|
@@ -655,7 +677,7 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
655
677
|
controlVisibilityConfig.times(interactionValues)
|
|
656
678
|
);
|
|
657
679
|
const EasingControl = useControlComponent("easing");
|
|
658
|
-
const containerRef = (0,
|
|
680
|
+
const containerRef = (0, import_react6.useRef)(null);
|
|
659
681
|
const updateInteraction = (updates) => {
|
|
660
682
|
const resolvedDirectionValue = resolveDirection(
|
|
661
683
|
"direction" in updates,
|
|
@@ -770,7 +792,7 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
770
792
|
|
|
771
793
|
// src/components/interaction-settings.tsx
|
|
772
794
|
var React8 = __toESM(require("react"));
|
|
773
|
-
var
|
|
795
|
+
var import_react7 = require("react");
|
|
774
796
|
var import_editor_controls4 = require("@elementor/editor-controls");
|
|
775
797
|
var import_editor_responsive = require("@elementor/editor-responsive");
|
|
776
798
|
var import_ui4 = require("@elementor/ui");
|
|
@@ -778,11 +800,11 @@ var import_i18n3 = require("@wordpress/i18n");
|
|
|
778
800
|
var SIZE = "tiny";
|
|
779
801
|
var InteractionSettings = ({ interaction, onChange }) => {
|
|
780
802
|
const breakpoints = (0, import_editor_responsive.useBreakpoints)();
|
|
781
|
-
const availableBreakpoints = (0,
|
|
803
|
+
const availableBreakpoints = (0, import_react7.useMemo)(
|
|
782
804
|
() => breakpoints.map((breakpoint) => ({ label: breakpoint.label, value: String(breakpoint.id) })),
|
|
783
805
|
[breakpoints]
|
|
784
806
|
);
|
|
785
|
-
const [selectedBreakpoints, setSelectedBreakpoints] = (0,
|
|
807
|
+
const [selectedBreakpoints, setSelectedBreakpoints] = (0, import_react7.useState)(() => {
|
|
786
808
|
const excluded = extractExcludedBreakpoints(interaction.breakpoints).filter((excludedBreakpoint) => {
|
|
787
809
|
return availableBreakpoints.some(({ value }) => value === excludedBreakpoint);
|
|
788
810
|
});
|
|
@@ -790,7 +812,7 @@ var InteractionSettings = ({ interaction, onChange }) => {
|
|
|
790
812
|
return !excluded.includes(value);
|
|
791
813
|
});
|
|
792
814
|
});
|
|
793
|
-
const handleBreakpointChange = (0,
|
|
815
|
+
const handleBreakpointChange = (0, import_react7.useCallback)(
|
|
794
816
|
(_, newValue) => {
|
|
795
817
|
setSelectedBreakpoints(newValue);
|
|
796
818
|
const selectedValues = newValue.map((option) => option.value);
|
|
@@ -834,13 +856,13 @@ var InteractionsListItem = ({
|
|
|
834
856
|
}) => {
|
|
835
857
|
const { getTabsProps, getTabProps, getTabPanelProps } = (0, import_ui5.useTabs)("details");
|
|
836
858
|
const context = useInteractionItemContext();
|
|
837
|
-
const handleChange = (0,
|
|
859
|
+
const handleChange = (0, import_react8.useCallback)(
|
|
838
860
|
(newInteractionValue) => {
|
|
839
861
|
context?.onInteractionChange(index, newInteractionValue);
|
|
840
862
|
},
|
|
841
863
|
[context, index]
|
|
842
864
|
);
|
|
843
|
-
const handlePlayInteraction = (0,
|
|
865
|
+
const handlePlayInteraction = (0, import_react8.useCallback)(
|
|
844
866
|
(interactionId2) => {
|
|
845
867
|
context?.onPlayInteraction(interactionId2);
|
|
846
868
|
},
|
|
@@ -879,14 +901,14 @@ var InteractionsListItem = ({
|
|
|
879
901
|
var MAX_NUMBER_OF_INTERACTIONS = 5;
|
|
880
902
|
function InteractionsList(props) {
|
|
881
903
|
const { interactions, onSelectInteractions, onPlayInteraction, triggerCreateOnShowEmpty } = props;
|
|
882
|
-
const hasInitializedRef = (0,
|
|
883
|
-
const handleUpdateInteractions = (0,
|
|
904
|
+
const hasInitializedRef = (0, import_react9.useRef)(false);
|
|
905
|
+
const handleUpdateInteractions = (0, import_react9.useCallback)(
|
|
884
906
|
(newInteractions) => {
|
|
885
907
|
onSelectInteractions(newInteractions);
|
|
886
908
|
},
|
|
887
909
|
[onSelectInteractions]
|
|
888
910
|
);
|
|
889
|
-
(0,
|
|
911
|
+
(0, import_react9.useEffect)(() => {
|
|
890
912
|
if (triggerCreateOnShowEmpty && !hasInitializedRef.current && (!interactions.items || interactions.items?.length === 0)) {
|
|
891
913
|
hasInitializedRef.current = true;
|
|
892
914
|
const newState = {
|
|
@@ -896,14 +918,14 @@ function InteractionsList(props) {
|
|
|
896
918
|
handleUpdateInteractions(newState);
|
|
897
919
|
}
|
|
898
920
|
}, [triggerCreateOnShowEmpty, interactions.items, handleUpdateInteractions]);
|
|
899
|
-
const isMaxNumberOfInteractionsReached = (0,
|
|
921
|
+
const isMaxNumberOfInteractionsReached = (0, import_react9.useMemo)(() => {
|
|
900
922
|
return interactions.items?.length >= MAX_NUMBER_OF_INTERACTIONS;
|
|
901
923
|
}, [interactions.items?.length]);
|
|
902
924
|
const infotipContent = isMaxNumberOfInteractionsReached ? /* @__PURE__ */ React10.createElement(import_ui6.Alert, { color: "secondary", icon: /* @__PURE__ */ React10.createElement(import_icons2.InfoCircleFilledIcon, null), size: "small" }, /* @__PURE__ */ React10.createElement(import_ui6.AlertTitle, null, (0, import_i18n5.__)("Interactions", "elementor")), /* @__PURE__ */ React10.createElement(import_ui6.Box, { component: "span" }, (0, import_i18n5.__)(
|
|
903
925
|
"You've reached the limit of 5 interactions for this element. Please remove an interaction before creating a new one.",
|
|
904
926
|
"elementor"
|
|
905
927
|
))) : void 0;
|
|
906
|
-
const handleRepeaterChange = (0,
|
|
928
|
+
const handleRepeaterChange = (0, import_react9.useCallback)(
|
|
907
929
|
(newItems) => {
|
|
908
930
|
handleUpdateInteractions({
|
|
909
931
|
...interactions,
|
|
@@ -912,7 +934,7 @@ function InteractionsList(props) {
|
|
|
912
934
|
},
|
|
913
935
|
[interactions, handleUpdateInteractions]
|
|
914
936
|
);
|
|
915
|
-
const handleInteractionChange = (0,
|
|
937
|
+
const handleInteractionChange = (0, import_react9.useCallback)(
|
|
916
938
|
(index, newInteractionValue) => {
|
|
917
939
|
const newItems = structuredClone(interactions.items);
|
|
918
940
|
newItems[index] = {
|
|
@@ -926,7 +948,7 @@ function InteractionsList(props) {
|
|
|
926
948
|
},
|
|
927
949
|
[interactions, handleUpdateInteractions]
|
|
928
950
|
);
|
|
929
|
-
const contextValue = (0,
|
|
951
|
+
const contextValue = (0, import_react9.useMemo)(
|
|
930
952
|
() => ({
|
|
931
953
|
onInteractionChange: handleInteractionChange,
|
|
932
954
|
onPlayInteraction
|
|
@@ -970,8 +992,8 @@ var InteractionsTab = ({ elementId }) => {
|
|
|
970
992
|
return /* @__PURE__ */ React11.createElement(PopupStateProvider, null, /* @__PURE__ */ React11.createElement(InteractionsTabContent, { elementId }));
|
|
971
993
|
};
|
|
972
994
|
function InteractionsTabContent({ elementId }) {
|
|
973
|
-
const existingInteractions =
|
|
974
|
-
const firstInteractionState = (0,
|
|
995
|
+
const existingInteractions = useElementInteractions(elementId);
|
|
996
|
+
const firstInteractionState = (0, import_react10.useState)(false);
|
|
975
997
|
const hasInteractions = existingInteractions?.items?.length || firstInteractionState[0];
|
|
976
998
|
return /* @__PURE__ */ React11.createElement(import_session.SessionStorageProvider, { prefix: elementId }, hasInteractions ? /* @__PURE__ */ React11.createElement(InteractionsProvider, { elementId }, /* @__PURE__ */ React11.createElement(InteractionsContent, { firstInteractionState })) : /* @__PURE__ */ React11.createElement(
|
|
977
999
|
EmptyState,
|
|
@@ -986,7 +1008,7 @@ function InteractionsContent({
|
|
|
986
1008
|
firstInteractionState
|
|
987
1009
|
}) {
|
|
988
1010
|
const { interactions, setInteractions, playInteractions } = useInteractionsContext();
|
|
989
|
-
const applyInteraction = (0,
|
|
1011
|
+
const applyInteraction = (0, import_react10.useCallback)(
|
|
990
1012
|
(newInteractions) => {
|
|
991
1013
|
firstInteractionState[1](false);
|
|
992
1014
|
if (!newInteractions) {
|
|
@@ -1069,7 +1091,7 @@ function createInteractionsProvider({
|
|
|
1069
1091
|
|
|
1070
1092
|
// src/providers/document-elements-interactions-provider.ts
|
|
1071
1093
|
var import_editor_elements3 = require("@elementor/editor-elements");
|
|
1072
|
-
var
|
|
1094
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
1073
1095
|
var ELEMENTS_INTERACTIONS_PROVIDER_KEY_PREFIX = "document-elements-interactions-";
|
|
1074
1096
|
var documentElementsInteractionsProvider = createInteractionsProvider({
|
|
1075
1097
|
key: () => {
|
|
@@ -1083,7 +1105,7 @@ var documentElementsInteractionsProvider = createInteractionsProvider({
|
|
|
1083
1105
|
},
|
|
1084
1106
|
priority: 50,
|
|
1085
1107
|
subscribe: (cb) => {
|
|
1086
|
-
return (0,
|
|
1108
|
+
return (0, import_editor_v1_adapters2.__privateListenTo)([(0, import_editor_v1_adapters2.windowEvent)("elementor/element/update_interactions")], () => cb());
|
|
1087
1109
|
},
|
|
1088
1110
|
actions: {
|
|
1089
1111
|
all: () => {
|
|
@@ -1109,12 +1131,12 @@ var documentElementsInteractionsProvider = createInteractionsProvider({
|
|
|
1109
1131
|
|
|
1110
1132
|
// src/components/controls/direction.tsx
|
|
1111
1133
|
var React12 = __toESM(require("react"));
|
|
1112
|
-
var
|
|
1134
|
+
var import_react11 = require("react");
|
|
1113
1135
|
var import_editor_controls6 = require("@elementor/editor-controls");
|
|
1114
1136
|
var import_icons3 = require("@elementor/icons");
|
|
1115
1137
|
var import_i18n6 = require("@wordpress/i18n");
|
|
1116
1138
|
function Direction({ value, onChange, interactionType }) {
|
|
1117
|
-
const options = (0,
|
|
1139
|
+
const options = (0, import_react11.useMemo)(() => {
|
|
1118
1140
|
const isIn = interactionType === "in";
|
|
1119
1141
|
return [
|
|
1120
1142
|
{
|
|
@@ -1152,23 +1174,23 @@ var import_i18n9 = require("@wordpress/i18n");
|
|
|
1152
1174
|
|
|
1153
1175
|
// src/ui/promotion-select.tsx
|
|
1154
1176
|
var React14 = __toESM(require("react"));
|
|
1155
|
-
var
|
|
1177
|
+
var import_react13 = require("react");
|
|
1156
1178
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
1157
1179
|
var import_ui9 = require("@elementor/ui");
|
|
1158
1180
|
var import_i18n8 = require("@wordpress/i18n");
|
|
1159
1181
|
|
|
1160
1182
|
// src/ui/interactions-promotion-chip.tsx
|
|
1161
1183
|
var React13 = __toESM(require("react"));
|
|
1162
|
-
var
|
|
1184
|
+
var import_react12 = require("react");
|
|
1163
1185
|
var import_editor_ui = require("@elementor/editor-ui");
|
|
1164
1186
|
var import_ui8 = require("@elementor/ui");
|
|
1165
1187
|
var import_i18n7 = require("@wordpress/i18n");
|
|
1166
|
-
var InteractionsPromotionChip = (0,
|
|
1188
|
+
var InteractionsPromotionChip = (0, import_react12.forwardRef)(
|
|
1167
1189
|
({ content, upgradeUrl, anchorRef }, ref) => {
|
|
1168
|
-
const [isOpen, setIsOpen] = (0,
|
|
1190
|
+
const [isOpen, setIsOpen] = (0, import_react12.useState)(false);
|
|
1169
1191
|
(0, import_editor_ui.useCanvasClickHandler)(isOpen, () => setIsOpen(false));
|
|
1170
1192
|
const toggle = () => setIsOpen((prev) => !prev);
|
|
1171
|
-
(0,
|
|
1193
|
+
(0, import_react12.useImperativeHandle)(ref, () => ({ toggle }), []);
|
|
1172
1194
|
const handleToggle = (e) => {
|
|
1173
1195
|
e.stopPropagation();
|
|
1174
1196
|
toggle();
|
|
@@ -1212,8 +1234,8 @@ function PromotionSelect({
|
|
|
1212
1234
|
promotionContent,
|
|
1213
1235
|
upgradeUrl
|
|
1214
1236
|
}) {
|
|
1215
|
-
const promotionRef = (0,
|
|
1216
|
-
const anchorRef = (0,
|
|
1237
|
+
const promotionRef = (0, import_react13.useRef)(null);
|
|
1238
|
+
const anchorRef = (0, import_react13.useRef)(null);
|
|
1217
1239
|
return /* @__PURE__ */ React14.createElement(
|
|
1218
1240
|
import_ui9.Select,
|
|
1219
1241
|
{
|
|
@@ -1416,9 +1438,9 @@ function Trigger({ value, onChange }) {
|
|
|
1416
1438
|
|
|
1417
1439
|
// src/hooks/on-duplicate.ts
|
|
1418
1440
|
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
1419
|
-
var
|
|
1441
|
+
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
1420
1442
|
function initCleanInteractionIdsOnDuplicate() {
|
|
1421
|
-
(0,
|
|
1443
|
+
(0, import_editor_v1_adapters3.registerDataHook)("after", "document/elements/duplicate", (_args, result) => {
|
|
1422
1444
|
const containers = Array.isArray(result) ? result : [result];
|
|
1423
1445
|
containers.forEach((container) => {
|
|
1424
1446
|
cleanInteractionIdsRecursive(container.id);
|
|
@@ -1830,6 +1852,7 @@ function init() {
|
|
|
1830
1852
|
isTempId,
|
|
1831
1853
|
parseSizeValue,
|
|
1832
1854
|
registerInteractionsControl,
|
|
1833
|
-
resolveDirection
|
|
1855
|
+
resolveDirection,
|
|
1856
|
+
useElementInteractions
|
|
1834
1857
|
});
|
|
1835
1858
|
//# sourceMappingURL=index.js.map
|