@elementor/editor-interactions 4.0.0-636 → 4.0.0-638
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 +72 -4
- package/dist/index.d.ts +72 -4
- package/dist/index.js +98 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
- package/src/index.ts +24 -0
- package/src/mcp/tools/manage-element-interaction-tool.ts +27 -3
- package/src/types.ts +4 -1
- package/src/utils/get-interactions-config.ts +6 -3
- package/src/utils/prop-value-utils.ts +5 -3
package/dist/index.mjs
CHANGED
|
@@ -172,17 +172,42 @@ var createSizeValue = (size, unit) => {
|
|
|
172
172
|
return { size, unit };
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
+
// src/utils/get-interactions-config.ts
|
|
176
|
+
var DEFAULT_CONFIG = {
|
|
177
|
+
constants: {
|
|
178
|
+
defaultDuration: 600,
|
|
179
|
+
defaultDelay: 0,
|
|
180
|
+
slideDistance: 100,
|
|
181
|
+
scaleStart: 0,
|
|
182
|
+
defaultEasing: "easeIn",
|
|
183
|
+
relativeTo: "viewport",
|
|
184
|
+
end: 15,
|
|
185
|
+
start: 85
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
function getInteractionsConfig() {
|
|
189
|
+
return window.ElementorInteractionsConfig || DEFAULT_CONFIG;
|
|
190
|
+
}
|
|
191
|
+
|
|
175
192
|
// src/utils/temp-id-utils.ts
|
|
176
193
|
var TEMP_ID_PREFIX = "temp-";
|
|
194
|
+
var TEMP_ID_REGEX = /^temp-[a-z0-9]+$/i;
|
|
177
195
|
function generateTempInteractionId() {
|
|
178
196
|
return `${TEMP_ID_PREFIX}${Math.random().toString(36).substring(2, 11)}`;
|
|
179
197
|
}
|
|
198
|
+
function isTempId(id) {
|
|
199
|
+
return !!id && TEMP_ID_REGEX.test(id);
|
|
200
|
+
}
|
|
180
201
|
|
|
181
202
|
// src/utils/prop-value-utils.ts
|
|
182
203
|
var createString = (value) => ({
|
|
183
204
|
$$type: "string",
|
|
184
205
|
value
|
|
185
206
|
});
|
|
207
|
+
var createNumber = (value) => ({
|
|
208
|
+
$$type: "number",
|
|
209
|
+
value
|
|
210
|
+
});
|
|
186
211
|
var createTimingConfig = (duration, delay) => ({
|
|
187
212
|
$$type: "timing-config",
|
|
188
213
|
value: {
|
|
@@ -300,17 +325,22 @@ var createInteractionItem = ({
|
|
|
300
325
|
}
|
|
301
326
|
});
|
|
302
327
|
var createDefaultInteractionItem = () => {
|
|
328
|
+
const { constants } = getInteractionsConfig();
|
|
303
329
|
return createInteractionItem({
|
|
304
330
|
trigger: "load",
|
|
305
331
|
effect: "fade",
|
|
306
332
|
type: "in",
|
|
307
|
-
duration:
|
|
308
|
-
delay:
|
|
333
|
+
duration: constants.defaultDuration,
|
|
334
|
+
delay: constants.defaultDelay,
|
|
309
335
|
replay: false,
|
|
310
|
-
easing:
|
|
336
|
+
easing: constants.defaultEasing,
|
|
311
337
|
interactionId: generateTempInteractionId()
|
|
312
338
|
});
|
|
313
339
|
};
|
|
340
|
+
var createDefaultInteractions = () => ({
|
|
341
|
+
version: 1,
|
|
342
|
+
items: [createDefaultInteractionItem()]
|
|
343
|
+
});
|
|
314
344
|
var extractString = (prop, fallback = "") => {
|
|
315
345
|
return prop?.value ?? fallback;
|
|
316
346
|
};
|
|
@@ -875,20 +905,6 @@ function InteractionsContent({
|
|
|
875
905
|
));
|
|
876
906
|
}
|
|
877
907
|
|
|
878
|
-
// src/utils/get-interactions-config.ts
|
|
879
|
-
var DEFAULT_CONFIG = {
|
|
880
|
-
constants: {
|
|
881
|
-
defaultDuration: 300,
|
|
882
|
-
defaultDelay: 0,
|
|
883
|
-
slideDistance: 100,
|
|
884
|
-
scaleStart: 0.5,
|
|
885
|
-
easing: "linear"
|
|
886
|
-
}
|
|
887
|
-
};
|
|
888
|
-
function getInteractionsConfig() {
|
|
889
|
-
return window.ElementorInteractionsConfig || DEFAULT_CONFIG;
|
|
890
|
-
}
|
|
891
|
-
|
|
892
908
|
// src/utils/create-interactions-repository.ts
|
|
893
909
|
var createInteractionsRepository = () => {
|
|
894
910
|
const providers = [];
|
|
@@ -1452,12 +1468,29 @@ var initManageElementInteractionTool = (reg) => {
|
|
|
1452
1468
|
const elementData = allInteractions.find((data) => data.elementId === elementId);
|
|
1453
1469
|
const currentInteractions = elementData?.interactions ?? EMPTY_INTERACTIONS;
|
|
1454
1470
|
if (action === "get") {
|
|
1471
|
+
const summary = currentInteractions.items.map((item) => {
|
|
1472
|
+
const { value } = item;
|
|
1473
|
+
const animValue = value.animation.value;
|
|
1474
|
+
const timingValue = animValue.timing_config.value;
|
|
1475
|
+
const configValue = animValue.config.value;
|
|
1476
|
+
return {
|
|
1477
|
+
id: extractString(value.interaction_id),
|
|
1478
|
+
trigger: extractString(value.trigger),
|
|
1479
|
+
effect: extractString(animValue.effect),
|
|
1480
|
+
effectType: extractString(animValue.type),
|
|
1481
|
+
direction: extractString(animValue.direction),
|
|
1482
|
+
duration: extractSize(timingValue.duration),
|
|
1483
|
+
delay: extractSize(timingValue.delay),
|
|
1484
|
+
easing: extractString(configValue.easing),
|
|
1485
|
+
excludedBreakpoints: extractExcludedBreakpoints(value.breakpoints)
|
|
1486
|
+
};
|
|
1487
|
+
});
|
|
1455
1488
|
return {
|
|
1456
1489
|
success: true,
|
|
1457
1490
|
elementId,
|
|
1458
1491
|
action,
|
|
1459
|
-
interactions:
|
|
1460
|
-
count:
|
|
1492
|
+
interactions: summary,
|
|
1493
|
+
count: summary.length
|
|
1461
1494
|
};
|
|
1462
1495
|
}
|
|
1463
1496
|
let updatedItems = [...currentInteractions.items];
|
|
@@ -1661,10 +1694,32 @@ export {
|
|
|
1661
1694
|
InteractionsTab,
|
|
1662
1695
|
REPLAY_OPTIONS,
|
|
1663
1696
|
TRIGGER_OPTIONS,
|
|
1697
|
+
buildDisplayLabel,
|
|
1698
|
+
convertTimeUnit,
|
|
1699
|
+
createAnimationPreset,
|
|
1700
|
+
createBoolean,
|
|
1701
|
+
createConfig,
|
|
1702
|
+
createDefaultInteractionItem,
|
|
1703
|
+
createDefaultInteractions,
|
|
1704
|
+
createExcludedBreakpoints,
|
|
1705
|
+
createInteractionBreakpoints,
|
|
1706
|
+
createInteractionItem,
|
|
1664
1707
|
createInteractionsProvider,
|
|
1708
|
+
createNumber,
|
|
1709
|
+
createString,
|
|
1710
|
+
createTimingConfig,
|
|
1711
|
+
extractBoolean,
|
|
1712
|
+
extractExcludedBreakpoints,
|
|
1713
|
+
extractSize,
|
|
1714
|
+
extractString,
|
|
1715
|
+
formatSizeValue,
|
|
1716
|
+
generateTempInteractionId,
|
|
1665
1717
|
getInteractionsConfig,
|
|
1666
1718
|
init,
|
|
1667
1719
|
interactionsRepository,
|
|
1668
|
-
|
|
1720
|
+
isTempId,
|
|
1721
|
+
parseSizeValue,
|
|
1722
|
+
registerInteractionsControl,
|
|
1723
|
+
resolveDirection
|
|
1669
1724
|
};
|
|
1670
1725
|
//# sourceMappingURL=index.mjs.map
|