@elementor/editor-interactions 4.0.0-497 → 4.0.0-499
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.js +159 -108
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +144 -93
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
- package/src/components/controls/time-frame-indicator.tsx +36 -25
- package/src/components/interaction-details.tsx +99 -48
- package/src/components/interactions-list.tsx +74 -39
- package/src/utils/prop-value-utils.ts +1 -12
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-";
|
|
@@ -230,7 +230,7 @@ var createDefaultInteractionItem = () => {
|
|
|
230
230
|
trigger: "load",
|
|
231
231
|
effect: "fade",
|
|
232
232
|
type: "in",
|
|
233
|
-
duration:
|
|
233
|
+
duration: 600,
|
|
234
234
|
delay: 0,
|
|
235
235
|
replay: false,
|
|
236
236
|
interactionId: generateTempInteractionId()
|
|
@@ -263,10 +263,10 @@ var buildDisplayLabel = (item) => {
|
|
|
263
263
|
|
|
264
264
|
// src/components/interaction-details.tsx
|
|
265
265
|
var React8 = __toESM(require("react"));
|
|
266
|
-
var
|
|
267
|
-
var
|
|
268
|
-
var
|
|
269
|
-
var
|
|
266
|
+
var import_react5 = require("react");
|
|
267
|
+
var import_editor_controls4 = require("@elementor/editor-controls");
|
|
268
|
+
var import_ui3 = require("@elementor/ui");
|
|
269
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
270
270
|
|
|
271
271
|
// src/interactions-controls-registry.ts
|
|
272
272
|
var controlsRegistry = /* @__PURE__ */ new Map();
|
|
@@ -370,31 +370,42 @@ function EffectType({ value, onChange }) {
|
|
|
370
370
|
|
|
371
371
|
// src/components/controls/time-frame-indicator.tsx
|
|
372
372
|
var React7 = __toESM(require("react"));
|
|
373
|
-
var
|
|
374
|
-
var
|
|
375
|
-
var
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
373
|
+
var import_react4 = require("react");
|
|
374
|
+
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
375
|
+
var import_editor_props = require("@elementor/editor-props");
|
|
376
|
+
var DEFAULT_UNIT = "ms";
|
|
377
|
+
function TimeFrameIndicator({ value, onChange, defaultValue }) {
|
|
378
|
+
const sizeValue = toSizeValue(value ?? defaultValue);
|
|
379
|
+
const setValue = (0, import_react4.useCallback)(
|
|
380
|
+
(size) => {
|
|
381
|
+
onChange(String(size));
|
|
382
|
+
},
|
|
383
|
+
[onChange]
|
|
383
384
|
);
|
|
385
|
+
const handleChange = (newValue) => {
|
|
386
|
+
setValue(newValue.size);
|
|
387
|
+
};
|
|
388
|
+
const handleBlur = () => {
|
|
389
|
+
if (!sizeValue.size) {
|
|
390
|
+
setValue(defaultValue);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
384
393
|
return /* @__PURE__ */ React7.createElement(
|
|
385
|
-
|
|
394
|
+
import_editor_controls3.UnstableSizeField,
|
|
386
395
|
{
|
|
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
|
-
})
|
|
396
|
+
units: [DEFAULT_UNIT],
|
|
397
|
+
value: sizeValue,
|
|
398
|
+
onChange: handleChange,
|
|
399
|
+
onBlur: handleBlur
|
|
400
|
+
}
|
|
396
401
|
);
|
|
397
402
|
}
|
|
403
|
+
var toSizeValue = (value) => {
|
|
404
|
+
return import_editor_props.sizePropTypeUtil.create({
|
|
405
|
+
size: Number(value),
|
|
406
|
+
unit: DEFAULT_UNIT
|
|
407
|
+
}).value;
|
|
408
|
+
};
|
|
398
409
|
|
|
399
410
|
// src/components/interaction-details.tsx
|
|
400
411
|
var DEFAULT_VALUES = {
|
|
@@ -402,14 +413,36 @@ var DEFAULT_VALUES = {
|
|
|
402
413
|
effect: "fade",
|
|
403
414
|
type: "in",
|
|
404
415
|
direction: "",
|
|
405
|
-
duration:
|
|
416
|
+
duration: 600,
|
|
406
417
|
delay: 0,
|
|
407
418
|
replay: false,
|
|
408
419
|
relativeTo: "viewport",
|
|
409
420
|
offsetTop: 15,
|
|
410
421
|
offsetBottom: 85
|
|
411
422
|
};
|
|
412
|
-
var
|
|
423
|
+
var TRIGGERS_WITHOUT_REPLAY = ["load", "scrollOn"];
|
|
424
|
+
var controlVisibilityConfig = {
|
|
425
|
+
replay: (values) => !TRIGGERS_WITHOUT_REPLAY.includes(values.trigger),
|
|
426
|
+
relativeTo: (values) => values.trigger === "scrollOn",
|
|
427
|
+
offsetTop: (values) => values.trigger === "scrollOn",
|
|
428
|
+
offsetBottom: (values) => values.trigger === "scrollOn",
|
|
429
|
+
duration: (values) => {
|
|
430
|
+
const isRelativeToVisible = values.trigger === "scrollOn";
|
|
431
|
+
return !isRelativeToVisible;
|
|
432
|
+
},
|
|
433
|
+
delay: (values) => {
|
|
434
|
+
const isRelativeToVisible = values.trigger === "scrollOn";
|
|
435
|
+
return !isRelativeToVisible;
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
function useControlComponent(controlName, isVisible = true) {
|
|
439
|
+
return (0, import_react5.useMemo)(() => {
|
|
440
|
+
if (!isVisible) {
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
return getInteractionsControl(controlName)?.component ?? null;
|
|
444
|
+
}, [controlName, isVisible]);
|
|
445
|
+
}
|
|
413
446
|
var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
414
447
|
const trigger = extractString(interaction.trigger, DEFAULT_VALUES.trigger);
|
|
415
448
|
const effect = extractString(interaction.animation.value.effect, DEFAULT_VALUES.effect);
|
|
@@ -424,35 +457,29 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
424
457
|
interaction.animation.value.config?.value.offsetBottom,
|
|
425
458
|
DEFAULT_VALUES.offsetBottom
|
|
426
459
|
);
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
const OffsetBottomControl = (0, import_react4.useMemo)(() => {
|
|
451
|
-
if (!shouldShowRelativeTo) {
|
|
452
|
-
return null;
|
|
453
|
-
}
|
|
454
|
-
return getInteractionsControl("offsetBottom")?.component ?? null;
|
|
455
|
-
}, [shouldShowRelativeTo]);
|
|
460
|
+
const interactionValues = {
|
|
461
|
+
trigger,
|
|
462
|
+
effect,
|
|
463
|
+
type,
|
|
464
|
+
direction,
|
|
465
|
+
duration,
|
|
466
|
+
delay,
|
|
467
|
+
replay,
|
|
468
|
+
relativeTo,
|
|
469
|
+
offsetTop,
|
|
470
|
+
offsetBottom
|
|
471
|
+
};
|
|
472
|
+
const TriggerControl = useControlComponent("trigger", true);
|
|
473
|
+
const ReplayControl = useControlComponent("replay", controlVisibilityConfig.replay(interactionValues));
|
|
474
|
+
const RelativeToControl = useControlComponent(
|
|
475
|
+
"relativeTo",
|
|
476
|
+
controlVisibilityConfig.relativeTo(interactionValues)
|
|
477
|
+
);
|
|
478
|
+
const OffsetTopControl = useControlComponent("offsetTop", controlVisibilityConfig.offsetTop(interactionValues));
|
|
479
|
+
const OffsetBottomControl = useControlComponent(
|
|
480
|
+
"offsetBottom",
|
|
481
|
+
controlVisibilityConfig.offsetBottom(interactionValues)
|
|
482
|
+
);
|
|
456
483
|
const resolveDirection = (hasDirection, newEffect, newDirection) => {
|
|
457
484
|
if (newEffect === "slide" && !newDirection) {
|
|
458
485
|
return "top";
|
|
@@ -487,68 +514,71 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
|
|
|
487
514
|
onPlayInteraction(interactionId);
|
|
488
515
|
}, 0);
|
|
489
516
|
};
|
|
490
|
-
return /* @__PURE__ */ React8.createElement(
|
|
517
|
+
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(
|
|
491
518
|
ReplayControl,
|
|
492
519
|
{
|
|
493
520
|
value: replay,
|
|
494
521
|
onChange: (v) => updateInteraction({ replay: v }),
|
|
495
522
|
disabled: true
|
|
496
523
|
}
|
|
497
|
-
))), /* @__PURE__ */ React8.createElement(
|
|
524
|
+
))), /* @__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(
|
|
498
525
|
Direction,
|
|
499
526
|
{
|
|
500
527
|
value: direction,
|
|
501
528
|
onChange: (v) => updateInteraction({ direction: v }),
|
|
502
529
|
interactionType: type
|
|
503
530
|
}
|
|
504
|
-
)), /* @__PURE__ */ React8.createElement(Field, { label: (0,
|
|
531
|
+
)), controlVisibilityConfig.duration(interactionValues) && /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Duration", "elementor") }, /* @__PURE__ */ React8.createElement(
|
|
505
532
|
TimeFrameIndicator,
|
|
506
533
|
{
|
|
507
534
|
value: String(duration),
|
|
508
|
-
onChange: (v) => updateInteraction({ duration: parseInt(v, 10) })
|
|
535
|
+
onChange: (v) => updateInteraction({ duration: parseInt(v, 10) }),
|
|
536
|
+
defaultValue: DEFAULT_VALUES.duration
|
|
509
537
|
}
|
|
510
|
-
)), /* @__PURE__ */ React8.createElement(Field, { label: (0,
|
|
538
|
+
)), controlVisibilityConfig.delay(interactionValues) && /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Delay", "elementor") }, /* @__PURE__ */ React8.createElement(
|
|
511
539
|
TimeFrameIndicator,
|
|
512
540
|
{
|
|
513
541
|
value: String(delay),
|
|
514
|
-
onChange: (v) => updateInteraction({ delay: parseInt(v, 10) })
|
|
542
|
+
onChange: (v) => updateInteraction({ delay: parseInt(v, 10) }),
|
|
543
|
+
defaultValue: DEFAULT_VALUES.delay
|
|
515
544
|
}
|
|
516
|
-
))),
|
|
545
|
+
))), 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(
|
|
517
546
|
RelativeToControl,
|
|
518
547
|
{
|
|
519
548
|
value: relativeTo,
|
|
520
549
|
onChange: (v) => updateInteraction({ relativeTo: v })
|
|
521
550
|
}
|
|
522
|
-
)), OffsetTopControl && /* @__PURE__ */ React8.createElement(Field, { label: (0,
|
|
551
|
+
)), OffsetTopControl && /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Offset Top", "elementor") }, /* @__PURE__ */ React8.createElement(
|
|
523
552
|
OffsetTopControl,
|
|
524
553
|
{
|
|
525
554
|
value: String(offsetTop),
|
|
526
555
|
onChange: (v) => updateInteraction({ offsetTop: parseInt(v, 10) })
|
|
527
556
|
}
|
|
528
|
-
)), OffsetBottomControl && /* @__PURE__ */ React8.createElement(Field, { label: (0,
|
|
557
|
+
)), OffsetBottomControl && /* @__PURE__ */ React8.createElement(Field, { label: (0, import_i18n5.__)("Offset Bottom", "elementor") }, /* @__PURE__ */ React8.createElement(
|
|
529
558
|
OffsetBottomControl,
|
|
530
559
|
{
|
|
531
560
|
value: String(offsetBottom),
|
|
532
561
|
onChange: (v) => updateInteraction({ offsetBottom: parseInt(v, 10) })
|
|
533
562
|
}
|
|
534
|
-
))), /* @__PURE__ */ React8.createElement(
|
|
563
|
+
))), /* @__PURE__ */ React8.createElement(import_ui3.Divider, null)));
|
|
535
564
|
};
|
|
536
565
|
function Field({ label, children }) {
|
|
537
|
-
return /* @__PURE__ */ React8.createElement(
|
|
566
|
+
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)));
|
|
538
567
|
}
|
|
539
568
|
|
|
540
569
|
// src/components/interactions-list.tsx
|
|
541
570
|
var MAX_NUMBER_OF_INTERACTIONS = 5;
|
|
571
|
+
var InteractionItemContext = (0, import_react6.createContext)(null);
|
|
542
572
|
function InteractionsList(props) {
|
|
543
573
|
const { interactions, onSelectInteractions, onPlayInteraction, triggerCreateOnShowEmpty } = props;
|
|
544
|
-
const hasInitializedRef = (0,
|
|
545
|
-
const handleUpdateInteractions = (0,
|
|
574
|
+
const hasInitializedRef = (0, import_react6.useRef)(false);
|
|
575
|
+
const handleUpdateInteractions = (0, import_react6.useCallback)(
|
|
546
576
|
(newInteractions) => {
|
|
547
577
|
onSelectInteractions(newInteractions);
|
|
548
578
|
},
|
|
549
579
|
[onSelectInteractions]
|
|
550
580
|
);
|
|
551
|
-
(0,
|
|
581
|
+
(0, import_react6.useEffect)(() => {
|
|
552
582
|
if (triggerCreateOnShowEmpty && !hasInitializedRef.current && (!interactions.items || interactions.items?.length === 0)) {
|
|
553
583
|
hasInitializedRef.current = true;
|
|
554
584
|
const newState = {
|
|
@@ -558,14 +588,14 @@ function InteractionsList(props) {
|
|
|
558
588
|
handleUpdateInteractions(newState);
|
|
559
589
|
}
|
|
560
590
|
}, [triggerCreateOnShowEmpty, interactions.items, handleUpdateInteractions]);
|
|
561
|
-
const isMaxNumberOfInteractionsReached = (0,
|
|
591
|
+
const isMaxNumberOfInteractionsReached = (0, import_react6.useMemo)(() => {
|
|
562
592
|
return interactions.items?.length >= MAX_NUMBER_OF_INTERACTIONS;
|
|
563
593
|
}, [interactions.items?.length]);
|
|
564
|
-
const infotipContent = isMaxNumberOfInteractionsReached ? /* @__PURE__ */ React9.createElement(
|
|
594
|
+
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.__)(
|
|
565
595
|
"You've reached the limit of 5 interactions for this element. Please remove an interaction before creating a new one.",
|
|
566
596
|
"elementor"
|
|
567
597
|
))) : void 0;
|
|
568
|
-
const handleRepeaterChange = (0,
|
|
598
|
+
const handleRepeaterChange = (0, import_react6.useCallback)(
|
|
569
599
|
(newItems) => {
|
|
570
600
|
handleUpdateInteractions({
|
|
571
601
|
...interactions,
|
|
@@ -574,7 +604,7 @@ function InteractionsList(props) {
|
|
|
574
604
|
},
|
|
575
605
|
[interactions, handleUpdateInteractions]
|
|
576
606
|
);
|
|
577
|
-
const handleInteractionChange = (0,
|
|
607
|
+
const handleInteractionChange = (0, import_react6.useCallback)(
|
|
578
608
|
(index, newInteractionValue) => {
|
|
579
609
|
const newItems = structuredClone(interactions.items);
|
|
580
610
|
newItems[index] = {
|
|
@@ -588,12 +618,19 @@ function InteractionsList(props) {
|
|
|
588
618
|
},
|
|
589
619
|
[interactions, handleUpdateInteractions]
|
|
590
620
|
);
|
|
591
|
-
|
|
592
|
-
|
|
621
|
+
const contextValue = (0, import_react6.useMemo)(
|
|
622
|
+
() => ({
|
|
623
|
+
onInteractionChange: handleInteractionChange,
|
|
624
|
+
onPlayInteraction
|
|
625
|
+
}),
|
|
626
|
+
[handleInteractionChange, onPlayInteraction]
|
|
627
|
+
);
|
|
628
|
+
return /* @__PURE__ */ React9.createElement(InteractionItemContext.Provider, { value: contextValue }, /* @__PURE__ */ React9.createElement(
|
|
629
|
+
import_editor_controls5.Repeater,
|
|
593
630
|
{
|
|
594
631
|
openOnAdd: true,
|
|
595
632
|
openItem: triggerCreateOnShowEmpty ? 0 : void 0,
|
|
596
|
-
label: (0,
|
|
633
|
+
label: (0, import_i18n6.__)("Interactions", "elementor"),
|
|
597
634
|
values: interactions.items,
|
|
598
635
|
setValues: handleRepeaterChange,
|
|
599
636
|
showDuplicate: false,
|
|
@@ -605,21 +642,11 @@ function InteractionsList(props) {
|
|
|
605
642
|
initialValues: createDefaultInteractionItem(),
|
|
606
643
|
Label: ({ value }) => buildDisplayLabel(value.value),
|
|
607
644
|
Icon: () => null,
|
|
608
|
-
Content
|
|
609
|
-
|
|
645
|
+
Content,
|
|
646
|
+
actions: (value) => /* @__PURE__ */ React9.createElement(import_ui4.Tooltip, { key: "preview", placement: "top", title: (0, import_i18n6.__)("Preview", "elementor") }, /* @__PURE__ */ React9.createElement(
|
|
647
|
+
import_ui4.IconButton,
|
|
610
648
|
{
|
|
611
|
-
|
|
612
|
-
interaction: value.value,
|
|
613
|
-
onChange: (newInteractionValue) => {
|
|
614
|
-
handleInteractionChange(index, newInteractionValue);
|
|
615
|
-
},
|
|
616
|
-
onPlayInteraction
|
|
617
|
-
}
|
|
618
|
-
),
|
|
619
|
-
actions: (value) => /* @__PURE__ */ React9.createElement(import_ui5.Tooltip, { key: "preview", placement: "top", title: (0, import_i18n7.__)("Preview", "elementor") }, /* @__PURE__ */ React9.createElement(
|
|
620
|
-
import_ui5.IconButton,
|
|
621
|
-
{
|
|
622
|
-
"aria-label": (0, import_i18n7.__)("Play interaction", "elementor"),
|
|
649
|
+
"aria-label": (0, import_i18n6.__)("Play interaction", "elementor"),
|
|
623
650
|
size: "tiny",
|
|
624
651
|
onClick: () => onPlayInteraction(extractString(value.value.interaction_id))
|
|
625
652
|
},
|
|
@@ -627,8 +654,32 @@ function InteractionsList(props) {
|
|
|
627
654
|
))
|
|
628
655
|
}
|
|
629
656
|
}
|
|
630
|
-
);
|
|
657
|
+
));
|
|
631
658
|
}
|
|
659
|
+
var Content = ({ index, value }) => {
|
|
660
|
+
const context = (0, import_react6.useContext)(InteractionItemContext);
|
|
661
|
+
const handleChange = (0, import_react6.useCallback)(
|
|
662
|
+
(newInteractionValue) => {
|
|
663
|
+
context?.onInteractionChange(index, newInteractionValue);
|
|
664
|
+
},
|
|
665
|
+
[context, index]
|
|
666
|
+
);
|
|
667
|
+
const handlePlayInteraction = (0, import_react6.useCallback)(
|
|
668
|
+
(interactionId) => {
|
|
669
|
+
context?.onPlayInteraction(interactionId);
|
|
670
|
+
},
|
|
671
|
+
[context]
|
|
672
|
+
);
|
|
673
|
+
return /* @__PURE__ */ React9.createElement(
|
|
674
|
+
InteractionDetails,
|
|
675
|
+
{
|
|
676
|
+
key: index,
|
|
677
|
+
interaction: value.value,
|
|
678
|
+
onChange: handleChange,
|
|
679
|
+
onPlayInteraction: handlePlayInteraction
|
|
680
|
+
}
|
|
681
|
+
);
|
|
682
|
+
};
|
|
632
683
|
|
|
633
684
|
// src/components/interactions-tab.tsx
|
|
634
685
|
var InteractionsTab = ({ elementId }) => {
|
|
@@ -636,7 +687,7 @@ var InteractionsTab = ({ elementId }) => {
|
|
|
636
687
|
};
|
|
637
688
|
function InteractionsTabContent({ elementId }) {
|
|
638
689
|
const existingInteractions = (0, import_editor_elements2.useElementInteractions)(elementId);
|
|
639
|
-
const firstInteractionState = (0,
|
|
690
|
+
const firstInteractionState = (0, import_react7.useState)(false);
|
|
640
691
|
const hasInteractions = existingInteractions?.items?.length || firstInteractionState[0];
|
|
641
692
|
return /* @__PURE__ */ React10.createElement(import_session.SessionStorageProvider, { prefix: elementId }, hasInteractions ? /* @__PURE__ */ React10.createElement(InteractionsProvider, { elementId }, /* @__PURE__ */ React10.createElement(InteractionsContent, { firstInteractionState })) : /* @__PURE__ */ React10.createElement(
|
|
642
693
|
EmptyState,
|
|
@@ -651,7 +702,7 @@ function InteractionsContent({
|
|
|
651
702
|
firstInteractionState
|
|
652
703
|
}) {
|
|
653
704
|
const { interactions, setInteractions, playInteractions } = useInteractionsContext();
|
|
654
|
-
const applyInteraction = (0,
|
|
705
|
+
const applyInteraction = (0, import_react7.useCallback)(
|
|
655
706
|
(newInteractions) => {
|
|
656
707
|
firstInteractionState[1](false);
|
|
657
708
|
if (!newInteractions) {
|
|
@@ -662,7 +713,7 @@ function InteractionsContent({
|
|
|
662
713
|
},
|
|
663
714
|
[setInteractions, firstInteractionState]
|
|
664
715
|
);
|
|
665
|
-
return /* @__PURE__ */ React10.createElement(
|
|
716
|
+
return /* @__PURE__ */ React10.createElement(import_ui5.Stack, { sx: { m: 1, p: 1.5 }, gap: 2 }, /* @__PURE__ */ React10.createElement(
|
|
666
717
|
InteractionsList,
|
|
667
718
|
{
|
|
668
719
|
triggerCreateOnShowEmpty: firstInteractionState[0],
|
|
@@ -789,19 +840,19 @@ var documentElementsInteractionsProvider = createInteractionsProvider({
|
|
|
789
840
|
|
|
790
841
|
// src/components/controls/trigger.tsx
|
|
791
842
|
var React11 = __toESM(require("react"));
|
|
792
|
-
var
|
|
793
|
-
var
|
|
794
|
-
var
|
|
843
|
+
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
844
|
+
var import_ui6 = require("@elementor/ui");
|
|
845
|
+
var import_i18n7 = require("@wordpress/i18n");
|
|
795
846
|
function Trigger({ value, onChange }) {
|
|
796
847
|
const availableTriggers = Object.entries({
|
|
797
|
-
load: (0,
|
|
798
|
-
scrollIn: (0,
|
|
848
|
+
load: (0, import_i18n7.__)("Page load", "elementor"),
|
|
849
|
+
scrollIn: (0, import_i18n7.__)("Scroll into view", "elementor")
|
|
799
850
|
}).map(([key, label]) => ({
|
|
800
851
|
key,
|
|
801
852
|
label
|
|
802
853
|
}));
|
|
803
854
|
return /* @__PURE__ */ React11.createElement(
|
|
804
|
-
|
|
855
|
+
import_ui6.Select,
|
|
805
856
|
{
|
|
806
857
|
fullWidth: true,
|
|
807
858
|
displayEmpty: true,
|
|
@@ -810,7 +861,7 @@ function Trigger({ value, onChange }) {
|
|
|
810
861
|
value
|
|
811
862
|
},
|
|
812
863
|
availableTriggers.map((trigger) => {
|
|
813
|
-
return /* @__PURE__ */ React11.createElement(
|
|
864
|
+
return /* @__PURE__ */ React11.createElement(import_editor_ui2.MenuListItem, { key: trigger.key, value: trigger.key }, trigger.label);
|
|
814
865
|
})
|
|
815
866
|
);
|
|
816
867
|
}
|