@elementor/editor-interactions 4.1.0-699 → 4.1.0-700
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 +31 -2
- package/dist/index.d.ts +31 -2
- package/dist/index.js +128 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +128 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/src/mcp/tools/schema.ts +1 -1
- package/src/utils/custom-effect-to-prop-value.ts +145 -0
- package/src/utils/prop-value-utils.ts +26 -22
package/dist/index.d.mts
CHANGED
|
@@ -137,6 +137,35 @@ declare const EFFECT_OPTIONS: {
|
|
|
137
137
|
};
|
|
138
138
|
declare const BASE_EFFECTS: string[];
|
|
139
139
|
|
|
140
|
+
type PlainKeyframeValue = {
|
|
141
|
+
opacity?: number;
|
|
142
|
+
scale?: {
|
|
143
|
+
x: number;
|
|
144
|
+
y: number;
|
|
145
|
+
};
|
|
146
|
+
rotate?: {
|
|
147
|
+
x: number;
|
|
148
|
+
y: number;
|
|
149
|
+
z: number;
|
|
150
|
+
};
|
|
151
|
+
move?: {
|
|
152
|
+
x: number;
|
|
153
|
+
y: number;
|
|
154
|
+
z: number;
|
|
155
|
+
};
|
|
156
|
+
skew?: {
|
|
157
|
+
x: number;
|
|
158
|
+
y: number;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
type PlainKeyframe = {
|
|
162
|
+
stop: number;
|
|
163
|
+
value: PlainKeyframeValue;
|
|
164
|
+
};
|
|
165
|
+
type PlainCustomEffect = {
|
|
166
|
+
keyframes: PlainKeyframe[];
|
|
167
|
+
};
|
|
168
|
+
|
|
140
169
|
declare const createString: (value: string) => StringPropValue;
|
|
141
170
|
declare const createNumber: (value: number) => NumberPropValue;
|
|
142
171
|
declare const createTimingConfig: (duration: SizeStringValue, delay: SizeStringValue) => TimingConfigPropValue;
|
|
@@ -167,7 +196,7 @@ declare const createAnimationPreset: ({ effect, type, direction, duration, delay
|
|
|
167
196
|
times?: number;
|
|
168
197
|
start?: SizeStringValue;
|
|
169
198
|
end?: SizeStringValue;
|
|
170
|
-
customEffects?: PropValue;
|
|
199
|
+
customEffects?: PropValue | PlainCustomEffect;
|
|
171
200
|
}) => AnimationPresetPropValue;
|
|
172
201
|
declare const createInteractionItem: ({ trigger, effect, type, direction, duration, delay, interactionId, replay, easing, relativeTo, repeat, times, start, end, excludedBreakpoints, customEffects, }: {
|
|
173
202
|
trigger?: string;
|
|
@@ -185,7 +214,7 @@ declare const createInteractionItem: ({ trigger, effect, type, direction, durati
|
|
|
185
214
|
start?: number;
|
|
186
215
|
end?: number;
|
|
187
216
|
excludedBreakpoints?: string[];
|
|
188
|
-
customEffects?: PropValue;
|
|
217
|
+
customEffects?: PropValue | PlainCustomEffect;
|
|
189
218
|
}) => InteractionItemPropValue;
|
|
190
219
|
declare const createDefaultInteractionItem: () => InteractionItemPropValue;
|
|
191
220
|
declare const createDefaultInteractions: () => ElementInteractions;
|
package/dist/index.d.ts
CHANGED
|
@@ -137,6 +137,35 @@ declare const EFFECT_OPTIONS: {
|
|
|
137
137
|
};
|
|
138
138
|
declare const BASE_EFFECTS: string[];
|
|
139
139
|
|
|
140
|
+
type PlainKeyframeValue = {
|
|
141
|
+
opacity?: number;
|
|
142
|
+
scale?: {
|
|
143
|
+
x: number;
|
|
144
|
+
y: number;
|
|
145
|
+
};
|
|
146
|
+
rotate?: {
|
|
147
|
+
x: number;
|
|
148
|
+
y: number;
|
|
149
|
+
z: number;
|
|
150
|
+
};
|
|
151
|
+
move?: {
|
|
152
|
+
x: number;
|
|
153
|
+
y: number;
|
|
154
|
+
z: number;
|
|
155
|
+
};
|
|
156
|
+
skew?: {
|
|
157
|
+
x: number;
|
|
158
|
+
y: number;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
type PlainKeyframe = {
|
|
162
|
+
stop: number;
|
|
163
|
+
value: PlainKeyframeValue;
|
|
164
|
+
};
|
|
165
|
+
type PlainCustomEffect = {
|
|
166
|
+
keyframes: PlainKeyframe[];
|
|
167
|
+
};
|
|
168
|
+
|
|
140
169
|
declare const createString: (value: string) => StringPropValue;
|
|
141
170
|
declare const createNumber: (value: number) => NumberPropValue;
|
|
142
171
|
declare const createTimingConfig: (duration: SizeStringValue, delay: SizeStringValue) => TimingConfigPropValue;
|
|
@@ -167,7 +196,7 @@ declare const createAnimationPreset: ({ effect, type, direction, duration, delay
|
|
|
167
196
|
times?: number;
|
|
168
197
|
start?: SizeStringValue;
|
|
169
198
|
end?: SizeStringValue;
|
|
170
|
-
customEffects?: PropValue;
|
|
199
|
+
customEffects?: PropValue | PlainCustomEffect;
|
|
171
200
|
}) => AnimationPresetPropValue;
|
|
172
201
|
declare const createInteractionItem: ({ trigger, effect, type, direction, duration, delay, interactionId, replay, easing, relativeTo, repeat, times, start, end, excludedBreakpoints, customEffects, }: {
|
|
173
202
|
trigger?: string;
|
|
@@ -185,7 +214,7 @@ declare const createInteractionItem: ({ trigger, effect, type, direction, durati
|
|
|
185
214
|
start?: number;
|
|
186
215
|
end?: number;
|
|
187
216
|
excludedBreakpoints?: string[];
|
|
188
|
-
customEffects?: PropValue;
|
|
217
|
+
customEffects?: PropValue | PlainCustomEffect;
|
|
189
218
|
}) => InteractionItemPropValue;
|
|
190
219
|
declare const createDefaultInteractionItem: () => InteractionItemPropValue;
|
|
191
220
|
declare const createDefaultInteractions: () => ElementInteractions;
|
package/dist/index.js
CHANGED
|
@@ -186,6 +186,110 @@ var createSizeValue = (size, unit) => {
|
|
|
186
186
|
return { size, unit };
|
|
187
187
|
};
|
|
188
188
|
|
|
189
|
+
// src/utils/custom-effect-to-prop-value.ts
|
|
190
|
+
var CUSTOM_EFFECT_TYPE = "custom-effect";
|
|
191
|
+
var KEYFRAMES_TYPE = "keyframes";
|
|
192
|
+
var KEYFRAME_STOP_TYPE = "keyframe-stop";
|
|
193
|
+
var KEYFRAME_STOP_SETTINGS_TYPE = "keyframe-stop-settings";
|
|
194
|
+
var SIZE_TYPE = "size";
|
|
195
|
+
var NUMBER_TYPE = "number";
|
|
196
|
+
var TRANSFORM_SCALE_TYPE = "transform-scale";
|
|
197
|
+
var TRANSFORM_ROTATE_TYPE = "transform-rotate";
|
|
198
|
+
var TRANSFORM_MOVE_TYPE = "transform-move";
|
|
199
|
+
var TRANSFORM_SKEW_TYPE = "transform-skew";
|
|
200
|
+
var UNIT_PERCENT = "%";
|
|
201
|
+
var UNIT_DEG = "deg";
|
|
202
|
+
var UNIT_PX = "px";
|
|
203
|
+
var isPlainCustomEffect = (v) => typeof v === "object" && v !== null && "keyframes" in v && Array.isArray(v.keyframes) && !("$$type" in v);
|
|
204
|
+
var toSizePropValue = (size, unit = UNIT_PERCENT) => ({
|
|
205
|
+
$$type: SIZE_TYPE,
|
|
206
|
+
value: { size, unit }
|
|
207
|
+
});
|
|
208
|
+
var toNumberPropValue = (n) => ({
|
|
209
|
+
$$type: NUMBER_TYPE,
|
|
210
|
+
value: n
|
|
211
|
+
});
|
|
212
|
+
var toDimensionalNumberPropValue = (type, plain, defaults) => ({
|
|
213
|
+
$$type: type,
|
|
214
|
+
value: {
|
|
215
|
+
x: toNumberPropValue(plain.x ?? defaults.x),
|
|
216
|
+
y: toNumberPropValue(plain.y ?? defaults.y),
|
|
217
|
+
z: toNumberPropValue(plain.z ?? defaults.z)
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
var toDimensionalSizePropValue = (type, plain, defaults, unit) => ({
|
|
221
|
+
$$type: type,
|
|
222
|
+
value: {
|
|
223
|
+
x: toSizePropValue(plain.x ?? defaults.x, unit),
|
|
224
|
+
y: toSizePropValue(plain.y ?? defaults.y, unit),
|
|
225
|
+
z: toSizePropValue(plain.z ?? defaults.z, unit)
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
var toSkewPropValue = (plain) => ({
|
|
229
|
+
$$type: TRANSFORM_SKEW_TYPE,
|
|
230
|
+
value: {
|
|
231
|
+
x: toSizePropValue(plain.x ?? 0, UNIT_DEG),
|
|
232
|
+
y: toSizePropValue(plain.y ?? 0, UNIT_DEG)
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
var toKeyframeStopSettingsPropValue = (plain) => {
|
|
236
|
+
const value = {};
|
|
237
|
+
if (plain.opacity !== void 0) {
|
|
238
|
+
const percent = plain.opacity <= 1 ? Math.round(plain.opacity * 100) : plain.opacity;
|
|
239
|
+
value.opacity = toSizePropValue(percent);
|
|
240
|
+
}
|
|
241
|
+
if (plain.scale !== void 0) {
|
|
242
|
+
value.scale = toDimensionalNumberPropValue(TRANSFORM_SCALE_TYPE, plain.scale, { x: 1, y: 1, z: 1 });
|
|
243
|
+
}
|
|
244
|
+
if (plain.rotate !== void 0) {
|
|
245
|
+
value.rotate = toDimensionalSizePropValue(
|
|
246
|
+
TRANSFORM_ROTATE_TYPE,
|
|
247
|
+
plain.rotate,
|
|
248
|
+
{ x: 0, y: 0, z: 0 },
|
|
249
|
+
UNIT_DEG
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
if (plain.move !== void 0) {
|
|
253
|
+
value.move = toDimensionalSizePropValue(TRANSFORM_MOVE_TYPE, plain.move, { x: 0, y: 0, z: 0 }, UNIT_PX);
|
|
254
|
+
}
|
|
255
|
+
if (plain.skew !== void 0) {
|
|
256
|
+
value.skew = toSkewPropValue(plain.skew);
|
|
257
|
+
}
|
|
258
|
+
return { $$type: KEYFRAME_STOP_SETTINGS_TYPE, value };
|
|
259
|
+
};
|
|
260
|
+
var isPlainKeyframe = (v) => typeof v === "object" && v !== null && "stop" in v && "value" in v && !("$$type" in v);
|
|
261
|
+
var toKeyframeStopPropValue = (item) => {
|
|
262
|
+
if (!isPlainKeyframe(item)) {
|
|
263
|
+
return item;
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
$$type: KEYFRAME_STOP_TYPE,
|
|
267
|
+
value: {
|
|
268
|
+
stop: toSizePropValue(item.stop),
|
|
269
|
+
settings: toKeyframeStopSettingsPropValue(item.value)
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
var toKeyframesPropValue = (keyframes) => ({
|
|
274
|
+
$$type: KEYFRAMES_TYPE,
|
|
275
|
+
value: keyframes.map(toKeyframeStopPropValue)
|
|
276
|
+
});
|
|
277
|
+
var plainCustomEffectToPropValue = (plain) => ({
|
|
278
|
+
$$type: CUSTOM_EFFECT_TYPE,
|
|
279
|
+
value: {
|
|
280
|
+
keyframes: toKeyframesPropValue(plain.keyframes)
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
var toCustomEffectPropValue = (customEffects) => {
|
|
284
|
+
if (customEffects === void 0) {
|
|
285
|
+
return void 0;
|
|
286
|
+
}
|
|
287
|
+
if (isPlainCustomEffect(customEffects)) {
|
|
288
|
+
return plainCustomEffectToPropValue(customEffects);
|
|
289
|
+
}
|
|
290
|
+
return customEffects;
|
|
291
|
+
};
|
|
292
|
+
|
|
189
293
|
// src/utils/get-interactions-config.ts
|
|
190
294
|
function getInteractionsConfig() {
|
|
191
295
|
return window.ElementorInteractionsConfig ?? {};
|
|
@@ -224,7 +328,7 @@ var createBoolean = (value) => ({
|
|
|
224
328
|
var createConfig = ({
|
|
225
329
|
replay,
|
|
226
330
|
easing = "easeIn",
|
|
227
|
-
relativeTo = "",
|
|
331
|
+
relativeTo = "viewport",
|
|
228
332
|
repeat = "",
|
|
229
333
|
times = 1,
|
|
230
334
|
start = 85,
|
|
@@ -277,25 +381,28 @@ var createAnimationPreset = ({
|
|
|
277
381
|
start,
|
|
278
382
|
end,
|
|
279
383
|
customEffects
|
|
280
|
-
}) =>
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
})
|
|
384
|
+
}) => {
|
|
385
|
+
const customEffectProp = toCustomEffectPropValue(customEffects);
|
|
386
|
+
return {
|
|
387
|
+
$$type: "animation-preset-props",
|
|
388
|
+
value: {
|
|
389
|
+
effect: createString(effect),
|
|
390
|
+
...customEffectProp !== void 0 && { custom_effect: customEffectProp },
|
|
391
|
+
type: createString(type),
|
|
392
|
+
direction: createString(direction ?? ""),
|
|
393
|
+
timing_config: createTimingConfig(duration, delay),
|
|
394
|
+
config: createConfig({
|
|
395
|
+
replay,
|
|
396
|
+
easing,
|
|
397
|
+
relativeTo,
|
|
398
|
+
repeat,
|
|
399
|
+
times,
|
|
400
|
+
start,
|
|
401
|
+
end
|
|
402
|
+
})
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
};
|
|
299
406
|
var createInteractionItem = ({
|
|
300
407
|
trigger,
|
|
301
408
|
effect,
|
|
@@ -1705,7 +1812,7 @@ var baseSchema = {
|
|
|
1705
1812
|
var proSchema = {
|
|
1706
1813
|
trigger: import_schema.z.enum(["load", "scrollIn", "scrollOut", "scrollOn", "hover", "click"]).optional().describe("Event that triggers the animation"),
|
|
1707
1814
|
effect: import_schema.z.enum(["fade", "slide", "scale", "custom"]).optional().describe("Animation effect type"),
|
|
1708
|
-
|
|
1815
|
+
customEffects: import_schema.z.object({
|
|
1709
1816
|
keyframes: import_schema.z.array(
|
|
1710
1817
|
import_schema.z.object({
|
|
1711
1818
|
stop: import_schema.z.number().describe("The stop of the keyframe in percent, can be either 0 or 100"),
|