@elementor/editor-interactions 4.0.0-498 → 4.0.0-500
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +178 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +163 -67
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
- package/src/components/controls/easing.tsx +38 -0
- package/src/components/controls/time-frame-indicator.tsx +36 -25
- package/src/components/interaction-details.tsx +27 -3
- package/src/components/interactions-list.tsx +74 -39
- package/src/init.ts +7 -0
- package/src/interactions-controls-registry.ts +2 -0
- package/src/utils/prop-value-utils.ts +31 -22
package/dist/index.d.mts
CHANGED
|
@@ -79,7 +79,7 @@ declare const ELEMENTS_INTERACTIONS_PROVIDER_KEY_PREFIX = "document-elements-int
|
|
|
79
79
|
|
|
80
80
|
declare function init(): void;
|
|
81
81
|
|
|
82
|
-
type InteractionsControlType = 'trigger' | 'effect' | 'effectType' | 'direction' | 'duration' | 'delay' | 'replay' | 'relativeTo' | 'offsetTop' | 'offsetBottom';
|
|
82
|
+
type InteractionsControlType = 'trigger' | 'effect' | 'effectType' | 'direction' | 'duration' | 'delay' | 'replay' | 'easing' | 'relativeTo' | 'offsetTop' | 'offsetBottom';
|
|
83
83
|
type InteractionsControlPropsMap = {
|
|
84
84
|
trigger: FieldProps;
|
|
85
85
|
effect: FieldProps;
|
|
@@ -88,6 +88,7 @@ type InteractionsControlPropsMap = {
|
|
|
88
88
|
duration: FieldProps;
|
|
89
89
|
delay: FieldProps;
|
|
90
90
|
replay: ReplayFieldProps;
|
|
91
|
+
easing: FieldProps;
|
|
91
92
|
relativeTo: FieldProps;
|
|
92
93
|
offsetTop: FieldProps;
|
|
93
94
|
offsetBottom: FieldProps;
|
package/dist/index.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ declare const ELEMENTS_INTERACTIONS_PROVIDER_KEY_PREFIX = "document-elements-int
|
|
|
79
79
|
|
|
80
80
|
declare function init(): void;
|
|
81
81
|
|
|
82
|
-
type InteractionsControlType = 'trigger' | 'effect' | 'effectType' | 'direction' | 'duration' | 'delay' | 'replay' | 'relativeTo' | 'offsetTop' | 'offsetBottom';
|
|
82
|
+
type InteractionsControlType = 'trigger' | 'effect' | 'effectType' | 'direction' | 'duration' | 'delay' | 'replay' | 'easing' | 'relativeTo' | 'offsetTop' | 'offsetBottom';
|
|
83
83
|
type InteractionsControlPropsMap = {
|
|
84
84
|
trigger: FieldProps;
|
|
85
85
|
effect: FieldProps;
|
|
@@ -88,6 +88,7 @@ type InteractionsControlPropsMap = {
|
|
|
88
88
|
duration: FieldProps;
|
|
89
89
|
delay: FieldProps;
|
|
90
90
|
replay: ReplayFieldProps;
|
|
91
|
+
easing: FieldProps;
|
|
91
92
|
relativeTo: FieldProps;
|
|
92
93
|
offsetTop: FieldProps;
|
|
93
94
|
offsetBottom: FieldProps;
|
package/dist/index.js
CHANGED
|
@@ -69,10 +69,10 @@ var EmptyState = ({ onCreateInteraction }) => {
|
|
|
69
69
|
|
|
70
70
|
// src/components/interactions-tab.tsx
|
|
71
71
|
var React10 = __toESM(require("react"));
|
|
72
|
-
var
|
|
72
|
+
var import_react7 = require("react");
|
|
73
73
|
var import_editor_elements2 = require("@elementor/editor-elements");
|
|
74
74
|
var import_session = require("@elementor/session");
|
|
75
|
-
var
|
|
75
|
+
var import_ui5 = require("@elementor/ui");
|
|
76
76
|
|
|
77
77
|
// src/contexts/interactions-context.tsx
|
|
78
78
|
var React2 = __toESM(require("react"));
|
|
@@ -131,11 +131,11 @@ var PopupStateProvider = ({ children }) => {
|
|
|
131
131
|
|
|
132
132
|
// src/components/interactions-list.tsx
|
|
133
133
|
var React9 = __toESM(require("react"));
|
|
134
|
-
var
|
|
135
|
-
var
|
|
134
|
+
var import_react6 = require("react");
|
|
135
|
+
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
136
136
|
var import_icons3 = require("@elementor/icons");
|
|
137
|
-
var
|
|
138
|
-
var
|
|
137
|
+
var import_ui4 = require("@elementor/ui");
|
|
138
|
+
var import_i18n6 = require("@wordpress/i18n");
|
|
139
139
|
|
|
140
140
|
// src/utils/temp-id-utils.ts
|
|
141
141
|
var TEMP_ID_PREFIX = "temp-";
|
|
@@ -163,13 +163,20 @@ var createBoolean = (value) => ({
|
|
|
163
163
|
$$type: "boolean",
|
|
164
164
|
value
|
|
165
165
|
});
|
|
166
|
-
var createConfig = (
|
|
166
|
+
var createConfig = ({
|
|
167
|
+
replay,
|
|
168
|
+
easing = "easeIn",
|
|
169
|
+
relativeTo = "",
|
|
170
|
+
offsetTop = 0,
|
|
171
|
+
offsetBottom = 100
|
|
172
|
+
}) => ({
|
|
167
173
|
$$type: "config",
|
|
168
174
|
value: {
|
|
169
175
|
replay: createBoolean(replay),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
176
|
+
easing: createString(easing),
|
|
177
|
+
relativeTo: createString(relativeTo),
|
|
178
|
+
offsetTop: createNumber(offsetTop),
|
|
179
|
+
offsetBottom: createNumber(offsetBottom)
|
|
173
180
|
}
|
|
174
181
|
});
|
|
175
182
|
var extractBoolean = (prop, fallback = false) => {
|
|
@@ -182,6 +189,7 @@ var createAnimationPreset = ({
|
|
|
182
189
|
duration,
|
|
183
190
|
delay,
|
|
184
191
|
replay = false,
|
|
192
|
+
easing = "easeIn",
|
|
185
193
|
relativeTo,
|
|
186
194
|
offsetTop,
|
|
187
195
|
offsetBottom
|
|
@@ -192,7 +200,13 @@ var createAnimationPreset = ({
|
|
|
192
200
|
type: createString(type),
|
|
193
201
|
direction: createString(direction ?? ""),
|
|
194
202
|
timing_config: createTimingConfig(duration, delay),
|
|
195
|
-
config: createConfig(
|
|
203
|
+
config: createConfig({
|
|
204
|
+
replay,
|
|
205
|
+
easing,
|
|
206
|
+
relativeTo,
|
|
207
|
+
offsetTop,
|
|
208
|
+
offsetBottom
|
|
209
|
+
})
|
|
196
210
|
}
|
|
197
211
|
});
|
|
198
212
|
var createInteractionItem = ({
|
|
@@ -204,6 +218,7 @@ var createInteractionItem = ({
|
|
|
204
218
|
delay,
|
|
205
219
|
interactionId,
|
|
206
220
|
replay = false,
|
|
221
|
+
easing = "easeIn",
|
|
207
222
|
relativeTo,
|
|
208
223
|
offsetTop,
|
|
209
224
|
offsetBottom
|
|
@@ -219,6 +234,7 @@ var createInteractionItem = ({
|
|
|
219
234
|
duration,
|
|
220
235
|
delay,
|
|
221
236
|
replay,
|
|
237
|
+
easing,
|
|
222
238
|
relativeTo,
|
|
223
239
|
offsetTop,
|
|
224
240
|
offsetBottom
|
|
@@ -230,9 +246,10 @@ var createDefaultInteractionItem = () => {
|
|
|
230
246
|
trigger: "load",
|
|
231
247
|
effect: "fade",
|
|
232
248
|
type: "in",
|
|
233
|
-
duration:
|
|
249
|
+
duration: 600,
|
|
234
250
|
delay: 0,
|
|
235
251
|
replay: false,
|
|
252
|
+
easing: "easeIn",
|
|
236
253
|
interactionId: generateTempInteractionId()
|
|
237
254
|
});
|
|
238
255
|
};
|
|
@@ -263,10 +280,10 @@ var buildDisplayLabel = (item) => {
|
|
|
263
280
|
|
|
264
281
|
// src/components/interaction-details.tsx
|
|
265
282
|
var React8 = __toESM(require("react"));
|
|
266
|
-
var
|
|
267
|
-
var
|
|
268
|
-
var
|
|
269
|
-
var
|
|
283
|
+
var import_react5 = require("react");
|
|
284
|
+
var import_editor_controls4 = require("@elementor/editor-controls");
|
|
285
|
+
var import_ui3 = require("@elementor/ui");
|
|
286
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
270
287
|
|
|
271
288
|
// src/interactions-controls-registry.ts
|
|
272
289
|
var controlsRegistry = /* @__PURE__ */ new Map();
|
|
@@ -370,31 +387,42 @@ function EffectType({ value, onChange }) {
|
|
|
370
387
|
|
|
371
388
|
// src/components/controls/time-frame-indicator.tsx
|
|
372
389
|
var React7 = __toESM(require("react"));
|
|
373
|
-
var
|
|
374
|
-
var
|
|
375
|
-
var
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
390
|
+
var import_react4 = require("react");
|
|
391
|
+
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
392
|
+
var import_editor_props = require("@elementor/editor-props");
|
|
393
|
+
var DEFAULT_UNIT = "ms";
|
|
394
|
+
function TimeFrameIndicator({ value, onChange, defaultValue }) {
|
|
395
|
+
const sizeValue = toSizeValue(value ?? defaultValue);
|
|
396
|
+
const setValue = (0, import_react4.useCallback)(
|
|
397
|
+
(size) => {
|
|
398
|
+
onChange(String(size));
|
|
399
|
+
},
|
|
400
|
+
[onChange]
|
|
383
401
|
);
|
|
402
|
+
const handleChange = (newValue) => {
|
|
403
|
+
setValue(newValue.size);
|
|
404
|
+
};
|
|
405
|
+
const handleBlur = () => {
|
|
406
|
+
if (!sizeValue.size) {
|
|
407
|
+
setValue(defaultValue);
|
|
408
|
+
}
|
|
409
|
+
};
|
|
384
410
|
return /* @__PURE__ */ React7.createElement(
|
|
385
|
-
|
|
411
|
+
import_editor_controls3.UnstableSizeField,
|
|
386
412
|
{
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
},
|
|
393
|
-
availableTimeFrames.map((timeFrame) => {
|
|
394
|
-
return /* @__PURE__ */ React7.createElement(import_editor_ui2.MenuListItem, { key: timeFrame.key, value: timeFrame.key }, timeFrame.label);
|
|
395
|
-
})
|
|
413
|
+
units: [DEFAULT_UNIT],
|
|
414
|
+
value: sizeValue,
|
|
415
|
+
onChange: handleChange,
|
|
416
|
+
onBlur: handleBlur
|
|
417
|
+
}
|
|
396
418
|
);
|
|
397
419
|
}
|
|
420
|
+
var toSizeValue = (value) => {
|
|
421
|
+
return import_editor_props.sizePropTypeUtil.create({
|
|
422
|
+
size: Number(value),
|
|
423
|
+
unit: DEFAULT_UNIT
|
|
424
|
+
}).value;
|
|
425
|
+
};
|
|
398
426
|
|
|
399
427
|
// src/components/interaction-details.tsx
|
|
400
428
|
var DEFAULT_VALUES = {
|
|
@@ -402,9 +430,10 @@ var DEFAULT_VALUES = {
|
|
|
402
430
|
effect: "fade",
|
|
403
431
|
type: "in",
|
|
404
432
|
direction: "",
|
|
405
|
-
duration:
|
|
433
|
+
duration: 600,
|
|
406
434
|
delay: 0,
|
|
407
435
|
replay: false,
|
|
436
|
+
easing: "easeIn",
|
|
408
437
|
relativeTo: "viewport",
|
|
409
438
|
offsetTop: 15,
|
|
410
439
|
offsetBottom: 85
|
|
@@ -425,7 +454,7 @@ var controlVisibilityConfig = {
|
|
|
425
454
|
}
|
|
426
455
|
};
|
|
427
456
|
function useControlComponent(controlName, isVisible = true) {
|
|
428
|
-
return (0,
|
|
457
|
+
return (0, import_react5.useMemo)(() => {
|
|
429
458
|
if (!isVisible) {
|
|
430
459
|
return null;
|
|
431
460
|
}
|
|
@@ -440,6 +469,7 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
440
469
|
const duration = extractNumber(interaction.animation.value.timing_config.value.duration, DEFAULT_VALUES.duration);
|
|
441
470
|
const delay = extractNumber(interaction.animation.value.timing_config.value.delay, DEFAULT_VALUES.delay);
|
|
442
471
|
const replay = extractBoolean(interaction.animation.value.config?.value.replay, DEFAULT_VALUES.replay);
|
|
472
|
+
const easing = extractString(interaction.animation.value.config?.value.easing, DEFAULT_VALUES.easing);
|
|
443
473
|
const relativeTo = extractString(interaction.animation.value.config?.value.relativeTo, DEFAULT_VALUES.relativeTo);
|
|
444
474
|
const offsetTop = extractNumber(interaction.animation.value.config?.value.offsetTop, DEFAULT_VALUES.offsetTop);
|
|
445
475
|
const offsetBottom = extractNumber(
|
|
@@ -453,6 +483,7 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
453
483
|
direction,
|
|
454
484
|
duration,
|
|
455
485
|
delay,
|
|
486
|
+
easing,
|
|
456
487
|
replay,
|
|
457
488
|
relativeTo,
|
|
458
489
|
offsetTop,
|
|
@@ -469,6 +500,7 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
469
500
|
"offsetBottom",
|
|
470
501
|
controlVisibilityConfig.offsetBottom(interactionValues)
|
|
471
502
|
);
|
|
503
|
+
const EasingControl = useControlComponent("easing");
|
|
472
504
|
const resolveDirection = (hasDirection, newEffect, newDirection) => {
|
|
473
505
|
if (newEffect === "slide" && !newDirection) {
|
|
474
506
|
return "top";
|
|
@@ -480,7 +512,6 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
480
512
|
};
|
|
481
513
|
const updateInteraction = (updates) => {
|
|
482
514
|
const resolvedDirectionValue = resolveDirection("direction" in updates, updates.effect, updates.direction);
|
|
483
|
-
const newReplay = updates.replay !== void 0 ? updates.replay : replay;
|
|
484
515
|
const updatedInteraction = {
|
|
485
516
|
...interaction,
|
|
486
517
|
interaction_id: interaction.interaction_id,
|
|
@@ -491,7 +522,8 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
491
522
|
direction: resolvedDirectionValue,
|
|
492
523
|
duration: updates.duration ?? duration,
|
|
493
524
|
delay: updates.delay ?? delay,
|
|
494
|
-
replay:
|
|
525
|
+
replay: updates.replay ?? replay,
|
|
526
|
+
easing: updates.easing ?? easing,
|
|
495
527
|
relativeTo: updates.relativeTo ?? relativeTo,
|
|
496
528
|
offsetTop: updates.offsetTop ?? offsetTop,
|
|
497
529
|
offsetBottom: updates.offsetBottom ?? offsetBottom
|
|
@@ -503,68 +535,79 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
503
535
|
onPlayInteraction(interactionId);
|
|
504
536
|
}, 0);
|
|
505
537
|
};
|
|
506
|
-
return /* @__PURE__ */ React8.createElement(
|
|
538
|
+
return /* @__PURE__ */ React8.createElement(import_editor_controls4.PopoverContent, { p: 1.5 }, /* @__PURE__ */ React8.createElement(import_ui3.Grid, { container: true, spacing: 1.5 }, TriggerControl && /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Trigger", "elementor") }, /* @__PURE__ */ React8.createElement(TriggerControl, { value: trigger, onChange: (v) => updateInteraction({ trigger: v }) })), ReplayControl && /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Replay", "elementor") }, /* @__PURE__ */ React8.createElement(
|
|
507
539
|
ReplayControl,
|
|
508
540
|
{
|
|
509
541
|
value: replay,
|
|
510
542
|
onChange: (v) => updateInteraction({ replay: v }),
|
|
511
543
|
disabled: true
|
|
512
544
|
}
|
|
513
|
-
))), /* @__PURE__ */ React8.createElement(
|
|
545
|
+
))), /* @__PURE__ */ React8.createElement(import_ui3.Divider, null), /* @__PURE__ */ React8.createElement(import_ui3.Grid, { container: true, spacing: 1.5 }, /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Effect", "elementor") }, /* @__PURE__ */ React8.createElement(Effect, { value: effect, onChange: (v) => updateInteraction({ effect: v }) })), /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Type", "elementor") }, /* @__PURE__ */ React8.createElement(EffectType, { value: type, onChange: (v) => updateInteraction({ type: v }) })), /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Direction", "elementor") }, /* @__PURE__ */ React8.createElement(
|
|
514
546
|
Direction,
|
|
515
547
|
{
|
|
516
548
|
value: direction,
|
|
517
549
|
onChange: (v) => updateInteraction({ direction: v }),
|
|
518
550
|
interactionType: type
|
|
519
551
|
}
|
|
520
|
-
)), controlVisibilityConfig.duration(interactionValues) && /* @__PURE__ */ React8.createElement(Field, { label: (0,
|
|
552
|
+
)), controlVisibilityConfig.duration(interactionValues) && /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Duration", "elementor") }, /* @__PURE__ */ React8.createElement(
|
|
521
553
|
TimeFrameIndicator,
|
|
522
554
|
{
|
|
523
555
|
value: String(duration),
|
|
524
|
-
onChange: (v) => updateInteraction({ duration: parseInt(v, 10) })
|
|
556
|
+
onChange: (v) => updateInteraction({ duration: parseInt(v, 10) }),
|
|
557
|
+
defaultValue: DEFAULT_VALUES.duration
|
|
525
558
|
}
|
|
526
|
-
)), controlVisibilityConfig.delay(interactionValues) && /* @__PURE__ */ React8.createElement(Field, { label: (0,
|
|
559
|
+
)), controlVisibilityConfig.delay(interactionValues) && /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Delay", "elementor") }, /* @__PURE__ */ React8.createElement(
|
|
527
560
|
TimeFrameIndicator,
|
|
528
561
|
{
|
|
529
562
|
value: String(delay),
|
|
530
|
-
onChange: (v) => updateInteraction({ delay: parseInt(v, 10) })
|
|
563
|
+
onChange: (v) => updateInteraction({ delay: parseInt(v, 10) }),
|
|
564
|
+
defaultValue: DEFAULT_VALUES.delay
|
|
531
565
|
}
|
|
532
|
-
))), controlVisibilityConfig.relativeTo(interactionValues) && RelativeToControl && /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(
|
|
566
|
+
))), controlVisibilityConfig.relativeTo(interactionValues) && RelativeToControl && /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(import_ui3.Divider, null), /* @__PURE__ */ React8.createElement(import_ui3.Grid, { container: true, spacing: 1.5 }, /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Relative To", "elementor") }, /* @__PURE__ */ React8.createElement(
|
|
533
567
|
RelativeToControl,
|
|
534
568
|
{
|
|
535
569
|
value: relativeTo,
|
|
536
570
|
onChange: (v) => updateInteraction({ relativeTo: v })
|
|
537
571
|
}
|
|
538
|
-
)), OffsetTopControl && /* @__PURE__ */ React8.createElement(Field, { label: (0,
|
|
572
|
+
)), OffsetTopControl && /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Offset Top", "elementor") }, /* @__PURE__ */ React8.createElement(
|
|
539
573
|
OffsetTopControl,
|
|
540
574
|
{
|
|
541
575
|
value: String(offsetTop),
|
|
542
576
|
onChange: (v) => updateInteraction({ offsetTop: parseInt(v, 10) })
|
|
543
577
|
}
|
|
544
|
-
)), OffsetBottomControl && /* @__PURE__ */ React8.createElement(Field, { label: (0,
|
|
578
|
+
)), OffsetBottomControl && /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Offset Bottom", "elementor") }, /* @__PURE__ */ React8.createElement(
|
|
545
579
|
OffsetBottomControl,
|
|
546
580
|
{
|
|
547
581
|
value: String(offsetBottom),
|
|
548
582
|
onChange: (v) => updateInteraction({ offsetBottom: parseInt(v, 10) })
|
|
549
583
|
}
|
|
550
|
-
))), /* @__PURE__ */ React8.createElement(
|
|
584
|
+
))), /* @__PURE__ */ React8.createElement(import_ui3.Divider, null)), EasingControl && /* @__PURE__ */ React8.createElement(import_ui3.Grid, { container: true, spacing: 1.5 }, /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Easing", "elementor") }, /* @__PURE__ */ React8.createElement(
|
|
585
|
+
EasingControl,
|
|
586
|
+
{
|
|
587
|
+
value: easing,
|
|
588
|
+
onChange: (v) => {
|
|
589
|
+
updateInteraction({ easing: v });
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
))));
|
|
551
593
|
};
|
|
552
594
|
function Field({ label, children }) {
|
|
553
|
-
return /* @__PURE__ */ React8.createElement(
|
|
595
|
+
return /* @__PURE__ */ React8.createElement(import_ui3.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React8.createElement(import_editor_controls4.PopoverGridContainer, null, /* @__PURE__ */ React8.createElement(import_ui3.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React8.createElement(import_editor_controls4.ControlFormLabel, null, label)), /* @__PURE__ */ React8.createElement(import_ui3.Grid, { item: true, xs: 6 }, children)));
|
|
554
596
|
}
|
|
555
597
|
|
|
556
598
|
// src/components/interactions-list.tsx
|
|
557
599
|
var MAX_NUMBER_OF_INTERACTIONS = 5;
|
|
600
|
+
var InteractionItemContext = (0, import_react6.createContext)(null);
|
|
558
601
|
function InteractionsList(props) {
|
|
559
602
|
const { interactions, onSelectInteractions, onPlayInteraction, triggerCreateOnShowEmpty } = props;
|
|
560
|
-
const hasInitializedRef = (0,
|
|
561
|
-
const handleUpdateInteractions = (0,
|
|
603
|
+
const hasInitializedRef = (0, import_react6.useRef)(false);
|
|
604
|
+
const handleUpdateInteractions = (0, import_react6.useCallback)(
|
|
562
605
|
(newInteractions) => {
|
|
563
606
|
onSelectInteractions(newInteractions);
|
|
564
607
|
},
|
|
565
608
|
[onSelectInteractions]
|
|
566
609
|
);
|
|
567
|
-
(0,
|
|
610
|
+
(0, import_react6.useEffect)(() => {
|
|
568
611
|
if (triggerCreateOnShowEmpty && !hasInitializedRef.current && (!interactions.items || interactions.items?.length === 0)) {
|
|
569
612
|
hasInitializedRef.current = true;
|
|
570
613
|
const newState = {
|
|
@@ -574,14 +617,14 @@ function InteractionsList(props) {
|
|
|
574
617
|
handleUpdateInteractions(newState);
|
|
575
618
|
}
|
|
576
619
|
}, [triggerCreateOnShowEmpty, interactions.items, handleUpdateInteractions]);
|
|
577
|
-
const isMaxNumberOfInteractionsReached = (0,
|
|
620
|
+
const isMaxNumberOfInteractionsReached = (0, import_react6.useMemo)(() => {
|
|
578
621
|
return interactions.items?.length >= MAX_NUMBER_OF_INTERACTIONS;
|
|
579
622
|
}, [interactions.items?.length]);
|
|
580
|
-
const infotipContent = isMaxNumberOfInteractionsReached ? /* @__PURE__ */ React9.createElement(
|
|
623
|
+
const infotipContent = isMaxNumberOfInteractionsReached ? /* @__PURE__ */ React9.createElement(import_ui4.Alert, { color: "secondary", icon: /* @__PURE__ */ React9.createElement(import_icons3.InfoCircleFilledIcon, null), size: "small" }, /* @__PURE__ */ React9.createElement(import_ui4.AlertTitle, null, (0, import_i18n6.__)("Interactions", "elementor")), /* @__PURE__ */ React9.createElement(import_ui4.Box, { component: "span" }, (0, import_i18n6.__)(
|
|
581
624
|
"You've reached the limit of 5 interactions for this element. Please remove an interaction before creating a new one.",
|
|
582
625
|
"elementor"
|
|
583
626
|
))) : void 0;
|
|
584
|
-
const handleRepeaterChange = (0,
|
|
627
|
+
const handleRepeaterChange = (0, import_react6.useCallback)(
|
|
585
628
|
(newItems) => {
|
|
586
629
|
handleUpdateInteractions({
|
|
587
630
|
...interactions,
|
|
@@ -590,7 +633,7 @@ function InteractionsList(props) {
|
|
|
590
633
|
},
|
|
591
634
|
[interactions, handleUpdateInteractions]
|
|
592
635
|
);
|
|
593
|
-
const handleInteractionChange = (0,
|
|
636
|
+
const handleInteractionChange = (0, import_react6.useCallback)(
|
|
594
637
|
(index, newInteractionValue) => {
|
|
595
638
|
const newItems = structuredClone(interactions.items);
|
|
596
639
|
newItems[index] = {
|
|
@@ -604,12 +647,19 @@ function InteractionsList(props) {
|
|
|
604
647
|
},
|
|
605
648
|
[interactions, handleUpdateInteractions]
|
|
606
649
|
);
|
|
607
|
-
|
|
608
|
-
|
|
650
|
+
const contextValue = (0, import_react6.useMemo)(
|
|
651
|
+
() => ({
|
|
652
|
+
onInteractionChange: handleInteractionChange,
|
|
653
|
+
onPlayInteraction
|
|
654
|
+
}),
|
|
655
|
+
[handleInteractionChange, onPlayInteraction]
|
|
656
|
+
);
|
|
657
|
+
return /* @__PURE__ */ React9.createElement(InteractionItemContext.Provider, { value: contextValue }, /* @__PURE__ */ React9.createElement(
|
|
658
|
+
import_editor_controls5.Repeater,
|
|
609
659
|
{
|
|
610
660
|
openOnAdd: true,
|
|
611
661
|
openItem: triggerCreateOnShowEmpty ? 0 : void 0,
|
|
612
|
-
label: (0,
|
|
662
|
+
label: (0, import_i18n6.__)("Interactions", "elementor"),
|
|
613
663
|
values: interactions.items,
|
|
614
664
|
setValues: handleRepeaterChange,
|
|
615
665
|
showDuplicate: false,
|
|
@@ -621,21 +671,11 @@ function InteractionsList(props) {
|
|
|
621
671
|
initialValues: createDefaultInteractionItem(),
|
|
622
672
|
Label: ({ value }) => buildDisplayLabel(value.value),
|
|
623
673
|
Icon: () => null,
|
|
624
|
-
Content
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
key: index,
|
|
628
|
-
interaction: value.value,
|
|
629
|
-
onChange: (newInteractionValue) => {
|
|
630
|
-
handleInteractionChange(index, newInteractionValue);
|
|
631
|
-
},
|
|
632
|
-
onPlayInteraction
|
|
633
|
-
}
|
|
634
|
-
),
|
|
635
|
-
actions: (value) => /* @__PURE__ */ React9.createElement(import_ui5.Tooltip, { key: "preview", placement: "top", title: (0, import_i18n7.__)("Preview", "elementor") }, /* @__PURE__ */ React9.createElement(
|
|
636
|
-
import_ui5.IconButton,
|
|
674
|
+
Content,
|
|
675
|
+
actions: (value) => /* @__PURE__ */ React9.createElement(import_ui4.Tooltip, { key: "preview", placement: "top", title: (0, import_i18n6.__)("Preview", "elementor") }, /* @__PURE__ */ React9.createElement(
|
|
676
|
+
import_ui4.IconButton,
|
|
637
677
|
{
|
|
638
|
-
"aria-label": (0,
|
|
678
|
+
"aria-label": (0, import_i18n6.__)("Play interaction", "elementor"),
|
|
639
679
|
size: "tiny",
|
|
640
680
|
onClick: () => onPlayInteraction(extractString(value.value.interaction_id))
|
|
641
681
|
},
|
|
@@ -643,8 +683,32 @@ function InteractionsList(props) {
|
|
|
643
683
|
))
|
|
644
684
|
}
|
|
645
685
|
}
|
|
646
|
-
);
|
|
686
|
+
));
|
|
647
687
|
}
|
|
688
|
+
var Content = ({ index, value }) => {
|
|
689
|
+
const context = (0, import_react6.useContext)(InteractionItemContext);
|
|
690
|
+
const handleChange = (0, import_react6.useCallback)(
|
|
691
|
+
(newInteractionValue) => {
|
|
692
|
+
context?.onInteractionChange(index, newInteractionValue);
|
|
693
|
+
},
|
|
694
|
+
[context, index]
|
|
695
|
+
);
|
|
696
|
+
const handlePlayInteraction = (0, import_react6.useCallback)(
|
|
697
|
+
(interactionId) => {
|
|
698
|
+
context?.onPlayInteraction(interactionId);
|
|
699
|
+
},
|
|
700
|
+
[context]
|
|
701
|
+
);
|
|
702
|
+
return /* @__PURE__ */ React9.createElement(
|
|
703
|
+
InteractionDetails,
|
|
704
|
+
{
|
|
705
|
+
key: index,
|
|
706
|
+
interaction: value.value,
|
|
707
|
+
onChange: handleChange,
|
|
708
|
+
onPlayInteraction: handlePlayInteraction
|
|
709
|
+
}
|
|
710
|
+
);
|
|
711
|
+
};
|
|
648
712
|
|
|
649
713
|
// src/components/interactions-tab.tsx
|
|
650
714
|
var InteractionsTab = ({ elementId }) => {
|
|
@@ -652,7 +716,7 @@ var InteractionsTab = ({ elementId }) => {
|
|
|
652
716
|
};
|
|
653
717
|
function InteractionsTabContent({ elementId }) {
|
|
654
718
|
const existingInteractions = (0, import_editor_elements2.useElementInteractions)(elementId);
|
|
655
|
-
const firstInteractionState = (0,
|
|
719
|
+
const firstInteractionState = (0, import_react7.useState)(false);
|
|
656
720
|
const hasInteractions = existingInteractions?.items?.length || firstInteractionState[0];
|
|
657
721
|
return /* @__PURE__ */ React10.createElement(import_session.SessionStorageProvider, { prefix: elementId }, hasInteractions ? /* @__PURE__ */ React10.createElement(InteractionsProvider, { elementId }, /* @__PURE__ */ React10.createElement(InteractionsContent, { firstInteractionState })) : /* @__PURE__ */ React10.createElement(
|
|
658
722
|
EmptyState,
|
|
@@ -667,7 +731,7 @@ function InteractionsContent({
|
|
|
667
731
|
firstInteractionState
|
|
668
732
|
}) {
|
|
669
733
|
const { interactions, setInteractions, playInteractions } = useInteractionsContext();
|
|
670
|
-
const applyInteraction = (0,
|
|
734
|
+
const applyInteraction = (0, import_react7.useCallback)(
|
|
671
735
|
(newInteractions) => {
|
|
672
736
|
firstInteractionState[1](false);
|
|
673
737
|
if (!newInteractions) {
|
|
@@ -678,7 +742,7 @@ function InteractionsContent({
|
|
|
678
742
|
},
|
|
679
743
|
[setInteractions, firstInteractionState]
|
|
680
744
|
);
|
|
681
|
-
return /* @__PURE__ */ React10.createElement(
|
|
745
|
+
return /* @__PURE__ */ React10.createElement(import_ui5.Stack, { sx: { m: 1, p: 1.5 }, gap: 2 }, /* @__PURE__ */ React10.createElement(
|
|
682
746
|
InteractionsList,
|
|
683
747
|
{
|
|
684
748
|
triggerCreateOnShowEmpty: firstInteractionState[0],
|
|
@@ -803,8 +867,35 @@ var documentElementsInteractionsProvider = createInteractionsProvider({
|
|
|
803
867
|
}
|
|
804
868
|
});
|
|
805
869
|
|
|
806
|
-
// src/components/controls/
|
|
870
|
+
// src/components/controls/easing.tsx
|
|
807
871
|
var React11 = __toESM(require("react"));
|
|
872
|
+
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
873
|
+
var import_ui6 = require("@elementor/ui");
|
|
874
|
+
var import_i18n7 = require("@wordpress/i18n");
|
|
875
|
+
var EASING_OPTIONS = {
|
|
876
|
+
easeIn: (0, import_i18n7.__)("Ease In", "elementor"),
|
|
877
|
+
easeInOut: (0, import_i18n7.__)("Ease In Out", "elementor"),
|
|
878
|
+
easeOut: (0, import_i18n7.__)("Ease Out", "elementor"),
|
|
879
|
+
backIn: (0, import_i18n7.__)("Back In", "elementor"),
|
|
880
|
+
backInOut: (0, import_i18n7.__)("Back In Out", "elementor"),
|
|
881
|
+
backOut: (0, import_i18n7.__)("Back Out", "elementor"),
|
|
882
|
+
linear: (0, import_i18n7.__)("Linear", "elementor")
|
|
883
|
+
};
|
|
884
|
+
var DEFAULT_EASING = "easeIn";
|
|
885
|
+
function Easing({}) {
|
|
886
|
+
const availableOptions = Object.entries(EASING_OPTIONS).map(([key, label]) => ({
|
|
887
|
+
key,
|
|
888
|
+
label
|
|
889
|
+
}));
|
|
890
|
+
return /* @__PURE__ */ React11.createElement(import_ui6.Select, { value: DEFAULT_EASING, onChange: () => {
|
|
891
|
+
}, fullWidth: true, displayEmpty: true, size: "tiny" }, availableOptions.map((option) => {
|
|
892
|
+
const isDisabled = DEFAULT_EASING !== option.key;
|
|
893
|
+
return /* @__PURE__ */ React11.createElement(import_editor_ui2.MenuListItem, { key: option.key, value: option.key, disabled: isDisabled }, option.label);
|
|
894
|
+
}));
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
// src/components/controls/trigger.tsx
|
|
898
|
+
var React12 = __toESM(require("react"));
|
|
808
899
|
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
809
900
|
var import_ui7 = require("@elementor/ui");
|
|
810
901
|
var import_i18n8 = require("@wordpress/i18n");
|
|
@@ -816,7 +907,7 @@ function Trigger({ value, onChange }) {
|
|
|
816
907
|
key,
|
|
817
908
|
label
|
|
818
909
|
}));
|
|
819
|
-
return /* @__PURE__ */
|
|
910
|
+
return /* @__PURE__ */ React12.createElement(
|
|
820
911
|
import_ui7.Select,
|
|
821
912
|
{
|
|
822
913
|
fullWidth: true,
|
|
@@ -826,7 +917,7 @@ function Trigger({ value, onChange }) {
|
|
|
826
917
|
value
|
|
827
918
|
},
|
|
828
919
|
availableTriggers.map((trigger) => {
|
|
829
|
-
return /* @__PURE__ */
|
|
920
|
+
return /* @__PURE__ */ React12.createElement(import_editor_ui3.MenuListItem, { key: trigger.key, value: trigger.key }, trigger.label);
|
|
830
921
|
})
|
|
831
922
|
);
|
|
832
923
|
}
|
|
@@ -879,6 +970,11 @@ function init() {
|
|
|
879
970
|
component: Trigger,
|
|
880
971
|
options: ["load", "scrollIn"]
|
|
881
972
|
});
|
|
973
|
+
registerInteractionsControl({
|
|
974
|
+
type: "easing",
|
|
975
|
+
component: Easing,
|
|
976
|
+
options: ["easeIn"]
|
|
977
|
+
});
|
|
882
978
|
} catch (error) {
|
|
883
979
|
throw error;
|
|
884
980
|
}
|