@elementor/editor-controls 0.9.0 → 0.10.0
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/CHANGELOG.md +11 -0
- package/dist/index.js +65 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/controls/background-control/background-overlay/background-overlay-repeater-control.tsx +18 -46
- package/src/controls/background-control/background-overlay/types.ts +22 -0
- package/src/controls/background-control/background-overlay/use-background-tabs-history.ts +62 -0
package/dist/index.mjs
CHANGED
|
@@ -1594,11 +1594,11 @@ import { __ as __18 } from "@wordpress/i18n";
|
|
|
1594
1594
|
// src/controls/background-control/background-overlay/background-overlay-repeater-control.tsx
|
|
1595
1595
|
import * as React34 from "react";
|
|
1596
1596
|
import {
|
|
1597
|
-
backgroundColorOverlayPropTypeUtil,
|
|
1598
|
-
backgroundImageOverlayPropTypeUtil,
|
|
1597
|
+
backgroundColorOverlayPropTypeUtil as backgroundColorOverlayPropTypeUtil2,
|
|
1598
|
+
backgroundImageOverlayPropTypeUtil as backgroundImageOverlayPropTypeUtil2,
|
|
1599
1599
|
backgroundOverlayPropTypeUtil
|
|
1600
1600
|
} from "@elementor/editor-props";
|
|
1601
|
-
import { Box as Box4, CardMedia as CardMedia3, Grid as Grid12, Stack as Stack12, Tab, TabPanel, Tabs, UnstableColorIndicator as UnstableColorIndicator2
|
|
1601
|
+
import { Box as Box4, CardMedia as CardMedia3, Grid as Grid12, Stack as Stack12, Tab, TabPanel, Tabs, UnstableColorIndicator as UnstableColorIndicator2 } from "@elementor/ui";
|
|
1602
1602
|
import { useWpMediaAttachment as useWpMediaAttachment3 } from "@elementor/wp-media";
|
|
1603
1603
|
import { __ as __17 } from "@wordpress/i18n";
|
|
1604
1604
|
|
|
@@ -1767,8 +1767,54 @@ var BackgroundImageOverlaySize = () => {
|
|
|
1767
1767
|
)))), isCustom ? /* @__PURE__ */ React33.createElement(PropProvider, { ...backgroundImageScaleContext }, /* @__PURE__ */ React33.createElement(Grid11, { item: true, xs: 12 }, /* @__PURE__ */ React33.createElement(Grid11, { container: true, spacing: 2 }, /* @__PURE__ */ React33.createElement(Grid11, { item: true, xs: 6 }, /* @__PURE__ */ React33.createElement(PropKeyProvider, { bind: "width" }, /* @__PURE__ */ React33.createElement(SizeControl, { startIcon: /* @__PURE__ */ React33.createElement(ArrowsMoveHorizontalIcon, { fontSize: "tiny" }) }))), /* @__PURE__ */ React33.createElement(Grid11, { item: true, xs: 6 }, /* @__PURE__ */ React33.createElement(PropKeyProvider, { bind: "height" }, /* @__PURE__ */ React33.createElement(SizeControl, { startIcon: /* @__PURE__ */ React33.createElement(ArrowsMoveVerticalIcon, { fontSize: "tiny" }) })))))) : null);
|
|
1768
1768
|
};
|
|
1769
1769
|
|
|
1770
|
+
// src/controls/background-control/background-overlay/use-background-tabs-history.ts
|
|
1771
|
+
import { useRef as useRef3 } from "react";
|
|
1772
|
+
import {
|
|
1773
|
+
backgroundColorOverlayPropTypeUtil,
|
|
1774
|
+
backgroundImageOverlayPropTypeUtil
|
|
1775
|
+
} from "@elementor/editor-props";
|
|
1776
|
+
import { useTabs } from "@elementor/ui";
|
|
1777
|
+
var useBackgroundTabsHistory = ({
|
|
1778
|
+
color: initialBackgroundColorOverlay2,
|
|
1779
|
+
image: initialBackgroundImageOverlay
|
|
1780
|
+
}) => {
|
|
1781
|
+
const { value: imageValue, setValue: setImageValue } = useBoundProp(backgroundImageOverlayPropTypeUtil);
|
|
1782
|
+
const { value: colorValue, setValue: setColorValue } = useBoundProp(backgroundColorOverlayPropTypeUtil);
|
|
1783
|
+
const { getTabsProps, getTabProps, getTabPanelProps } = useTabs(colorValue ? "color" : "image");
|
|
1784
|
+
const valuesHistory = useRef3({
|
|
1785
|
+
image: initialBackgroundImageOverlay,
|
|
1786
|
+
color: initialBackgroundColorOverlay2
|
|
1787
|
+
});
|
|
1788
|
+
const saveToHistory = (key, value) => {
|
|
1789
|
+
if (value) {
|
|
1790
|
+
valuesHistory.current[key] = value;
|
|
1791
|
+
}
|
|
1792
|
+
};
|
|
1793
|
+
const onTabChange = (e, tabName) => {
|
|
1794
|
+
switch (tabName) {
|
|
1795
|
+
case "image":
|
|
1796
|
+
setImageValue(valuesHistory.current.image);
|
|
1797
|
+
saveToHistory("color", colorValue);
|
|
1798
|
+
break;
|
|
1799
|
+
case "color":
|
|
1800
|
+
setColorValue(valuesHistory.current.color);
|
|
1801
|
+
saveToHistory("image", imageValue);
|
|
1802
|
+
}
|
|
1803
|
+
return getTabsProps().onChange(e, tabName);
|
|
1804
|
+
};
|
|
1805
|
+
return {
|
|
1806
|
+
getTabProps,
|
|
1807
|
+
getTabPanelProps,
|
|
1808
|
+
getTabsProps: () => ({ ...getTabsProps(), onChange: onTabChange })
|
|
1809
|
+
};
|
|
1810
|
+
};
|
|
1811
|
+
|
|
1770
1812
|
// src/controls/background-control/background-overlay/background-overlay-repeater-control.tsx
|
|
1771
|
-
var
|
|
1813
|
+
var initialBackgroundColorOverlay = {
|
|
1814
|
+
$$type: "background-color-overlay",
|
|
1815
|
+
value: "#00000033"
|
|
1816
|
+
};
|
|
1817
|
+
var getInitialBackgroundOverlay = () => ({
|
|
1772
1818
|
$$type: "background-image-overlay",
|
|
1773
1819
|
value: {
|
|
1774
1820
|
image: {
|
|
@@ -1779,7 +1825,7 @@ var initialBackgroundOverlay = (backgroundPlaceholderImage) => ({
|
|
|
1779
1825
|
value: {
|
|
1780
1826
|
url: {
|
|
1781
1827
|
$$type: "url",
|
|
1782
|
-
value:
|
|
1828
|
+
value: env.background_placeholder_image
|
|
1783
1829
|
},
|
|
1784
1830
|
id: null
|
|
1785
1831
|
}
|
|
@@ -1810,18 +1856,20 @@ var BackgroundOverlayRepeaterControl = createControl(() => {
|
|
|
1810
1856
|
Icon: ItemIcon2,
|
|
1811
1857
|
Label: ItemLabel2,
|
|
1812
1858
|
Content: ItemContent2,
|
|
1813
|
-
initialValues:
|
|
1859
|
+
initialValues: getInitialBackgroundOverlay()
|
|
1814
1860
|
}
|
|
1815
1861
|
}
|
|
1816
1862
|
));
|
|
1817
1863
|
});
|
|
1818
|
-
var ItemContent2 = ({ bind
|
|
1819
|
-
return /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React34.createElement(Content2,
|
|
1864
|
+
var ItemContent2 = ({ bind }) => {
|
|
1865
|
+
return /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React34.createElement(Content2, null));
|
|
1820
1866
|
};
|
|
1821
|
-
var Content2 = (
|
|
1822
|
-
const
|
|
1823
|
-
|
|
1824
|
-
|
|
1867
|
+
var Content2 = () => {
|
|
1868
|
+
const { getTabsProps, getTabProps, getTabPanelProps } = useBackgroundTabsHistory({
|
|
1869
|
+
image: getInitialBackgroundOverlay().value,
|
|
1870
|
+
color: initialBackgroundColorOverlay.value
|
|
1871
|
+
});
|
|
1872
|
+
return /* @__PURE__ */ React34.createElement(Box4, { sx: { width: "100%" } }, /* @__PURE__ */ React34.createElement(Box4, { sx: { borderBottom: 1, borderColor: "divider" } }, /* @__PURE__ */ React34.createElement(Tabs, { ...getTabsProps(), "aria-label": __17("Background Overlay", "elementor") }, /* @__PURE__ */ React34.createElement(Tab, { label: __17("Image", "elementor"), ...getTabProps("image") }), /* @__PURE__ */ React34.createElement(Tab, { label: __17("Color", "elementor"), ...getTabProps("color") }))), /* @__PURE__ */ React34.createElement(TabPanel, { sx: { p: 1.5 }, ...getTabPanelProps("image") }, /* @__PURE__ */ React34.createElement(Stack12, { gap: 1.5 }, /* @__PURE__ */ React34.createElement(ImageOverlayContent, null))), /* @__PURE__ */ React34.createElement(TabPanel, { ...getTabPanelProps("color"), sx: { p: 1.5 } }, /* @__PURE__ */ React34.createElement(Grid12, { container: true, spacing: 1, alignItems: "center" }, /* @__PURE__ */ React34.createElement(Grid12, { item: true, xs: 12 }, /* @__PURE__ */ React34.createElement(ColorControl, { propTypeUtil: backgroundColorOverlayPropTypeUtil2 })))));
|
|
1825
1873
|
};
|
|
1826
1874
|
var ItemIcon2 = ({ value }) => {
|
|
1827
1875
|
switch (value.$$type) {
|
|
@@ -1858,7 +1906,7 @@ var ItemLabelImage = ({ value }) => {
|
|
|
1858
1906
|
return /* @__PURE__ */ React34.createElement("span", null, imageTitle);
|
|
1859
1907
|
};
|
|
1860
1908
|
var ImageOverlayContent = () => {
|
|
1861
|
-
const propContext = useBoundProp(
|
|
1909
|
+
const propContext = useBoundProp(backgroundImageOverlayPropTypeUtil2);
|
|
1862
1910
|
return /* @__PURE__ */ React34.createElement(PropProvider, { ...propContext }, /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "image" }, /* @__PURE__ */ React34.createElement(Grid12, { container: true, spacing: 1, alignItems: "center" }, /* @__PURE__ */ React34.createElement(Grid12, { item: true, xs: 12 }, /* @__PURE__ */ React34.createElement(
|
|
1863
1911
|
ImageControl,
|
|
1864
1912
|
{
|
|
@@ -1867,15 +1915,6 @@ var ImageOverlayContent = () => {
|
|
|
1867
1915
|
}
|
|
1868
1916
|
)))), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "position" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlayPosition, null)), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "repeat" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlayRepeat, null)), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "size" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlaySize, null)), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "attachment" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlayAttachment, null)));
|
|
1869
1917
|
};
|
|
1870
|
-
var deriveOverlayType = (type) => {
|
|
1871
|
-
if (type === "background-color-overlay") {
|
|
1872
|
-
return "color";
|
|
1873
|
-
}
|
|
1874
|
-
if (type === "background-image-overlay") {
|
|
1875
|
-
return "image";
|
|
1876
|
-
}
|
|
1877
|
-
throw new Error(`Invalid overlay type: ${type}`);
|
|
1878
|
-
};
|
|
1879
1918
|
var useImage = (image) => {
|
|
1880
1919
|
let imageTitle, imageUrl = null;
|
|
1881
1920
|
const imageSrc = image?.value.image.value?.src.value;
|