@elementor/editor-interactions 4.1.0-712 → 4.1.0-714

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 CHANGED
@@ -1427,38 +1427,87 @@ var React12 = __toESM(require("react"));
1427
1427
  var import_react11 = require("react");
1428
1428
  var import_editor_controls6 = require("@elementor/editor-controls");
1429
1429
  var import_icons3 = require("@elementor/icons");
1430
+ var import_ui8 = require("@elementor/ui");
1430
1431
  var import_i18n7 = require("@wordpress/i18n");
1432
+ var AXIS = {
1433
+ top: "vertical",
1434
+ bottom: "vertical",
1435
+ left: "horizontal",
1436
+ right: "horizontal"
1437
+ };
1438
+ function parseValue(value) {
1439
+ return value.split("-").filter(Boolean);
1440
+ }
1441
+ function serializeValue(directions) {
1442
+ const vertical = directions.find((d) => d === "top" || d === "bottom");
1443
+ const horizontal = directions.find((d) => d === "left" || d === "right");
1444
+ if (vertical && horizontal) {
1445
+ return `${vertical}-${horizontal}`;
1446
+ }
1447
+ return directions[0] ?? "";
1448
+ }
1449
+ function toggleDirection(current, clicked) {
1450
+ if (current.includes(clicked)) {
1451
+ return current.filter((d) => d !== clicked);
1452
+ }
1453
+ const filtered = current.filter((d) => AXIS[d] !== AXIS[clicked]);
1454
+ return [...filtered, clicked];
1455
+ }
1431
1456
  function Direction({ value, onChange, interactionType }) {
1432
- const options = (0, import_react11.useMemo)(() => {
1433
- const isIn = interactionType === "in";
1434
- return [
1457
+ const isIn = interactionType === "in";
1458
+ const options = (0, import_react11.useMemo)(
1459
+ () => [
1435
1460
  {
1436
- value: "top",
1461
+ dir: "top",
1437
1462
  label: isIn ? (0, import_i18n7.__)("From top", "elementor") : (0, import_i18n7.__)("To top", "elementor"),
1438
- renderContent: ({ size }) => isIn ? /* @__PURE__ */ React12.createElement(import_icons3.ArrowDownSmallIcon, { fontSize: size }) : /* @__PURE__ */ React12.createElement(import_icons3.ArrowUpSmallIcon, { fontSize: size }),
1439
- showTooltip: true
1463
+ Icon: isIn ? import_icons3.ArrowDownSmallIcon : import_icons3.ArrowUpSmallIcon
1440
1464
  },
1441
1465
  {
1442
- value: "bottom",
1443
- label: interactionType === "in" ? (0, import_i18n7.__)("From bottom", "elementor") : (0, import_i18n7.__)("To bottom", "elementor"),
1444
- renderContent: ({ size }) => isIn ? /* @__PURE__ */ React12.createElement(import_icons3.ArrowUpSmallIcon, { fontSize: size }) : /* @__PURE__ */ React12.createElement(import_icons3.ArrowDownSmallIcon, { fontSize: size }),
1445
- showTooltip: true
1466
+ dir: "bottom",
1467
+ label: isIn ? (0, import_i18n7.__)("From bottom", "elementor") : (0, import_i18n7.__)("To bottom", "elementor"),
1468
+ Icon: isIn ? import_icons3.ArrowUpSmallIcon : import_icons3.ArrowDownSmallIcon
1446
1469
  },
1447
1470
  {
1448
- value: "left",
1449
- label: interactionType === "in" ? (0, import_i18n7.__)("From left", "elementor") : (0, import_i18n7.__)("To left", "elementor"),
1450
- renderContent: ({ size }) => isIn ? /* @__PURE__ */ React12.createElement(import_icons3.ArrowRightIcon, { fontSize: size }) : /* @__PURE__ */ React12.createElement(import_icons3.ArrowLeftIcon, { fontSize: size }),
1451
- showTooltip: true
1471
+ dir: "left",
1472
+ label: isIn ? (0, import_i18n7.__)("From left", "elementor") : (0, import_i18n7.__)("To left", "elementor"),
1473
+ Icon: isIn ? import_icons3.ArrowRightIcon : import_icons3.ArrowLeftIcon
1452
1474
  },
1453
1475
  {
1454
- value: "right",
1455
- label: interactionType === "in" ? (0, import_i18n7.__)("From right", "elementor") : (0, import_i18n7.__)("To right", "elementor"),
1456
- renderContent: ({ size }) => isIn ? /* @__PURE__ */ React12.createElement(import_icons3.ArrowLeftIcon, { fontSize: size }) : /* @__PURE__ */ React12.createElement(import_icons3.ArrowRightIcon, { fontSize: size }),
1457
- showTooltip: true
1476
+ dir: "right",
1477
+ label: isIn ? (0, import_i18n7.__)("From right", "elementor") : (0, import_i18n7.__)("To right", "elementor"),
1478
+ Icon: isIn ? import_icons3.ArrowLeftIcon : import_icons3.ArrowRightIcon
1479
+ }
1480
+ ],
1481
+ [isIn]
1482
+ );
1483
+ const selectedDirections = (0, import_react11.useMemo)(() => parseValue(value), [value]);
1484
+ return /* @__PURE__ */ React12.createElement(
1485
+ import_editor_controls6.StyledToggleButtonGroup,
1486
+ {
1487
+ size: "tiny",
1488
+ justify: "end",
1489
+ sx: {
1490
+ display: "grid",
1491
+ gridTemplateColumns: "repeat(4, minmax(0, 25%))",
1492
+ width: "100%"
1458
1493
  }
1459
- ];
1460
- }, [interactionType]);
1461
- return /* @__PURE__ */ React12.createElement(import_editor_controls6.ToggleButtonGroupUi, { items: options, exclusive: true, onChange, value });
1494
+ },
1495
+ options.map(({ dir, label, Icon }) => /* @__PURE__ */ React12.createElement(import_ui8.Tooltip, { key: dir, title: label, disableFocusListener: true, placement: "top" }, /* @__PURE__ */ React12.createElement(
1496
+ import_editor_controls6.StyledToggleButton,
1497
+ {
1498
+ value: dir,
1499
+ selected: selectedDirections.includes(dir),
1500
+ "aria-label": label,
1501
+ size: "tiny",
1502
+ isPlaceholder: false,
1503
+ onChange: () => {
1504
+ const next = toggleDirection(selectedDirections, dir);
1505
+ onChange(serializeValue(next));
1506
+ }
1507
+ },
1508
+ /* @__PURE__ */ React12.createElement(Icon, { fontSize: "tiny" })
1509
+ )))
1510
+ );
1462
1511
  }
1463
1512
 
1464
1513
  // src/components/controls/easing.tsx
@@ -1469,7 +1518,7 @@ var import_i18n10 = require("@wordpress/i18n");
1469
1518
  var React14 = __toESM(require("react"));
1470
1519
  var import_react13 = require("react");
1471
1520
  var import_editor_ui2 = require("@elementor/editor-ui");
1472
- var import_ui9 = require("@elementor/ui");
1521
+ var import_ui10 = require("@elementor/ui");
1473
1522
  var import_i18n9 = require("@wordpress/i18n");
1474
1523
 
1475
1524
  // src/ui/interactions-promotion-chip.tsx
@@ -1477,7 +1526,7 @@ var React13 = __toESM(require("react"));
1477
1526
  var import_react12 = require("react");
1478
1527
  var import_editor_controls7 = require("@elementor/editor-controls");
1479
1528
  var import_editor_ui = require("@elementor/editor-ui");
1480
- var import_ui8 = require("@elementor/ui");
1529
+ var import_ui9 = require("@elementor/ui");
1481
1530
  var import_i18n8 = require("@wordpress/i18n");
1482
1531
  var InteractionsPromotionChip = (0, import_react12.forwardRef)(
1483
1532
  ({ content, upgradeUrl, anchorRef, trackingData }, ref) => {
@@ -1513,7 +1562,7 @@ var InteractionsPromotionChip = (0, import_react12.forwardRef)(
1513
1562
  onCtaClick: () => (0, import_editor_controls7.trackUpgradePromotionClick)(trackingData)
1514
1563
  },
1515
1564
  /* @__PURE__ */ React13.createElement(
1516
- import_ui8.Box,
1565
+ import_ui9.Box,
1517
1566
  {
1518
1567
  onMouseDown: (e) => e.stopPropagation(),
1519
1568
  onClick: handleToggle,
@@ -1540,7 +1589,7 @@ function PromotionSelect({
1540
1589
  const promotionRef = (0, import_react13.useRef)(null);
1541
1590
  const anchorRef = (0, import_react13.useRef)(null);
1542
1591
  return /* @__PURE__ */ React14.createElement(
1543
- import_ui9.Select,
1592
+ import_ui10.Select,
1544
1593
  {
1545
1594
  value,
1546
1595
  onChange: (e) => onChange?.(e.target.value),
@@ -1551,7 +1600,7 @@ function PromotionSelect({
1551
1600
  },
1552
1601
  Object.entries(baseOptions).map(([key, label]) => /* @__PURE__ */ React14.createElement(import_editor_ui2.MenuListItem, { key, value: key }, label)),
1553
1602
  /* @__PURE__ */ React14.createElement(
1554
- import_ui9.MenuSubheader,
1603
+ import_ui10.MenuSubheader,
1555
1604
  {
1556
1605
  ref: anchorRef,
1557
1606
  sx: {
@@ -1676,7 +1725,7 @@ function EffectType({ value, onChange }) {
1676
1725
  var React18 = __toESM(require("react"));
1677
1726
  var import_editor_controls9 = require("@elementor/editor-controls");
1678
1727
  var import_icons4 = require("@elementor/icons");
1679
- var import_ui10 = require("@elementor/ui");
1728
+ var import_ui11 = require("@elementor/ui");
1680
1729
  var import_i18n13 = require("@wordpress/i18n");
1681
1730
  var TRACKING_DATA3 = { target_name: "interactions_replay", location_l2: "interactions" };
1682
1731
  var REPLAY_OPTIONS = {
@@ -1703,7 +1752,7 @@ function Replay({ onChange, anchorRef }) {
1703
1752
  showTooltip: true
1704
1753
  }
1705
1754
  ];
1706
- return /* @__PURE__ */ React18.createElement(import_ui10.Box, { sx: { display: "grid", alignItems: "center" } }, /* @__PURE__ */ React18.createElement(import_ui10.Box, { sx: { gridArea: OVERLAY_GRID } }, /* @__PURE__ */ React18.createElement(import_editor_controls9.ToggleButtonGroupUi, { items: options, exclusive: true, onChange, value: false })), /* @__PURE__ */ React18.createElement(import_ui10.Box, { sx: { gridArea: OVERLAY_GRID, marginInlineEnd: CHIP_OFFSET, justifySelf: "end" } }, /* @__PURE__ */ React18.createElement(
1755
+ return /* @__PURE__ */ React18.createElement(import_ui11.Box, { sx: { display: "grid", alignItems: "center" } }, /* @__PURE__ */ React18.createElement(import_ui11.Box, { sx: { gridArea: OVERLAY_GRID } }, /* @__PURE__ */ React18.createElement(import_editor_controls9.ToggleButtonGroupUi, { items: options, exclusive: true, onChange, value: false })), /* @__PURE__ */ React18.createElement(import_ui11.Box, { sx: { gridArea: OVERLAY_GRID, marginInlineEnd: CHIP_OFFSET, justifySelf: "end" } }, /* @__PURE__ */ React18.createElement(
1707
1756
  InteractionsPromotionChip,
1708
1757
  {
1709
1758
  content: (0, import_i18n13.__)("Upgrade to run the animation every time its trigger occurs.", "elementor"),
@@ -1801,7 +1850,9 @@ var baseSchema = {
1801
1850
  trigger: import_schema.z.enum(["load", "scrollIn"]).optional().describe("Event that triggers the animation"),
1802
1851
  effect: import_schema.z.enum(["fade", "slide", "scale"]).optional().describe("Animation effect type"),
1803
1852
  effectType: import_schema.z.enum(["in", "out"]).optional().describe("Whether the animation plays in or out"),
1804
- direction: import_schema.z.enum(["top", "bottom", "left", "right", ""]).optional().describe("Direction for slide effect. Use empty string for fade/scale."),
1853
+ direction: import_schema.z.enum(["top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"]).optional().describe(
1854
+ "Direction of the Animation. Can be one of the following or empty if not needed. At slide effect, this is required field."
1855
+ ),
1805
1856
  duration: import_schema.z.number().min(0).max(1e4).optional().describe("Animation duration in milliseconds"),
1806
1857
  delay: import_schema.z.number().min(0).max(1e4).optional().describe("Animation delay in milliseconds"),
1807
1858
  easing: import_schema.z.string().optional().describe("Easing function. See interactions schema for options."),