@elementor/editor-variables 3.33.0-105 → 3.33.0-106

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
@@ -576,7 +576,8 @@ var useFilteredVariables = (searchValue, propTypeKey) => {
576
576
  return {
577
577
  list: searchFilteredVariables,
578
578
  hasMatches: searchFilteredVariables.length > 0,
579
- isSourceNotEmpty: typeFilteredVariables.length > 0
579
+ isSourceNotEmpty: typeFilteredVariables.length > 0,
580
+ hasNoCompatibleVariables: baseVariables.length > 0 && typeFilteredVariables.length === 0
580
581
  };
581
582
  };
582
583
  var useVariableSelectionFilter = (variables) => {
@@ -1647,16 +1648,46 @@ import { ColorFilterIcon as ColorFilterIcon2, PlusIcon, SettingsIcon } from "@el
1647
1648
  import { Divider as Divider4, IconButton as IconButton7 } from "@elementor/ui";
1648
1649
  import { __ as __13, sprintf } from "@wordpress/i18n";
1649
1650
 
1650
- // src/components/ui/menu-item-content.tsx
1651
+ // src/components/ui/empty-state.tsx
1651
1652
  import * as React15 from "react";
1653
+ import { Button as Button6, Stack as Stack5, Typography as Typography6 } from "@elementor/ui";
1654
+ import { __ as __10 } from "@wordpress/i18n";
1655
+ var EmptyState = ({ icon, title, message, onAdd }) => {
1656
+ const canAdd = usePermissions().canAdd();
1657
+ return /* @__PURE__ */ React15.createElement(
1658
+ Stack5,
1659
+ {
1660
+ gap: 1,
1661
+ alignItems: "center",
1662
+ justifyContent: "center",
1663
+ height: "100%",
1664
+ color: "text.secondary",
1665
+ sx: { p: 2.5, pb: 5.5 }
1666
+ },
1667
+ icon,
1668
+ canAdd ? /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(Content, { title, message }), onAdd && /* @__PURE__ */ React15.createElement(Button6, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, __10("Create a variable", "elementor"))) : /* @__PURE__ */ React15.createElement(
1669
+ Content,
1670
+ {
1671
+ title: __10("There are no variables", "elementor"),
1672
+ message: __10("With your current role, you can only connect and detach variables.", "elementor")
1673
+ }
1674
+ )
1675
+ );
1676
+ };
1677
+ function Content({ title, message }) {
1678
+ return /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(Typography6, { align: "center", variant: "subtitle2" }, title), /* @__PURE__ */ React15.createElement(Typography6, { align: "center", variant: "caption", maxWidth: "180px" }, message));
1679
+ }
1680
+
1681
+ // src/components/ui/menu-item-content.tsx
1682
+ import * as React16 from "react";
1652
1683
  import { EllipsisWithTooltip as EllipsisWithTooltip2 } from "@elementor/editor-ui";
1653
1684
  import { EditIcon } from "@elementor/icons";
1654
- import { Box as Box3, IconButton as IconButton6, ListItemIcon, Typography as Typography6 } from "@elementor/ui";
1655
- import { __ as __10 } from "@wordpress/i18n";
1685
+ import { Box as Box3, IconButton as IconButton6, ListItemIcon, Typography as Typography7 } from "@elementor/ui";
1686
+ import { __ as __11 } from "@wordpress/i18n";
1656
1687
  var SIZE3 = "tiny";
1657
1688
  var MenuItemContent = ({ item }) => {
1658
1689
  const onEdit = item.onEdit;
1659
- return /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(ListItemIcon, null, item.icon), /* @__PURE__ */ React15.createElement(
1690
+ return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(ListItemIcon, null, item.icon), /* @__PURE__ */ React16.createElement(
1660
1691
  Box3,
1661
1692
  {
1662
1693
  sx: {
@@ -1667,29 +1698,29 @@ var MenuItemContent = ({ item }) => {
1667
1698
  gap: 1
1668
1699
  }
1669
1700
  },
1670
- /* @__PURE__ */ React15.createElement(
1701
+ /* @__PURE__ */ React16.createElement(
1671
1702
  EllipsisWithTooltip2,
1672
1703
  {
1673
1704
  title: item.label || item.value,
1674
- as: Typography6,
1705
+ as: Typography7,
1675
1706
  variant: "caption",
1676
1707
  color: "text.primary",
1677
1708
  sx: { marginTop: "1px", lineHeight: "2" },
1678
1709
  maxWidth: "50%"
1679
1710
  }
1680
1711
  ),
1681
- item.secondaryText && /* @__PURE__ */ React15.createElement(
1712
+ item.secondaryText && /* @__PURE__ */ React16.createElement(
1682
1713
  EllipsisWithTooltip2,
1683
1714
  {
1684
1715
  title: item.secondaryText,
1685
- as: Typography6,
1716
+ as: Typography7,
1686
1717
  variant: "caption",
1687
1718
  color: "text.tertiary",
1688
1719
  sx: { marginTop: "1px", lineHeight: "1" },
1689
1720
  maxWidth: "50%"
1690
1721
  }
1691
1722
  )
1692
- ), !!onEdit && /* @__PURE__ */ React15.createElement(
1723
+ ), !!onEdit && /* @__PURE__ */ React16.createElement(
1693
1724
  IconButton6,
1694
1725
  {
1695
1726
  sx: { mx: 1, opacity: "0" },
@@ -1697,40 +1728,17 @@ var MenuItemContent = ({ item }) => {
1697
1728
  e.stopPropagation();
1698
1729
  onEdit(item.value);
1699
1730
  },
1700
- "aria-label": __10("Edit", "elementor")
1731
+ "aria-label": __11("Edit", "elementor")
1701
1732
  },
1702
- /* @__PURE__ */ React15.createElement(EditIcon, { color: "action", fontSize: SIZE3 })
1733
+ /* @__PURE__ */ React16.createElement(EditIcon, { color: "action", fontSize: SIZE3 })
1703
1734
  ));
1704
1735
  };
1705
1736
 
1706
1737
  // src/components/ui/no-search-results.tsx
1707
- import * as React16 from "react";
1708
- import { Link, Stack as Stack5, Typography as Typography7 } from "@elementor/ui";
1709
- import { __ as __11 } from "@wordpress/i18n";
1710
- var NoSearchResults = ({ searchValue, onClear, icon }) => {
1711
- return /* @__PURE__ */ React16.createElement(
1712
- Stack5,
1713
- {
1714
- gap: 1,
1715
- alignItems: "center",
1716
- justifyContent: "center",
1717
- height: "100%",
1718
- p: 2.5,
1719
- color: "text.secondary",
1720
- sx: { pb: 3.5 }
1721
- },
1722
- icon,
1723
- /* @__PURE__ */ React16.createElement(Typography7, { align: "center", variant: "subtitle2" }, __11("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React16.createElement("br", null), "\u201C", searchValue, "\u201D."),
1724
- /* @__PURE__ */ React16.createElement(Typography7, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, __11("Try something else.", "elementor"), /* @__PURE__ */ React16.createElement(Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, __11("Clear & try again", "elementor")))
1725
- );
1726
- };
1727
-
1728
- // src/components/ui/no-variables.tsx
1729
1738
  import * as React17 from "react";
1730
- import { Button as Button6, Stack as Stack6, Typography as Typography8 } from "@elementor/ui";
1739
+ import { Link, Stack as Stack6, Typography as Typography8 } from "@elementor/ui";
1731
1740
  import { __ as __12 } from "@wordpress/i18n";
1732
- var NoVariables = ({ icon, title, onAdd }) => {
1733
- const canAdd = usePermissions().canAdd();
1741
+ var NoSearchResults = ({ searchValue, onClear, icon }) => {
1734
1742
  return /* @__PURE__ */ React17.createElement(
1735
1743
  Stack6,
1736
1744
  {
@@ -1738,31 +1746,15 @@ var NoVariables = ({ icon, title, onAdd }) => {
1738
1746
  alignItems: "center",
1739
1747
  justifyContent: "center",
1740
1748
  height: "100%",
1749
+ p: 2.5,
1741
1750
  color: "text.secondary",
1742
- sx: { p: 2.5, pb: 5.5 }
1751
+ sx: { pb: 3.5 }
1743
1752
  },
1744
1753
  icon,
1745
- canAdd ? /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(
1746
- NoVariablesContent,
1747
- {
1748
- title: title || __12("Create your first variable", "elementor"),
1749
- message: __12(
1750
- "Variables are saved attributes that you can apply anywhere on your site.",
1751
- "elementor"
1752
- )
1753
- }
1754
- ), onAdd && /* @__PURE__ */ React17.createElement(Button6, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, __12("Create a variable", "elementor"))) : /* @__PURE__ */ React17.createElement(
1755
- NoVariablesContent,
1756
- {
1757
- title: __12("There are no variables", "elementor"),
1758
- message: __12("With your current role, you can only connect and detach variables.", "elementor")
1759
- }
1760
- )
1754
+ /* @__PURE__ */ React17.createElement(Typography8, { align: "center", variant: "subtitle2" }, __12("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React17.createElement("br", null), "\u201C", searchValue, "\u201D."),
1755
+ /* @__PURE__ */ React17.createElement(Typography8, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, __12("Try something else.", "elementor"), /* @__PURE__ */ React17.createElement(Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, __12("Clear & try again", "elementor")))
1761
1756
  );
1762
1757
  };
1763
- function NoVariablesContent({ title, message }) {
1764
- return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(Typography8, { align: "center", variant: "subtitle2" }, title), /* @__PURE__ */ React17.createElement(Typography8, { align: "center", variant: "caption", maxWidth: "180px" }, message));
1765
- }
1766
1758
 
1767
1759
  // src/components/ui/styled-menu-list.tsx
1768
1760
  import { MenuList, styled as styled2 } from "@elementor/ui";
@@ -1805,7 +1797,8 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
1805
1797
  const {
1806
1798
  list: variables,
1807
1799
  hasMatches: hasSearchResults,
1808
- isSourceNotEmpty: hasVariables
1800
+ isSourceNotEmpty: hasVariables,
1801
+ hasNoCompatibleVariables
1809
1802
  } = useFilteredVariables(searchValue, propTypeUtil.key);
1810
1803
  const handleSetVariable = (key) => {
1811
1804
  setVariable(key);
@@ -1889,7 +1882,29 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
1889
1882
  onClear: handleClearSearch,
1890
1883
  icon: /* @__PURE__ */ React18.createElement(VariableIcon, { fontSize: "large" })
1891
1884
  }
1892
- ), !hasVariables && /* @__PURE__ */ React18.createElement(NoVariables, { title: noVariableTitle, icon: /* @__PURE__ */ React18.createElement(VariableIcon, { fontSize: "large" }), onAdd }));
1885
+ ), !hasVariables && !hasNoCompatibleVariables && /* @__PURE__ */ React18.createElement(
1886
+ EmptyState,
1887
+ {
1888
+ title: noVariableTitle,
1889
+ message: __13(
1890
+ "Variables are saved attributes that you can apply anywhere on your site.",
1891
+ "elementor"
1892
+ ),
1893
+ icon: /* @__PURE__ */ React18.createElement(VariableIcon, { fontSize: "large" }),
1894
+ onAdd
1895
+ }
1896
+ ), hasNoCompatibleVariables && /* @__PURE__ */ React18.createElement(
1897
+ EmptyState,
1898
+ {
1899
+ title: __13("No compatible variables", "elementor"),
1900
+ message: __13(
1901
+ "Looks like none of your variables work with this control. Create a new variable to use it here.",
1902
+ "elementor"
1903
+ ),
1904
+ icon: /* @__PURE__ */ React18.createElement(VariableIcon, { fontSize: "large" }),
1905
+ onAdd
1906
+ }
1907
+ ));
1893
1908
  };
1894
1909
 
1895
1910
  // src/components/variable-selection-popover.tsx