@elementor/editor-interactions 4.0.0-524 → 4.0.0-526

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.mjs CHANGED
@@ -25,8 +25,8 @@ var EmptyState = ({ onCreateInteraction }) => {
25
25
  };
26
26
 
27
27
  // src/components/interactions-tab.tsx
28
- import * as React12 from "react";
29
- import { useCallback as useCallback5, useState as useState2 } from "react";
28
+ import * as React13 from "react";
29
+ import { useCallback as useCallback5, useState as useState3 } from "react";
30
30
  import { useElementInteractions as useElementInteractions2 } from "@elementor/editor-elements";
31
31
  import { SessionStorageProvider } from "@elementor/session";
32
32
  import { Stack as Stack2 } from "@elementor/ui";
@@ -91,12 +91,12 @@ var PopupStateProvider = ({ children }) => {
91
91
  };
92
92
 
93
93
  // src/components/interactions-list.tsx
94
- import * as React11 from "react";
94
+ import * as React12 from "react";
95
95
  import { useCallback as useCallback4, useEffect as useEffect2, useMemo as useMemo3, useRef } from "react";
96
96
  import { Repeater } from "@elementor/editor-controls";
97
97
  import { InfoCircleFilledIcon, PlayerPlayIcon } from "@elementor/icons";
98
98
  import { Alert, AlertTitle, Box, IconButton, Tooltip } from "@elementor/ui";
99
- import { __ as __6 } from "@wordpress/i18n";
99
+ import { __ as __8 } from "@wordpress/i18n";
100
100
 
101
101
  // src/contexts/interactions-item-context.tsx
102
102
  import * as React4 from "react";
@@ -161,6 +161,19 @@ var createConfig = ({
161
161
  var extractBoolean = (prop, fallback = false) => {
162
162
  return prop?.value ?? fallback;
163
163
  };
164
+ var createExcludedBreakpoints = (breakpoints) => ({
165
+ $$type: "excluded-breakpoints",
166
+ value: breakpoints.map(createString)
167
+ });
168
+ var createInteractionBreakpoints = (excluded) => ({
169
+ $$type: "interaction-breakpoints",
170
+ value: {
171
+ excluded: createExcludedBreakpoints(excluded)
172
+ }
173
+ });
174
+ var extractExcludedBreakpoints = (breakpoints) => {
175
+ return breakpoints?.value.excluded.value.map((bp) => bp.value) ?? [];
176
+ };
164
177
  var createAnimationPreset = ({
165
178
  effect,
166
179
  type,
@@ -200,7 +213,8 @@ var createInteractionItem = ({
200
213
  easing = "easeIn",
201
214
  relativeTo,
202
215
  offsetTop,
203
- offsetBottom
216
+ offsetBottom,
217
+ excludedBreakpoints
204
218
  }) => ({
205
219
  $$type: "interaction-item",
206
220
  value: {
@@ -217,7 +231,10 @@ var createInteractionItem = ({
217
231
  relativeTo,
218
232
  offsetTop,
219
233
  offsetBottom
220
- })
234
+ }),
235
+ ...excludedBreakpoints && excludedBreakpoints.length > 0 && {
236
+ breakpoints: createInteractionBreakpoints(excludedBreakpoints)
237
+ }
221
238
  }
222
239
  });
223
240
  var createDefaultInteractionItem = () => {
@@ -258,8 +275,10 @@ var buildDisplayLabel = (item) => {
258
275
  };
259
276
 
260
277
  // src/components/interactions-list-item.tsx
261
- import * as React10 from "react";
278
+ import * as React11 from "react";
262
279
  import { useCallback as useCallback3 } from "react";
280
+ import { Divider as Divider2, Tab, TabPanel, Tabs, useTabs } from "@elementor/ui";
281
+ import { __ as __7 } from "@wordpress/i18n";
263
282
 
264
283
  // src/components/interaction-details.tsx
265
284
  import * as React9 from "react";
@@ -583,8 +602,56 @@ function Field({ label, children }) {
583
602
  return /* @__PURE__ */ React9.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React9.createElement(PopoverGridContainer, null, /* @__PURE__ */ React9.createElement(Grid, { item: true, xs: 6 }, /* @__PURE__ */ React9.createElement(ControlFormLabel, null, label)), /* @__PURE__ */ React9.createElement(Grid, { item: true, xs: 6 }, children)));
584
603
  }
585
604
 
605
+ // src/components/interaction-settings.tsx
606
+ import * as React10 from "react";
607
+ import { useState as useState2 } from "react";
608
+ import { ControlFormLabel as ControlFormLabel2, PopoverContent as PopoverContent2 } from "@elementor/editor-controls";
609
+ import { Autocomplete, Grid as Grid2, TextField } from "@elementor/ui";
610
+ import { __ as __6 } from "@wordpress/i18n";
611
+ var availableBreakpoints = [
612
+ { label: __6("Desktop", "elementor"), value: "desktop" },
613
+ { label: __6("Tablet", "elementor"), value: "tablet" },
614
+ { label: __6("Mobile", "elementor"), value: "mobile" }
615
+ ];
616
+ var InteractionSettings = ({ interaction, onChange }) => {
617
+ const [selectedBreakpoints, setSelectedBreakpoints] = useState2(() => {
618
+ const excluded = extractExcludedBreakpoints(interaction.breakpoints);
619
+ return availableBreakpoints.filter(({ value }) => {
620
+ return !excluded.includes(value);
621
+ });
622
+ });
623
+ const handleBreakpointChange = (_, newValue) => {
624
+ setSelectedBreakpoints(newValue);
625
+ const selectedValues = newValue.map((option) => option.value);
626
+ const newExcluded = availableBreakpoints.filter((bp) => !selectedValues.includes(bp.value)).map((bp) => bp.value);
627
+ const updatedInteraction = {
628
+ ...interaction,
629
+ ...newExcluded.length > 0 && {
630
+ breakpoints: createInteractionBreakpoints(newExcluded)
631
+ }
632
+ };
633
+ if (newExcluded.length === 0) {
634
+ delete updatedInteraction.breakpoints;
635
+ }
636
+ onChange(updatedInteraction);
637
+ };
638
+ return /* @__PURE__ */ React10.createElement(PopoverContent2, { p: 1.5 }, /* @__PURE__ */ React10.createElement(Grid2, { container: true, spacing: 1.5 }, /* @__PURE__ */ React10.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(ControlFormLabel2, { sx: { width: "100%" } }, __6("Trigger on", "elementor"))), /* @__PURE__ */ React10.createElement(Grid2, { id: "interactions-settings-breakpoints", item: true, xs: 12, sx: { paddingTop: 0 } }, /* @__PURE__ */ React10.createElement(
639
+ Autocomplete,
640
+ {
641
+ fullWidth: true,
642
+ multiple: true,
643
+ value: selectedBreakpoints,
644
+ onChange: handleBreakpointChange,
645
+ size: "tiny",
646
+ options: availableBreakpoints,
647
+ renderInput: (params) => /* @__PURE__ */ React10.createElement(TextField, { ...params })
648
+ }
649
+ ))));
650
+ };
651
+
586
652
  // src/components/interactions-list-item.tsx
587
653
  var InteractionsListItem = ({ index, value }) => {
654
+ const { getTabsProps, getTabProps, getTabPanelProps } = useTabs("details");
588
655
  const context = useInteractionItemContext();
589
656
  const handleChange = useCallback3(
590
657
  (newInteractionValue) => {
@@ -598,15 +665,32 @@ var InteractionsListItem = ({ index, value }) => {
598
665
  },
599
666
  [context]
600
667
  );
601
- return /* @__PURE__ */ React10.createElement(
668
+ return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(
669
+ Tabs,
670
+ {
671
+ size: "small",
672
+ variant: "fullWidth",
673
+ "aria-label": __7("Interaction", "elementor"),
674
+ ...getTabsProps()
675
+ },
676
+ /* @__PURE__ */ React11.createElement(Tab, { label: __7("Details", "elementor"), ...getTabProps("details") }),
677
+ /* @__PURE__ */ React11.createElement(Tab, { label: __7("Settings", "elementor"), ...getTabProps("settings") })
678
+ ), /* @__PURE__ */ React11.createElement(Divider2, null), /* @__PURE__ */ React11.createElement(TabPanel, { sx: { p: 0 }, ...getTabPanelProps("details") }, /* @__PURE__ */ React11.createElement(
602
679
  InteractionDetails,
603
680
  {
604
- key: index,
681
+ key: `details-${index}`,
605
682
  interaction: value.value,
606
683
  onChange: handleChange,
607
684
  onPlayInteraction: handlePlayInteraction
608
685
  }
609
- );
686
+ )), /* @__PURE__ */ React11.createElement(TabPanel, { sx: { p: 0 }, ...getTabPanelProps("settings") }, /* @__PURE__ */ React11.createElement(
687
+ InteractionSettings,
688
+ {
689
+ key: `settings-${index}`,
690
+ interaction: value.value,
691
+ onChange: handleChange
692
+ }
693
+ )));
610
694
  };
611
695
 
612
696
  // src/components/interactions-list.tsx
@@ -633,7 +717,7 @@ function InteractionsList(props) {
633
717
  const isMaxNumberOfInteractionsReached = useMemo3(() => {
634
718
  return interactions.items?.length >= MAX_NUMBER_OF_INTERACTIONS;
635
719
  }, [interactions.items?.length]);
636
- const infotipContent = isMaxNumberOfInteractionsReached ? /* @__PURE__ */ React11.createElement(Alert, { color: "secondary", icon: /* @__PURE__ */ React11.createElement(InfoCircleFilledIcon, null), size: "small" }, /* @__PURE__ */ React11.createElement(AlertTitle, null, __6("Interactions", "elementor")), /* @__PURE__ */ React11.createElement(Box, { component: "span" }, __6(
720
+ const infotipContent = isMaxNumberOfInteractionsReached ? /* @__PURE__ */ React12.createElement(Alert, { color: "secondary", icon: /* @__PURE__ */ React12.createElement(InfoCircleFilledIcon, null), size: "small" }, /* @__PURE__ */ React12.createElement(AlertTitle, null, __8("Interactions", "elementor")), /* @__PURE__ */ React12.createElement(Box, { component: "span" }, __8(
637
721
  "You've reached the limit of 5 interactions for this element. Please remove an interaction before creating a new one.",
638
722
  "elementor"
639
723
  ))) : void 0;
@@ -667,12 +751,12 @@ function InteractionsList(props) {
667
751
  }),
668
752
  [handleInteractionChange, onPlayInteraction]
669
753
  );
670
- return /* @__PURE__ */ React11.createElement(InteractionItemContextProvider, { value: contextValue }, /* @__PURE__ */ React11.createElement(
754
+ return /* @__PURE__ */ React12.createElement(InteractionItemContextProvider, { value: contextValue }, /* @__PURE__ */ React12.createElement(
671
755
  Repeater,
672
756
  {
673
757
  openOnAdd: true,
674
758
  openItem: triggerCreateOnShowEmpty ? 0 : void 0,
675
- label: __6("Interactions", "elementor"),
759
+ label: __8("Interactions", "elementor"),
676
760
  values: interactions.items,
677
761
  setValues: handleRepeaterChange,
678
762
  showDuplicate: false,
@@ -685,14 +769,14 @@ function InteractionsList(props) {
685
769
  Label: ({ value }) => buildDisplayLabel(value.value),
686
770
  Icon: () => null,
687
771
  Content: InteractionsListItem,
688
- actions: (value) => /* @__PURE__ */ React11.createElement(Tooltip, { key: "preview", placement: "top", title: __6("Preview", "elementor") }, /* @__PURE__ */ React11.createElement(
772
+ actions: (value) => /* @__PURE__ */ React12.createElement(Tooltip, { key: "preview", placement: "top", title: __8("Preview", "elementor") }, /* @__PURE__ */ React12.createElement(
689
773
  IconButton,
690
774
  {
691
- "aria-label": __6("Play interaction", "elementor"),
775
+ "aria-label": __8("Play interaction", "elementor"),
692
776
  size: "tiny",
693
777
  onClick: () => onPlayInteraction(extractString(value.value.interaction_id))
694
778
  },
695
- /* @__PURE__ */ React11.createElement(PlayerPlayIcon, { fontSize: "tiny" })
779
+ /* @__PURE__ */ React12.createElement(PlayerPlayIcon, { fontSize: "tiny" })
696
780
  ))
697
781
  }
698
782
  }
@@ -701,13 +785,13 @@ function InteractionsList(props) {
701
785
 
702
786
  // src/components/interactions-tab.tsx
703
787
  var InteractionsTab = ({ elementId }) => {
704
- return /* @__PURE__ */ React12.createElement(PopupStateProvider, null, /* @__PURE__ */ React12.createElement(InteractionsTabContent, { elementId }));
788
+ return /* @__PURE__ */ React13.createElement(PopupStateProvider, null, /* @__PURE__ */ React13.createElement(InteractionsTabContent, { elementId }));
705
789
  };
706
790
  function InteractionsTabContent({ elementId }) {
707
791
  const existingInteractions = useElementInteractions2(elementId);
708
- const firstInteractionState = useState2(false);
792
+ const firstInteractionState = useState3(false);
709
793
  const hasInteractions = existingInteractions?.items?.length || firstInteractionState[0];
710
- return /* @__PURE__ */ React12.createElement(SessionStorageProvider, { prefix: elementId }, hasInteractions ? /* @__PURE__ */ React12.createElement(InteractionsProvider, { elementId }, /* @__PURE__ */ React12.createElement(InteractionsContent, { firstInteractionState })) : /* @__PURE__ */ React12.createElement(
794
+ return /* @__PURE__ */ React13.createElement(SessionStorageProvider, { prefix: elementId }, hasInteractions ? /* @__PURE__ */ React13.createElement(InteractionsProvider, { elementId }, /* @__PURE__ */ React13.createElement(InteractionsContent, { firstInteractionState })) : /* @__PURE__ */ React13.createElement(
711
795
  EmptyState,
712
796
  {
713
797
  onCreateInteraction: () => {
@@ -731,7 +815,7 @@ function InteractionsContent({
731
815
  },
732
816
  [setInteractions, firstInteractionState]
733
817
  );
734
- return /* @__PURE__ */ React12.createElement(Stack2, { sx: { m: 1, p: 1.5 }, gap: 2 }, /* @__PURE__ */ React12.createElement(
818
+ return /* @__PURE__ */ React13.createElement(Stack2, { sx: { m: 1, p: 1.5 }, gap: 2 }, /* @__PURE__ */ React13.createElement(
735
819
  InteractionsList,
736
820
  {
737
821
  triggerCreateOnShowEmpty: firstInteractionState[0],
@@ -857,18 +941,18 @@ var documentElementsInteractionsProvider = createInteractionsProvider({
857
941
  });
858
942
 
859
943
  // src/components/controls/easing.tsx
860
- import * as React13 from "react";
944
+ import * as React14 from "react";
861
945
  import { MenuListItem as MenuListItem2 } from "@elementor/editor-ui";
862
946
  import { Select as Select2 } from "@elementor/ui";
863
- import { __ as __7 } from "@wordpress/i18n";
947
+ import { __ as __9 } from "@wordpress/i18n";
864
948
  var EASING_OPTIONS = {
865
- easeIn: __7("Ease In", "elementor"),
866
- easeInOut: __7("Ease In Out", "elementor"),
867
- easeOut: __7("Ease Out", "elementor"),
868
- backIn: __7("Back In", "elementor"),
869
- backInOut: __7("Back In Out", "elementor"),
870
- backOut: __7("Back Out", "elementor"),
871
- linear: __7("Linear", "elementor")
949
+ easeIn: __9("Ease In", "elementor"),
950
+ easeInOut: __9("Ease In Out", "elementor"),
951
+ easeOut: __9("Ease Out", "elementor"),
952
+ backIn: __9("Back In", "elementor"),
953
+ backInOut: __9("Back In Out", "elementor"),
954
+ backOut: __9("Back Out", "elementor"),
955
+ linear: __9("Linear", "elementor")
872
956
  };
873
957
  var DEFAULT_EASING = "easeIn";
874
958
  function Easing({}) {
@@ -876,27 +960,27 @@ function Easing({}) {
876
960
  key,
877
961
  label
878
962
  }));
879
- return /* @__PURE__ */ React13.createElement(Select2, { value: DEFAULT_EASING, onChange: () => {
963
+ return /* @__PURE__ */ React14.createElement(Select2, { value: DEFAULT_EASING, onChange: () => {
880
964
  }, fullWidth: true, displayEmpty: true, size: "tiny" }, availableOptions.map((option) => {
881
965
  const isDisabled = DEFAULT_EASING !== option.key;
882
- return /* @__PURE__ */ React13.createElement(MenuListItem2, { key: option.key, value: option.key, disabled: isDisabled }, option.label);
966
+ return /* @__PURE__ */ React14.createElement(MenuListItem2, { key: option.key, value: option.key, disabled: isDisabled }, option.label);
883
967
  }));
884
968
  }
885
969
 
886
970
  // src/components/controls/trigger.tsx
887
- import * as React14 from "react";
971
+ import * as React15 from "react";
888
972
  import { MenuListItem as MenuListItem3 } from "@elementor/editor-ui";
889
973
  import { Select as Select3 } from "@elementor/ui";
890
- import { __ as __8 } from "@wordpress/i18n";
974
+ import { __ as __10 } from "@wordpress/i18n";
891
975
  function Trigger({ value, onChange }) {
892
976
  const availableTriggers = Object.entries({
893
- load: __8("Page load", "elementor"),
894
- scrollIn: __8("Scroll into view", "elementor")
977
+ load: __10("Page load", "elementor"),
978
+ scrollIn: __10("Scroll into view", "elementor")
895
979
  }).map(([key, label]) => ({
896
980
  key,
897
981
  label
898
982
  }));
899
- return /* @__PURE__ */ React14.createElement(
983
+ return /* @__PURE__ */ React15.createElement(
900
984
  Select3,
901
985
  {
902
986
  fullWidth: true,
@@ -906,7 +990,7 @@ function Trigger({ value, onChange }) {
906
990
  value
907
991
  },
908
992
  availableTriggers.map((trigger) => {
909
- return /* @__PURE__ */ React14.createElement(MenuListItem3, { key: trigger.key, value: trigger.key }, trigger.label);
993
+ return /* @__PURE__ */ React15.createElement(MenuListItem3, { key: trigger.key, value: trigger.key }, trigger.label);
910
994
  })
911
995
  );
912
996
  }