@elementor/editor-components 3.35.0-333 → 3.35.0-334
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 +46 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -20
- package/src/components/overridable-props/overridable-prop-control.tsx +16 -13
- package/src/components/overridable-props/overridable-prop-indicator.tsx +17 -12
- package/src/provider/overridable-prop-context.tsx +16 -0
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
registerElementType,
|
|
5
5
|
settingsTransformersRegistry as settingsTransformersRegistry2
|
|
6
6
|
} from "@elementor/editor-canvas";
|
|
7
|
-
import { getV1CurrentDocument
|
|
7
|
+
import { getV1CurrentDocument } from "@elementor/editor-documents";
|
|
8
8
|
import {
|
|
9
9
|
FIELD_TYPE,
|
|
10
10
|
injectIntoPanelHeaderTop,
|
|
@@ -1653,7 +1653,7 @@ var EditModeDialog = ({ lockedBy }) => {
|
|
|
1653
1653
|
};
|
|
1654
1654
|
|
|
1655
1655
|
// src/components/overridable-props/overridable-prop-control.tsx
|
|
1656
|
-
import * as
|
|
1656
|
+
import * as React14 from "react";
|
|
1657
1657
|
import { ControlReplacementsProvider, PropKeyProvider, PropProvider, useBoundProp } from "@elementor/editor-controls";
|
|
1658
1658
|
import { createTopLevelObjectType, useElement } from "@elementor/editor-editing-panel";
|
|
1659
1659
|
import { __getState as getState6 } from "@elementor/store";
|
|
@@ -1672,6 +1672,15 @@ var componentOverridablePropTypeUtil = createPropUtils(
|
|
|
1672
1672
|
})
|
|
1673
1673
|
);
|
|
1674
1674
|
|
|
1675
|
+
// src/provider/overridable-prop-context.tsx
|
|
1676
|
+
import * as React13 from "react";
|
|
1677
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
1678
|
+
var OverridablePropContext = createContext2(null);
|
|
1679
|
+
function OverridablePropProvider({ children, ...props }) {
|
|
1680
|
+
return /* @__PURE__ */ React13.createElement(OverridablePropContext.Provider, { value: props }, children);
|
|
1681
|
+
}
|
|
1682
|
+
var useOverridablePropValue = () => useContext2(OverridablePropContext)?.value;
|
|
1683
|
+
|
|
1675
1684
|
// src/store/actions/update-overridable-prop-origin-value.ts
|
|
1676
1685
|
import { __dispatch as dispatch4, __getState as getState5 } from "@elementor/store";
|
|
1677
1686
|
function updateOverridablePropOriginValue(componentId, propValue) {
|
|
@@ -1729,7 +1738,7 @@ function OverridablePropControl({
|
|
|
1729
1738
|
}
|
|
1730
1739
|
});
|
|
1731
1740
|
const objectPlaceholder = placeholder ? { [bind]: placeholder } : void 0;
|
|
1732
|
-
return /* @__PURE__ */
|
|
1741
|
+
return /* @__PURE__ */ React14.createElement(OverridablePropProvider, { value }, /* @__PURE__ */ React14.createElement(
|
|
1733
1742
|
PropProvider,
|
|
1734
1743
|
{
|
|
1735
1744
|
...propContext,
|
|
@@ -1738,14 +1747,13 @@ function OverridablePropControl({
|
|
|
1738
1747
|
value: { [bind]: value.origin_value },
|
|
1739
1748
|
placeholder: objectPlaceholder
|
|
1740
1749
|
},
|
|
1741
|
-
/* @__PURE__ */
|
|
1742
|
-
);
|
|
1750
|
+
/* @__PURE__ */ React14.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React14.createElement(ControlReplacementsProvider, { replacements: [] }, /* @__PURE__ */ React14.createElement(OriginalControl, { ...props })))
|
|
1751
|
+
));
|
|
1743
1752
|
}
|
|
1744
1753
|
|
|
1745
1754
|
// src/components/overridable-props/overridable-prop-indicator.tsx
|
|
1746
|
-
import * as
|
|
1755
|
+
import * as React17 from "react";
|
|
1747
1756
|
import { useBoundProp as useBoundProp2 } from "@elementor/editor-controls";
|
|
1748
|
-
import { getV1CurrentDocument } from "@elementor/editor-documents";
|
|
1749
1757
|
import { useElement as useElement2 } from "@elementor/editor-editing-panel";
|
|
1750
1758
|
import { getWidgetsCache } from "@elementor/editor-elements";
|
|
1751
1759
|
import { __getState as getState9 } from "@elementor/store";
|
|
@@ -1895,7 +1903,7 @@ function removeProps({
|
|
|
1895
1903
|
}
|
|
1896
1904
|
|
|
1897
1905
|
// src/components/overridable-props/indicator.tsx
|
|
1898
|
-
import * as
|
|
1906
|
+
import * as React15 from "react";
|
|
1899
1907
|
import { forwardRef } from "react";
|
|
1900
1908
|
import { CheckIcon, PlusIcon } from "@elementor/icons";
|
|
1901
1909
|
import { Box as Box8, styled as styled2 } from "@elementor/ui";
|
|
@@ -1955,17 +1963,17 @@ var Content = styled2(Box8)`
|
|
|
1955
1963
|
}
|
|
1956
1964
|
}
|
|
1957
1965
|
`;
|
|
1958
|
-
var Indicator = forwardRef(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */
|
|
1966
|
+
var Indicator = forwardRef(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */ React15.createElement(Content, { ref, ...props, className: isOpen || isOverridable ? "enlarged" : "" }, /* @__PURE__ */ React15.createElement(
|
|
1959
1967
|
IconContainer,
|
|
1960
1968
|
{
|
|
1961
1969
|
className: "icon",
|
|
1962
1970
|
"aria-label": isOverridable ? __12("Overridable property", "elementor") : __12("Make prop overridable", "elementor")
|
|
1963
1971
|
},
|
|
1964
|
-
isOverridable ? /* @__PURE__ */
|
|
1972
|
+
isOverridable ? /* @__PURE__ */ React15.createElement(CheckIcon, { fontSize: SIZE }) : /* @__PURE__ */ React15.createElement(PlusIcon, { fontSize: SIZE })
|
|
1965
1973
|
)));
|
|
1966
1974
|
|
|
1967
1975
|
// src/components/overridable-props/overridable-prop-form.tsx
|
|
1968
|
-
import * as
|
|
1976
|
+
import * as React16 from "react";
|
|
1969
1977
|
import { useState as useState4 } from "react";
|
|
1970
1978
|
import { Form as Form2, MenuListItem as MenuListItem2 } from "@elementor/editor-ui";
|
|
1971
1979
|
import { Button as Button3, FormLabel as FormLabel2, Grid as Grid2, Select, Stack as Stack7, TextField as TextField3, Typography as Typography6 } from "@elementor/ui";
|
|
@@ -1980,7 +1988,7 @@ function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
|
1980
1988
|
const isCreate = currentValue === void 0;
|
|
1981
1989
|
const title = isCreate ? __13("Create new property", "elementor") : __13("Update property", "elementor");
|
|
1982
1990
|
const ctaLabel = isCreate ? __13("Create", "elementor") : __13("Update", "elementor");
|
|
1983
|
-
return /* @__PURE__ */
|
|
1991
|
+
return /* @__PURE__ */ React16.createElement(Form2, { onSubmit: () => onSubmit({ label: propLabel ?? "", group }) }, /* @__PURE__ */ React16.createElement(Stack7, { alignItems: "start", width: "268px" }, /* @__PURE__ */ React16.createElement(
|
|
1984
1992
|
Stack7,
|
|
1985
1993
|
{
|
|
1986
1994
|
direction: "row",
|
|
@@ -1989,8 +1997,8 @@ function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
|
1989
1997
|
px: 1.5,
|
|
1990
1998
|
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%", mb: 1.5 }
|
|
1991
1999
|
},
|
|
1992
|
-
/* @__PURE__ */
|
|
1993
|
-
), /* @__PURE__ */
|
|
2000
|
+
/* @__PURE__ */ React16.createElement(Typography6, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, title)
|
|
2001
|
+
), /* @__PURE__ */ React16.createElement(Grid2, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React16.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React16.createElement(FormLabel2, { size: "tiny" }, name)), /* @__PURE__ */ React16.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React16.createElement(
|
|
1994
2002
|
TextField3,
|
|
1995
2003
|
{
|
|
1996
2004
|
name,
|
|
@@ -2000,7 +2008,7 @@ function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
|
2000
2008
|
value: propLabel ?? "",
|
|
2001
2009
|
onChange: (e) => setPropLabel(e.target.value)
|
|
2002
2010
|
}
|
|
2003
|
-
))), /* @__PURE__ */
|
|
2011
|
+
))), /* @__PURE__ */ React16.createElement(Grid2, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React16.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React16.createElement(FormLabel2, { size: "tiny" }, groupName)), /* @__PURE__ */ React16.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React16.createElement(
|
|
2004
2012
|
Select,
|
|
2005
2013
|
{
|
|
2006
2014
|
name: groupName,
|
|
@@ -2017,8 +2025,8 @@ function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
|
2017
2025
|
return groups?.find(({ value }) => value === selectedValue)?.label ?? selectedValue;
|
|
2018
2026
|
}
|
|
2019
2027
|
},
|
|
2020
|
-
(groups ?? [DEFAULT_GROUP]).map(({ label: groupLabel, ...props }) => /* @__PURE__ */
|
|
2021
|
-
))), /* @__PURE__ */
|
|
2028
|
+
(groups ?? [DEFAULT_GROUP]).map(({ label: groupLabel, ...props }) => /* @__PURE__ */ React16.createElement(MenuListItem2, { key: props.value, ...props, value: props.value ?? "" }, groupLabel))
|
|
2029
|
+
))), /* @__PURE__ */ React16.createElement(Stack7, { direction: "row", justifyContent: "flex-end", alignSelf: "end", mt: 1.5, py: 1, px: 1.5 }, /* @__PURE__ */ React16.createElement(Button3, { type: "submit", disabled: !propLabel, variant: "contained", color: "primary", size: "small" }, ctaLabel))));
|
|
2022
2030
|
}
|
|
2023
2031
|
|
|
2024
2032
|
// src/components/overridable-props/utils/get-overridable-prop.ts
|
|
@@ -2038,15 +2046,12 @@ function getOverridableProp({
|
|
|
2038
2046
|
var FORBIDDEN_KEYS = ["_cssid", "attributes"];
|
|
2039
2047
|
function OverridablePropIndicator() {
|
|
2040
2048
|
const { bind } = useBoundProp2();
|
|
2041
|
-
const
|
|
2042
|
-
if (
|
|
2043
|
-
return null;
|
|
2044
|
-
}
|
|
2045
|
-
if (!isPropAllowed(bind)) {
|
|
2049
|
+
const componentId = selectCurrentComponentId(getState9());
|
|
2050
|
+
if (!isPropAllowed(bind) || !componentId) {
|
|
2046
2051
|
return null;
|
|
2047
2052
|
}
|
|
2048
|
-
const overridableProps = selectOverridableProps(getState9(),
|
|
2049
|
-
return /* @__PURE__ */
|
|
2053
|
+
const overridableProps = selectOverridableProps(getState9(), componentId);
|
|
2054
|
+
return /* @__PURE__ */ React17.createElement(Content2, { componentId, overridableProps });
|
|
2050
2055
|
}
|
|
2051
2056
|
function Content2({ componentId, overridableProps }) {
|
|
2052
2057
|
const {
|
|
@@ -2054,7 +2059,11 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2054
2059
|
elementType
|
|
2055
2060
|
} = useElement2();
|
|
2056
2061
|
const { value, bind, propType } = useBoundProp2();
|
|
2057
|
-
const
|
|
2062
|
+
const contextOverridableValue = useOverridablePropValue();
|
|
2063
|
+
const { value: boundPropOverridableValue, setValue: setOverridableValue } = useBoundProp2(
|
|
2064
|
+
componentOverridablePropTypeUtil
|
|
2065
|
+
);
|
|
2066
|
+
const overridableValue = boundPropOverridableValue ?? contextOverridableValue;
|
|
2058
2067
|
const popupState = usePopupState2({
|
|
2059
2068
|
variant: "popover"
|
|
2060
2069
|
});
|
|
@@ -2083,7 +2092,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2083
2092
|
popupState.close();
|
|
2084
2093
|
};
|
|
2085
2094
|
const overridableConfig = overridableValue ? getOverridableProp({ componentId, overrideKey: overridableValue.override_key }) : void 0;
|
|
2086
|
-
return /* @__PURE__ */
|
|
2095
|
+
return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(Tooltip2, { placement: "top", title: __14("Override Property", "elementor") }, /* @__PURE__ */ React17.createElement(Indicator, { ...triggerProps, isOpen: !!popoverProps.open, isOverridable: !!overridableValue })), /* @__PURE__ */ React17.createElement(
|
|
2087
2096
|
Popover2,
|
|
2088
2097
|
{
|
|
2089
2098
|
disableScrollLock: true,
|
|
@@ -2100,7 +2109,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2100
2109
|
},
|
|
2101
2110
|
...popoverProps
|
|
2102
2111
|
},
|
|
2103
|
-
/* @__PURE__ */
|
|
2112
|
+
/* @__PURE__ */ React17.createElement(
|
|
2104
2113
|
OverridablePropForm,
|
|
2105
2114
|
{
|
|
2106
2115
|
onSubmit: handleSubmit,
|
|
@@ -2404,7 +2413,7 @@ function init() {
|
|
|
2404
2413
|
(options) => createComponentType({ ...options, showLockedByModal: openEditModeDialog })
|
|
2405
2414
|
);
|
|
2406
2415
|
registerDataHook("dependency", "editor/documents/close", (args) => {
|
|
2407
|
-
const document =
|
|
2416
|
+
const document = getV1CurrentDocument();
|
|
2408
2417
|
if (document.config.type === COMPONENT_DOCUMENT_TYPE) {
|
|
2409
2418
|
args.mode = "autosave";
|
|
2410
2419
|
}
|
|
@@ -2434,7 +2443,7 @@ function init() {
|
|
|
2434
2443
|
component: ComponentPanelHeader
|
|
2435
2444
|
});
|
|
2436
2445
|
registerDataHook("after", "editor/documents/attach-preview", async () => {
|
|
2437
|
-
const { id, config } =
|
|
2446
|
+
const { id, config } = getV1CurrentDocument();
|
|
2438
2447
|
if (id) {
|
|
2439
2448
|
removeComponentStyles(id);
|
|
2440
2449
|
}
|