@elementor/editor-interactions 4.1.0-711 → 4.1.0-713

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
@@ -1364,40 +1364,89 @@ function initPasteInteractionsCommand() {
1364
1364
  // src/components/controls/direction.tsx
1365
1365
  import * as React12 from "react";
1366
1366
  import { useMemo as useMemo4 } from "react";
1367
- import { ToggleButtonGroupUi } from "@elementor/editor-controls";
1367
+ import { StyledToggleButton, StyledToggleButtonGroup } from "@elementor/editor-controls";
1368
1368
  import { ArrowDownSmallIcon, ArrowLeftIcon, ArrowRightIcon, ArrowUpSmallIcon } from "@elementor/icons";
1369
+ import { Tooltip as Tooltip2 } from "@elementor/ui";
1369
1370
  import { __ as __7 } from "@wordpress/i18n";
1371
+ var AXIS = {
1372
+ top: "vertical",
1373
+ bottom: "vertical",
1374
+ left: "horizontal",
1375
+ right: "horizontal"
1376
+ };
1377
+ function parseValue(value) {
1378
+ return value.split("-").filter(Boolean);
1379
+ }
1380
+ function serializeValue(directions) {
1381
+ const vertical = directions.find((d) => d === "top" || d === "bottom");
1382
+ const horizontal = directions.find((d) => d === "left" || d === "right");
1383
+ if (vertical && horizontal) {
1384
+ return `${vertical}-${horizontal}`;
1385
+ }
1386
+ return directions[0] ?? "";
1387
+ }
1388
+ function toggleDirection(current, clicked) {
1389
+ if (current.includes(clicked)) {
1390
+ return current.filter((d) => d !== clicked);
1391
+ }
1392
+ const filtered = current.filter((d) => AXIS[d] !== AXIS[clicked]);
1393
+ return [...filtered, clicked];
1394
+ }
1370
1395
  function Direction({ value, onChange, interactionType }) {
1371
- const options = useMemo4(() => {
1372
- const isIn = interactionType === "in";
1373
- return [
1396
+ const isIn = interactionType === "in";
1397
+ const options = useMemo4(
1398
+ () => [
1374
1399
  {
1375
- value: "top",
1400
+ dir: "top",
1376
1401
  label: isIn ? __7("From top", "elementor") : __7("To top", "elementor"),
1377
- renderContent: ({ size }) => isIn ? /* @__PURE__ */ React12.createElement(ArrowDownSmallIcon, { fontSize: size }) : /* @__PURE__ */ React12.createElement(ArrowUpSmallIcon, { fontSize: size }),
1378
- showTooltip: true
1402
+ Icon: isIn ? ArrowDownSmallIcon : ArrowUpSmallIcon
1379
1403
  },
1380
1404
  {
1381
- value: "bottom",
1382
- label: interactionType === "in" ? __7("From bottom", "elementor") : __7("To bottom", "elementor"),
1383
- renderContent: ({ size }) => isIn ? /* @__PURE__ */ React12.createElement(ArrowUpSmallIcon, { fontSize: size }) : /* @__PURE__ */ React12.createElement(ArrowDownSmallIcon, { fontSize: size }),
1384
- showTooltip: true
1405
+ dir: "bottom",
1406
+ label: isIn ? __7("From bottom", "elementor") : __7("To bottom", "elementor"),
1407
+ Icon: isIn ? ArrowUpSmallIcon : ArrowDownSmallIcon
1385
1408
  },
1386
1409
  {
1387
- value: "left",
1388
- label: interactionType === "in" ? __7("From left", "elementor") : __7("To left", "elementor"),
1389
- renderContent: ({ size }) => isIn ? /* @__PURE__ */ React12.createElement(ArrowRightIcon, { fontSize: size }) : /* @__PURE__ */ React12.createElement(ArrowLeftIcon, { fontSize: size }),
1390
- showTooltip: true
1410
+ dir: "left",
1411
+ label: isIn ? __7("From left", "elementor") : __7("To left", "elementor"),
1412
+ Icon: isIn ? ArrowRightIcon : ArrowLeftIcon
1391
1413
  },
1392
1414
  {
1393
- value: "right",
1394
- label: interactionType === "in" ? __7("From right", "elementor") : __7("To right", "elementor"),
1395
- renderContent: ({ size }) => isIn ? /* @__PURE__ */ React12.createElement(ArrowLeftIcon, { fontSize: size }) : /* @__PURE__ */ React12.createElement(ArrowRightIcon, { fontSize: size }),
1396
- showTooltip: true
1415
+ dir: "right",
1416
+ label: isIn ? __7("From right", "elementor") : __7("To right", "elementor"),
1417
+ Icon: isIn ? ArrowLeftIcon : ArrowRightIcon
1418
+ }
1419
+ ],
1420
+ [isIn]
1421
+ );
1422
+ const selectedDirections = useMemo4(() => parseValue(value), [value]);
1423
+ return /* @__PURE__ */ React12.createElement(
1424
+ StyledToggleButtonGroup,
1425
+ {
1426
+ size: "tiny",
1427
+ justify: "end",
1428
+ sx: {
1429
+ display: "grid",
1430
+ gridTemplateColumns: "repeat(4, minmax(0, 25%))",
1431
+ width: "100%"
1397
1432
  }
1398
- ];
1399
- }, [interactionType]);
1400
- return /* @__PURE__ */ React12.createElement(ToggleButtonGroupUi, { items: options, exclusive: true, onChange, value });
1433
+ },
1434
+ options.map(({ dir, label, Icon }) => /* @__PURE__ */ React12.createElement(Tooltip2, { key: dir, title: label, disableFocusListener: true, placement: "top" }, /* @__PURE__ */ React12.createElement(
1435
+ StyledToggleButton,
1436
+ {
1437
+ value: dir,
1438
+ selected: selectedDirections.includes(dir),
1439
+ "aria-label": label,
1440
+ size: "tiny",
1441
+ isPlaceholder: false,
1442
+ onChange: () => {
1443
+ const next = toggleDirection(selectedDirections, dir);
1444
+ onChange(serializeValue(next));
1445
+ }
1446
+ },
1447
+ /* @__PURE__ */ React12.createElement(Icon, { fontSize: "tiny" })
1448
+ )))
1449
+ );
1401
1450
  }
1402
1451
 
1403
1452
  // src/components/controls/easing.tsx
@@ -1591,7 +1640,7 @@ function Effect({ value, onChange }) {
1591
1640
 
1592
1641
  // src/components/controls/effect-type.tsx
1593
1642
  import * as React17 from "react";
1594
- import { ToggleButtonGroupUi as ToggleButtonGroupUi2 } from "@elementor/editor-controls";
1643
+ import { ToggleButtonGroupUi } from "@elementor/editor-controls";
1595
1644
  import { __ as __12 } from "@wordpress/i18n";
1596
1645
  function EffectType({ value, onChange }) {
1597
1646
  const options = [
@@ -1608,12 +1657,12 @@ function EffectType({ value, onChange }) {
1608
1657
  showTooltip: true
1609
1658
  }
1610
1659
  ];
1611
- return /* @__PURE__ */ React17.createElement(ToggleButtonGroupUi2, { items: options, exclusive: true, onChange, value });
1660
+ return /* @__PURE__ */ React17.createElement(ToggleButtonGroupUi, { items: options, exclusive: true, onChange, value });
1612
1661
  }
1613
1662
 
1614
1663
  // src/components/controls/replay.tsx
1615
1664
  import * as React18 from "react";
1616
- import { ToggleButtonGroupUi as ToggleButtonGroupUi3 } from "@elementor/editor-controls";
1665
+ import { ToggleButtonGroupUi as ToggleButtonGroupUi2 } from "@elementor/editor-controls";
1617
1666
  import { CheckIcon, MinusIcon } from "@elementor/icons";
1618
1667
  import { Box as Box4 } from "@elementor/ui";
1619
1668
  import { __ as __13 } from "@wordpress/i18n";
@@ -1642,7 +1691,7 @@ function Replay({ onChange, anchorRef }) {
1642
1691
  showTooltip: true
1643
1692
  }
1644
1693
  ];
1645
- return /* @__PURE__ */ React18.createElement(Box4, { sx: { display: "grid", alignItems: "center" } }, /* @__PURE__ */ React18.createElement(Box4, { sx: { gridArea: OVERLAY_GRID } }, /* @__PURE__ */ React18.createElement(ToggleButtonGroupUi3, { items: options, exclusive: true, onChange, value: false })), /* @__PURE__ */ React18.createElement(Box4, { sx: { gridArea: OVERLAY_GRID, marginInlineEnd: CHIP_OFFSET, justifySelf: "end" } }, /* @__PURE__ */ React18.createElement(
1694
+ return /* @__PURE__ */ React18.createElement(Box4, { sx: { display: "grid", alignItems: "center" } }, /* @__PURE__ */ React18.createElement(Box4, { sx: { gridArea: OVERLAY_GRID } }, /* @__PURE__ */ React18.createElement(ToggleButtonGroupUi2, { items: options, exclusive: true, onChange, value: false })), /* @__PURE__ */ React18.createElement(Box4, { sx: { gridArea: OVERLAY_GRID, marginInlineEnd: CHIP_OFFSET, justifySelf: "end" } }, /* @__PURE__ */ React18.createElement(
1646
1695
  InteractionsPromotionChip,
1647
1696
  {
1648
1697
  content: __13("Upgrade to run the animation every time its trigger occurs.", "elementor"),
@@ -1740,7 +1789,9 @@ var baseSchema = {
1740
1789
  trigger: z.enum(["load", "scrollIn"]).optional().describe("Event that triggers the animation"),
1741
1790
  effect: z.enum(["fade", "slide", "scale"]).optional().describe("Animation effect type"),
1742
1791
  effectType: z.enum(["in", "out"]).optional().describe("Whether the animation plays in or out"),
1743
- direction: z.enum(["top", "bottom", "left", "right", ""]).optional().describe("Direction for slide effect. Use empty string for fade/scale."),
1792
+ direction: z.enum(["top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"]).optional().describe(
1793
+ "Direction of the Animation. Can be one of the following or empty if not needed. At slide effect, this is required field."
1794
+ ),
1744
1795
  duration: z.number().min(0).max(1e4).optional().describe("Animation duration in milliseconds"),
1745
1796
  delay: z.number().min(0).max(1e4).optional().describe("Animation delay in milliseconds"),
1746
1797
  easing: z.string().optional().describe("Easing function. See interactions schema for options."),