@elementor/editor-components 3.35.0-341 → 3.35.0-343
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 +282 -145
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +232 -94
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -20
- package/src/components/instance-editing-panel/empty-state.tsx +35 -0
- package/src/components/instance-editing-panel/instance-editing-panel.tsx +73 -0
- package/src/components/instance-editing-panel/override-props-group.tsx +56 -0
- package/src/create-component-type.ts +2 -7
- package/src/hooks/use-component-instance-settings.ts +15 -0
- package/src/hooks/use-navigate-back.ts +3 -13
- package/src/init.ts +8 -0
- package/src/prop-types/component-instance-override-prop-type.ts +18 -0
- package/src/prop-types/component-instance-overrides-prop-type.ts +13 -0
- package/src/prop-types/component-instance-prop-type.ts +14 -0
- package/src/store/store.ts +1 -1
- package/src/utils/switch-to-component.ts +11 -0
package/dist/index.mjs
CHANGED
|
@@ -9,13 +9,14 @@ import {
|
|
|
9
9
|
FIELD_TYPE,
|
|
10
10
|
injectIntoPanelHeaderTop,
|
|
11
11
|
registerControlReplacement,
|
|
12
|
+
registerEditingPanelReplacement,
|
|
12
13
|
registerFieldIndicator
|
|
13
14
|
} from "@elementor/editor-editing-panel";
|
|
14
15
|
import { injectTab } from "@elementor/editor-elements-panel";
|
|
15
16
|
import { stylesRepository } from "@elementor/editor-styles-repository";
|
|
16
17
|
import { registerDataHook } from "@elementor/editor-v1-adapters";
|
|
17
18
|
import { __registerSlice as registerSlice } from "@elementor/store";
|
|
18
|
-
import { __ as
|
|
19
|
+
import { __ as __17 } from "@wordpress/i18n";
|
|
19
20
|
|
|
20
21
|
// src/component-instance-transformer.ts
|
|
21
22
|
import { createTransformer } from "@elementor/editor-canvas";
|
|
@@ -284,27 +285,31 @@ import { __ as __2 } from "@wordpress/i18n";
|
|
|
284
285
|
// src/hooks/use-navigate-back.ts
|
|
285
286
|
import { useCallback } from "react";
|
|
286
287
|
import { getV1DocumentsManager as getV1DocumentsManager2 } from "@elementor/editor-documents";
|
|
287
|
-
import { __privateRunCommand as runCommand } from "@elementor/editor-v1-adapters";
|
|
288
288
|
import { __useSelector as useSelector } from "@elementor/store";
|
|
289
|
+
|
|
290
|
+
// src/utils/switch-to-component.ts
|
|
291
|
+
import { __privateRunCommand as runCommand } from "@elementor/editor-v1-adapters";
|
|
292
|
+
function switchToComponent(componentId, componentInstanceId) {
|
|
293
|
+
runCommand("editor/documents/switch", {
|
|
294
|
+
id: componentId,
|
|
295
|
+
selector: componentInstanceId ? `[data-id="${componentInstanceId}"]` : void 0,
|
|
296
|
+
mode: "autosave",
|
|
297
|
+
setAsInitial: false,
|
|
298
|
+
shouldScroll: false
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/hooks/use-navigate-back.ts
|
|
289
303
|
function useNavigateBack() {
|
|
290
304
|
const path = useSelector(selectPath);
|
|
291
305
|
const documentsManager = getV1DocumentsManager2();
|
|
292
306
|
return useCallback(() => {
|
|
293
307
|
const { componentId: prevComponentId, instanceId: prevComponentInstanceId } = path.at(-2) ?? {};
|
|
294
|
-
const switchToDocument = (id, selector) => {
|
|
295
|
-
runCommand("editor/documents/switch", {
|
|
296
|
-
id,
|
|
297
|
-
selector,
|
|
298
|
-
mode: "autosave",
|
|
299
|
-
setAsInitial: false,
|
|
300
|
-
shouldScroll: false
|
|
301
|
-
});
|
|
302
|
-
};
|
|
303
308
|
if (prevComponentId && prevComponentInstanceId) {
|
|
304
|
-
|
|
309
|
+
switchToComponent(prevComponentId, prevComponentInstanceId);
|
|
305
310
|
return;
|
|
306
311
|
}
|
|
307
|
-
|
|
312
|
+
switchToComponent(documentsManager.getInitialId());
|
|
308
313
|
}, [path, documentsManager]);
|
|
309
314
|
}
|
|
310
315
|
|
|
@@ -505,7 +510,6 @@ import {
|
|
|
505
510
|
createTemplatedElementView
|
|
506
511
|
} from "@elementor/editor-canvas";
|
|
507
512
|
import { getCurrentDocument } from "@elementor/editor-documents";
|
|
508
|
-
import { __privateRunCommand as runCommand2 } from "@elementor/editor-v1-adapters";
|
|
509
513
|
import { __ as __4 } from "@wordpress/i18n";
|
|
510
514
|
|
|
511
515
|
// src/utils/tracking.ts
|
|
@@ -643,12 +647,7 @@ function createComponentView(options) {
|
|
|
643
647
|
if (!isAllowedToSwitchDocument) {
|
|
644
648
|
options.showLockedByModal?.(lockedBy || "");
|
|
645
649
|
} else {
|
|
646
|
-
|
|
647
|
-
id: this.getComponentId(),
|
|
648
|
-
mode: "autosave",
|
|
649
|
-
selector: `[data-id="${this.model.get("id")}"]`,
|
|
650
|
-
shouldScroll: false
|
|
651
|
-
});
|
|
650
|
+
switchToComponent(this.getComponentId(), this.model.get("id"));
|
|
652
651
|
}
|
|
653
652
|
}
|
|
654
653
|
editComponent({ trigger, location, secondaryLocation }) {
|
|
@@ -1104,7 +1103,7 @@ import { Alert, Button, FormLabel, Grid, Popover, Snackbar, Stack as Stack5, Tex
|
|
|
1104
1103
|
import { __ as __8 } from "@wordpress/i18n";
|
|
1105
1104
|
|
|
1106
1105
|
// src/store/actions/create-unpublished-component.ts
|
|
1107
|
-
import { __privateRunCommand as
|
|
1106
|
+
import { __privateRunCommand as runCommand2 } from "@elementor/editor-v1-adapters";
|
|
1108
1107
|
import { __dispatch as dispatch3 } from "@elementor/store";
|
|
1109
1108
|
import { generateUniqueId } from "@elementor/utils";
|
|
1110
1109
|
function createUnpublishedComponent(name, element, eventData) {
|
|
@@ -1124,7 +1123,7 @@ function createUnpublishedComponent(name, element, eventData) {
|
|
|
1124
1123
|
component_name: name,
|
|
1125
1124
|
...eventData
|
|
1126
1125
|
});
|
|
1127
|
-
|
|
1126
|
+
runCommand2("document/save/auto");
|
|
1128
1127
|
return uid;
|
|
1129
1128
|
}
|
|
1130
1129
|
|
|
@@ -1652,39 +1651,173 @@ var EditModeDialog = ({ lockedBy }) => {
|
|
|
1652
1651
|
)), /* @__PURE__ */ React12.createElement(DialogActions, null, /* @__PURE__ */ React12.createElement(Button2, { color: "secondary", variant: "contained", onClick: closeDialog }, __10("Close", "elementor"))))));
|
|
1653
1652
|
};
|
|
1654
1653
|
|
|
1655
|
-
// src/components/
|
|
1656
|
-
import * as
|
|
1657
|
-
import {
|
|
1658
|
-
import {
|
|
1659
|
-
import {
|
|
1654
|
+
// src/components/instance-editing-panel/instance-editing-panel.tsx
|
|
1655
|
+
import * as React15 from "react";
|
|
1656
|
+
import { useElement } from "@elementor/editor-editing-panel";
|
|
1657
|
+
import { useElementSetting, useSelectedElement } from "@elementor/editor-elements";
|
|
1658
|
+
import { PanelBody, PanelHeader, PanelHeaderTitle } from "@elementor/editor-panels";
|
|
1659
|
+
import { ComponentsIcon as ComponentsIcon3, PencilIcon as PencilIcon2 } from "@elementor/icons";
|
|
1660
|
+
import { __getState as getState5 } from "@elementor/store";
|
|
1661
|
+
import { IconButton as IconButton3, Stack as Stack9, Tooltip as Tooltip2 } from "@elementor/ui";
|
|
1662
|
+
import { __ as __12 } from "@wordpress/i18n";
|
|
1660
1663
|
|
|
1661
|
-
// src/prop-types/component-
|
|
1664
|
+
// src/prop-types/component-instance-prop-type.ts
|
|
1665
|
+
import { createPropUtils as createPropUtils3, numberPropTypeUtil } from "@elementor/editor-props";
|
|
1666
|
+
import { z as z4 } from "@elementor/schema";
|
|
1667
|
+
|
|
1668
|
+
// src/prop-types/component-instance-overrides-prop-type.ts
|
|
1669
|
+
import { createPropUtils as createPropUtils2 } from "@elementor/editor-props";
|
|
1670
|
+
import { z as z3 } from "@elementor/schema";
|
|
1671
|
+
|
|
1672
|
+
// src/prop-types/component-instance-override-prop-type.ts
|
|
1662
1673
|
import { createPropUtils } from "@elementor/editor-props";
|
|
1663
1674
|
import { z as z2 } from "@elementor/schema";
|
|
1664
|
-
var
|
|
1665
|
-
"
|
|
1675
|
+
var componentInstanceOverridePropTypeUtil = createPropUtils(
|
|
1676
|
+
"override",
|
|
1666
1677
|
z2.object({
|
|
1667
1678
|
override_key: z2.string(),
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1679
|
+
override_value: z2.unknown(),
|
|
1680
|
+
schema_source: z2.object({
|
|
1681
|
+
type: z2.literal("component"),
|
|
1682
|
+
id: z2.number()
|
|
1683
|
+
})
|
|
1684
|
+
})
|
|
1685
|
+
);
|
|
1686
|
+
|
|
1687
|
+
// src/prop-types/component-instance-overrides-prop-type.ts
|
|
1688
|
+
var componentInstanceOverridesPropTypeUtil = createPropUtils2(
|
|
1689
|
+
"overrides",
|
|
1690
|
+
z3.array(componentInstanceOverridePropTypeUtil.schema)
|
|
1691
|
+
);
|
|
1692
|
+
|
|
1693
|
+
// src/prop-types/component-instance-prop-type.ts
|
|
1694
|
+
var componentInstancePropTypeUtil = createPropUtils3(
|
|
1695
|
+
"component-instance",
|
|
1696
|
+
z4.object({
|
|
1697
|
+
component_id: numberPropTypeUtil.schema,
|
|
1698
|
+
overrides: componentInstanceOverridesPropTypeUtil.schema
|
|
1699
|
+
})
|
|
1700
|
+
);
|
|
1701
|
+
|
|
1702
|
+
// src/components/instance-editing-panel/empty-state.tsx
|
|
1703
|
+
import * as React13 from "react";
|
|
1704
|
+
import { ComponentPropListIcon as ComponentPropListIcon2, PencilIcon } from "@elementor/icons";
|
|
1705
|
+
import { Button as Button3, Stack as Stack7, Typography as Typography6 } from "@elementor/ui";
|
|
1706
|
+
import { __ as __11 } from "@wordpress/i18n";
|
|
1707
|
+
var EmptyState2 = ({ onEditComponent }) => {
|
|
1708
|
+
return /* @__PURE__ */ React13.createElement(
|
|
1709
|
+
Stack7,
|
|
1710
|
+
{
|
|
1711
|
+
alignItems: "center",
|
|
1712
|
+
justifyContent: "start",
|
|
1713
|
+
height: "100%",
|
|
1714
|
+
color: "text.secondary",
|
|
1715
|
+
sx: { p: 2.5, pt: 8, pb: 5.5, mt: 1 },
|
|
1716
|
+
gap: 1.5
|
|
1717
|
+
},
|
|
1718
|
+
/* @__PURE__ */ React13.createElement(ComponentPropListIcon2, { fontSize: "large" }),
|
|
1719
|
+
/* @__PURE__ */ React13.createElement(Typography6, { align: "center", variant: "subtitle2" }, __11("No properties yet", "elementor")),
|
|
1720
|
+
/* @__PURE__ */ React13.createElement(Typography6, { align: "center", variant: "caption", maxWidth: "170px" }, __11(
|
|
1721
|
+
"Edit the component to add properties, manage them or update the design across all instances.",
|
|
1722
|
+
"elementor"
|
|
1723
|
+
)),
|
|
1724
|
+
/* @__PURE__ */ React13.createElement(Button3, { variant: "outlined", color: "secondary", size: "small", sx: { mt: 1 }, onClick: onEditComponent }, /* @__PURE__ */ React13.createElement(PencilIcon, { fontSize: "small" }), __11("Edit component", "elementor"))
|
|
1725
|
+
);
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1728
|
+
// src/components/instance-editing-panel/override-props-group.tsx
|
|
1729
|
+
import * as React14 from "react";
|
|
1730
|
+
import { useId } from "react";
|
|
1731
|
+
import { useStateByElement } from "@elementor/editor-editing-panel";
|
|
1732
|
+
import { CollapseIcon } from "@elementor/editor-ui";
|
|
1733
|
+
import { Collapse, ListItemButton as ListItemButton3, ListItemText as ListItemText2, Stack as Stack8 } from "@elementor/ui";
|
|
1734
|
+
function OverridePropsGroup({ group, props }) {
|
|
1735
|
+
const [isOpen, setIsOpen] = useStateByElement(group.id, true);
|
|
1736
|
+
const handleClick = () => {
|
|
1737
|
+
setIsOpen(!isOpen);
|
|
1738
|
+
};
|
|
1739
|
+
const id = useId();
|
|
1740
|
+
const labelId = `label-${id}`;
|
|
1741
|
+
const contentId = `content-${id}`;
|
|
1742
|
+
const title = group.label;
|
|
1743
|
+
return /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(
|
|
1744
|
+
ListItemButton3,
|
|
1745
|
+
{
|
|
1746
|
+
id: labelId,
|
|
1747
|
+
"aria-controls": contentId,
|
|
1748
|
+
"aria-label": `${title} section`,
|
|
1749
|
+
onClick: handleClick,
|
|
1750
|
+
p: 0,
|
|
1751
|
+
sx: { "&:hover": { backgroundColor: "transparent" } }
|
|
1752
|
+
},
|
|
1753
|
+
/* @__PURE__ */ React14.createElement(Stack8, { direction: "row", alignItems: "center", justifyItems: "start", flexGrow: 1, gap: 0.5 }, /* @__PURE__ */ React14.createElement(
|
|
1754
|
+
ListItemText2,
|
|
1755
|
+
{
|
|
1756
|
+
secondary: title,
|
|
1757
|
+
secondaryTypographyProps: { color: "text.primary", variant: "caption", fontWeight: "bold" },
|
|
1758
|
+
sx: { flexGrow: 0, flexShrink: 1, marginInlineEnd: 1 }
|
|
1759
|
+
}
|
|
1760
|
+
)),
|
|
1761
|
+
/* @__PURE__ */ React14.createElement(CollapseIcon, { open: isOpen, color: "secondary", fontSize: "tiny" })
|
|
1762
|
+
), /* @__PURE__ */ React14.createElement(Collapse, { id: contentId, "aria-labelledby": labelId, in: isOpen, timeout: "auto" }, /* @__PURE__ */ React14.createElement(Stack8, { direction: "column", gap: 1, p: 2 }, group.props.map((propId) => (
|
|
1763
|
+
// TODO: Render actual controls
|
|
1764
|
+
/* @__PURE__ */ React14.createElement("pre", { key: propId }, JSON.stringify(props[propId], null, 2))
|
|
1765
|
+
)))));
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
// src/components/instance-editing-panel/instance-editing-panel.tsx
|
|
1769
|
+
function InstanceEditingPanel() {
|
|
1770
|
+
const { element } = useElement();
|
|
1771
|
+
const settings = useElementSetting(element.id, "component_instance");
|
|
1772
|
+
const componentId = (componentInstancePropTypeUtil.extract(settings)?.component_id).value;
|
|
1773
|
+
const component = componentId ? selectComponent(getState5(), componentId) : null;
|
|
1774
|
+
const overridableProps = componentId ? selectOverridableProps(getState5(), componentId) : null;
|
|
1775
|
+
const componentInstanceId = useSelectedElement()?.element?.id ?? null;
|
|
1776
|
+
if (!componentId || !overridableProps || !component) {
|
|
1777
|
+
return null;
|
|
1778
|
+
}
|
|
1779
|
+
const panelTitle = __12("Edit %s", "elementor").replace("%s", component.name);
|
|
1780
|
+
const handleEditComponent = () => switchToComponent(componentId, componentInstanceId);
|
|
1781
|
+
const groups = overridableProps.groups.order.map(
|
|
1782
|
+
(groupId) => overridableProps.groups.items[groupId] ? overridableProps.groups.items[groupId] : null
|
|
1783
|
+
).filter(Boolean);
|
|
1784
|
+
const isEmpty = groups.length === 0 || Object.keys(overridableProps.props).length === 0;
|
|
1785
|
+
return /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(PanelHeader, { sx: { justifyContent: "start" } }, /* @__PURE__ */ React15.createElement(Stack9, { direction: "row", alignContent: "space-between", flexGrow: 1 }, /* @__PURE__ */ React15.createElement(Stack9, { direction: "row", alignItems: "center", justifyContent: "start", gap: 1, flexGrow: 1 }, /* @__PURE__ */ React15.createElement(ComponentsIcon3, { fontSize: "small", sx: { color: "text.tertiary" } }), /* @__PURE__ */ React15.createElement(PanelHeaderTitle, null, component.name)), /* @__PURE__ */ React15.createElement(Tooltip2, { title: panelTitle }, /* @__PURE__ */ React15.createElement(IconButton3, { size: "tiny", onClick: handleEditComponent, "aria-label": panelTitle }, /* @__PURE__ */ React15.createElement(PencilIcon2, { fontSize: "tiny" }))))), /* @__PURE__ */ React15.createElement(PanelBody, null, isEmpty ? /* @__PURE__ */ React15.createElement(EmptyState2, { onEditComponent: handleEditComponent }) : /* @__PURE__ */ React15.createElement(Stack9, { direction: "column", alignItems: "stretch" }, groups.map((group) => /* @__PURE__ */ React15.createElement(OverridePropsGroup, { key: group.id, group, props: overridableProps.props })))));
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
// src/components/overridable-props/overridable-prop-control.tsx
|
|
1789
|
+
import * as React17 from "react";
|
|
1790
|
+
import { ControlReplacementsProvider, PropKeyProvider, PropProvider, useBoundProp } from "@elementor/editor-controls";
|
|
1791
|
+
import { createTopLevelObjectType, useElement as useElement2 } from "@elementor/editor-editing-panel";
|
|
1792
|
+
import { __getState as getState7 } from "@elementor/store";
|
|
1793
|
+
|
|
1794
|
+
// src/prop-types/component-overridable-prop-type.ts
|
|
1795
|
+
import { createPropUtils as createPropUtils4 } from "@elementor/editor-props";
|
|
1796
|
+
import { z as z5 } from "@elementor/schema";
|
|
1797
|
+
var componentOverridablePropTypeUtil = createPropUtils4(
|
|
1798
|
+
"overridable",
|
|
1799
|
+
z5.object({
|
|
1800
|
+
override_key: z5.string(),
|
|
1801
|
+
origin_value: z5.object({
|
|
1802
|
+
$$type: z5.string(),
|
|
1803
|
+
value: z5.unknown()
|
|
1671
1804
|
}).nullable()
|
|
1672
1805
|
})
|
|
1673
1806
|
);
|
|
1674
1807
|
|
|
1675
1808
|
// src/provider/overridable-prop-context.tsx
|
|
1676
|
-
import * as
|
|
1809
|
+
import * as React16 from "react";
|
|
1677
1810
|
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
1678
1811
|
var OverridablePropContext = createContext2(null);
|
|
1679
1812
|
function OverridablePropProvider({ children, ...props }) {
|
|
1680
|
-
return /* @__PURE__ */
|
|
1813
|
+
return /* @__PURE__ */ React16.createElement(OverridablePropContext.Provider, { value: props }, children);
|
|
1681
1814
|
}
|
|
1682
1815
|
var useOverridablePropValue = () => useContext2(OverridablePropContext)?.value;
|
|
1683
1816
|
|
|
1684
1817
|
// src/store/actions/update-overridable-prop-origin-value.ts
|
|
1685
|
-
import { __dispatch as dispatch4, __getState as
|
|
1818
|
+
import { __dispatch as dispatch4, __getState as getState6 } from "@elementor/store";
|
|
1686
1819
|
function updateOverridablePropOriginValue(componentId, propValue) {
|
|
1687
|
-
const overridableProps = selectOverridableProps(
|
|
1820
|
+
const overridableProps = selectOverridableProps(getState6(), componentId);
|
|
1688
1821
|
if (!overridableProps) {
|
|
1689
1822
|
return;
|
|
1690
1823
|
}
|
|
@@ -1715,9 +1848,9 @@ function OverridablePropControl({
|
|
|
1715
1848
|
OriginalControl,
|
|
1716
1849
|
...props
|
|
1717
1850
|
}) {
|
|
1718
|
-
const { elementType } =
|
|
1851
|
+
const { elementType } = useElement2();
|
|
1719
1852
|
const { value, bind, setValue, placeholder, ...propContext } = useBoundProp(componentOverridablePropTypeUtil);
|
|
1720
|
-
const componentId = selectCurrentComponentId(
|
|
1853
|
+
const componentId = selectCurrentComponentId(getState7());
|
|
1721
1854
|
if (!componentId) {
|
|
1722
1855
|
throw new Error("Component ID is required");
|
|
1723
1856
|
}
|
|
@@ -1738,7 +1871,7 @@ function OverridablePropControl({
|
|
|
1738
1871
|
}
|
|
1739
1872
|
});
|
|
1740
1873
|
const objectPlaceholder = placeholder ? { [bind]: placeholder } : void 0;
|
|
1741
|
-
return /* @__PURE__ */
|
|
1874
|
+
return /* @__PURE__ */ React17.createElement(OverridablePropProvider, { value }, /* @__PURE__ */ React17.createElement(
|
|
1742
1875
|
PropProvider,
|
|
1743
1876
|
{
|
|
1744
1877
|
...propContext,
|
|
@@ -1747,23 +1880,23 @@ function OverridablePropControl({
|
|
|
1747
1880
|
value: { [bind]: value.origin_value },
|
|
1748
1881
|
placeholder: objectPlaceholder
|
|
1749
1882
|
},
|
|
1750
|
-
/* @__PURE__ */
|
|
1883
|
+
/* @__PURE__ */ React17.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React17.createElement(ControlReplacementsProvider, { replacements: [] }, /* @__PURE__ */ React17.createElement(OriginalControl, { ...props })))
|
|
1751
1884
|
));
|
|
1752
1885
|
}
|
|
1753
1886
|
|
|
1754
1887
|
// src/components/overridable-props/overridable-prop-indicator.tsx
|
|
1755
|
-
import * as
|
|
1888
|
+
import * as React20 from "react";
|
|
1756
1889
|
import { useBoundProp as useBoundProp2 } from "@elementor/editor-controls";
|
|
1757
|
-
import { useElement as
|
|
1890
|
+
import { useElement as useElement3 } from "@elementor/editor-editing-panel";
|
|
1758
1891
|
import { getWidgetsCache } from "@elementor/editor-elements";
|
|
1759
|
-
import { __getState as
|
|
1760
|
-
import { bindPopover, bindTrigger as bindTrigger2, Popover as Popover2, Tooltip as
|
|
1761
|
-
import { __ as
|
|
1892
|
+
import { __getState as getState10 } from "@elementor/store";
|
|
1893
|
+
import { bindPopover, bindTrigger as bindTrigger2, Popover as Popover2, Tooltip as Tooltip3, usePopupState as usePopupState2 } from "@elementor/ui";
|
|
1894
|
+
import { __ as __16 } from "@wordpress/i18n";
|
|
1762
1895
|
|
|
1763
1896
|
// src/store/actions/set-overridable-prop.ts
|
|
1764
|
-
import { __dispatch as dispatch5, __getState as
|
|
1897
|
+
import { __dispatch as dispatch5, __getState as getState8 } from "@elementor/store";
|
|
1765
1898
|
import { generateUniqueId as generateUniqueId2 } from "@elementor/utils";
|
|
1766
|
-
import { __ as
|
|
1899
|
+
import { __ as __13 } from "@wordpress/i18n";
|
|
1767
1900
|
function setOverridableProp({
|
|
1768
1901
|
componentId,
|
|
1769
1902
|
overrideKey,
|
|
@@ -1775,7 +1908,7 @@ function setOverridableProp({
|
|
|
1775
1908
|
widgetType,
|
|
1776
1909
|
originValue
|
|
1777
1910
|
}) {
|
|
1778
|
-
const overridableProps = selectOverridableProps(
|
|
1911
|
+
const overridableProps = selectOverridableProps(getState8(), componentId);
|
|
1779
1912
|
if (!overridableProps) {
|
|
1780
1913
|
return;
|
|
1781
1914
|
}
|
|
@@ -1853,7 +1986,7 @@ function addNewGroup(groups, groupId) {
|
|
|
1853
1986
|
...groups.items,
|
|
1854
1987
|
[currentGroupId]: {
|
|
1855
1988
|
id: currentGroupId,
|
|
1856
|
-
label:
|
|
1989
|
+
label: __13("Default", "elementor"),
|
|
1857
1990
|
props: []
|
|
1858
1991
|
}
|
|
1859
1992
|
},
|
|
@@ -1903,11 +2036,11 @@ function removeProps({
|
|
|
1903
2036
|
}
|
|
1904
2037
|
|
|
1905
2038
|
// src/components/overridable-props/indicator.tsx
|
|
1906
|
-
import * as
|
|
2039
|
+
import * as React18 from "react";
|
|
1907
2040
|
import { forwardRef } from "react";
|
|
1908
2041
|
import { CheckIcon, PlusIcon } from "@elementor/icons";
|
|
1909
2042
|
import { Box as Box8, styled as styled2 } from "@elementor/ui";
|
|
1910
|
-
import { __ as
|
|
2043
|
+
import { __ as __14 } from "@wordpress/i18n";
|
|
1911
2044
|
var SIZE = "tiny";
|
|
1912
2045
|
var IconContainer = styled2(Box8)`
|
|
1913
2046
|
pointer-events: none;
|
|
@@ -1963,33 +2096,33 @@ var Content = styled2(Box8)`
|
|
|
1963
2096
|
}
|
|
1964
2097
|
}
|
|
1965
2098
|
`;
|
|
1966
|
-
var Indicator = forwardRef(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */
|
|
2099
|
+
var Indicator = forwardRef(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */ React18.createElement(Content, { ref, ...props, className: isOpen || isOverridable ? "enlarged" : "" }, /* @__PURE__ */ React18.createElement(
|
|
1967
2100
|
IconContainer,
|
|
1968
2101
|
{
|
|
1969
2102
|
className: "icon",
|
|
1970
|
-
"aria-label": isOverridable ?
|
|
2103
|
+
"aria-label": isOverridable ? __14("Overridable property", "elementor") : __14("Make prop overridable", "elementor")
|
|
1971
2104
|
},
|
|
1972
|
-
isOverridable ? /* @__PURE__ */
|
|
2105
|
+
isOverridable ? /* @__PURE__ */ React18.createElement(CheckIcon, { fontSize: SIZE }) : /* @__PURE__ */ React18.createElement(PlusIcon, { fontSize: SIZE })
|
|
1973
2106
|
)));
|
|
1974
2107
|
|
|
1975
2108
|
// src/components/overridable-props/overridable-prop-form.tsx
|
|
1976
|
-
import * as
|
|
2109
|
+
import * as React19 from "react";
|
|
1977
2110
|
import { useState as useState4 } from "react";
|
|
1978
2111
|
import { Form as Form2, MenuListItem as MenuListItem2 } from "@elementor/editor-ui";
|
|
1979
|
-
import { Button as
|
|
1980
|
-
import { __ as
|
|
2112
|
+
import { Button as Button4, FormLabel as FormLabel2, Grid as Grid2, Select, Stack as Stack10, TextField as TextField3, Typography as Typography7 } from "@elementor/ui";
|
|
2113
|
+
import { __ as __15 } from "@wordpress/i18n";
|
|
1981
2114
|
var SIZE2 = "tiny";
|
|
1982
|
-
var DEFAULT_GROUP = { value: null, label:
|
|
2115
|
+
var DEFAULT_GROUP = { value: null, label: __15("Default", "elementor") };
|
|
1983
2116
|
function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
1984
2117
|
const [propLabel, setPropLabel] = useState4(currentValue?.label ?? null);
|
|
1985
2118
|
const [group, setGroup] = useState4(currentValue?.groupId ?? groups?.[0]?.value ?? null);
|
|
1986
|
-
const name =
|
|
1987
|
-
const groupName =
|
|
2119
|
+
const name = __15("Name", "elementor");
|
|
2120
|
+
const groupName = __15("Group Name", "elementor");
|
|
1988
2121
|
const isCreate = currentValue === void 0;
|
|
1989
|
-
const title = isCreate ?
|
|
1990
|
-
const ctaLabel = isCreate ?
|
|
1991
|
-
return /* @__PURE__ */
|
|
1992
|
-
|
|
2122
|
+
const title = isCreate ? __15("Create new property", "elementor") : __15("Update property", "elementor");
|
|
2123
|
+
const ctaLabel = isCreate ? __15("Create", "elementor") : __15("Update", "elementor");
|
|
2124
|
+
return /* @__PURE__ */ React19.createElement(Form2, { onSubmit: () => onSubmit({ label: propLabel ?? "", group }) }, /* @__PURE__ */ React19.createElement(Stack10, { alignItems: "start", width: "268px" }, /* @__PURE__ */ React19.createElement(
|
|
2125
|
+
Stack10,
|
|
1993
2126
|
{
|
|
1994
2127
|
direction: "row",
|
|
1995
2128
|
alignItems: "center",
|
|
@@ -1997,18 +2130,18 @@ function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
|
1997
2130
|
px: 1.5,
|
|
1998
2131
|
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%", mb: 1.5 }
|
|
1999
2132
|
},
|
|
2000
|
-
/* @__PURE__ */
|
|
2001
|
-
), /* @__PURE__ */
|
|
2133
|
+
/* @__PURE__ */ React19.createElement(Typography7, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, title)
|
|
2134
|
+
), /* @__PURE__ */ React19.createElement(Grid2, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React19.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React19.createElement(FormLabel2, { size: "tiny" }, name)), /* @__PURE__ */ React19.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React19.createElement(
|
|
2002
2135
|
TextField3,
|
|
2003
2136
|
{
|
|
2004
2137
|
name,
|
|
2005
2138
|
size: SIZE2,
|
|
2006
2139
|
fullWidth: true,
|
|
2007
|
-
placeholder:
|
|
2140
|
+
placeholder: __15("Enter value", "elementor"),
|
|
2008
2141
|
value: propLabel ?? "",
|
|
2009
2142
|
onChange: (e) => setPropLabel(e.target.value)
|
|
2010
2143
|
}
|
|
2011
|
-
))), /* @__PURE__ */
|
|
2144
|
+
))), /* @__PURE__ */ React19.createElement(Grid2, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React19.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React19.createElement(FormLabel2, { size: "tiny" }, groupName)), /* @__PURE__ */ React19.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React19.createElement(
|
|
2012
2145
|
Select,
|
|
2013
2146
|
{
|
|
2014
2147
|
name: groupName,
|
|
@@ -2025,17 +2158,17 @@ function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
|
2025
2158
|
return groups?.find(({ value }) => value === selectedValue)?.label ?? selectedValue;
|
|
2026
2159
|
}
|
|
2027
2160
|
},
|
|
2028
|
-
(groups ?? [DEFAULT_GROUP]).map(({ label: groupLabel, ...props }) => /* @__PURE__ */
|
|
2029
|
-
))), /* @__PURE__ */
|
|
2161
|
+
(groups ?? [DEFAULT_GROUP]).map(({ label: groupLabel, ...props }) => /* @__PURE__ */ React19.createElement(MenuListItem2, { key: props.value, ...props, value: props.value ?? "" }, groupLabel))
|
|
2162
|
+
))), /* @__PURE__ */ React19.createElement(Stack10, { direction: "row", justifyContent: "flex-end", alignSelf: "end", mt: 1.5, py: 1, px: 1.5 }, /* @__PURE__ */ React19.createElement(Button4, { type: "submit", disabled: !propLabel, variant: "contained", color: "primary", size: "small" }, ctaLabel))));
|
|
2030
2163
|
}
|
|
2031
2164
|
|
|
2032
2165
|
// src/components/overridable-props/utils/get-overridable-prop.ts
|
|
2033
|
-
import { __getState as
|
|
2166
|
+
import { __getState as getState9 } from "@elementor/store";
|
|
2034
2167
|
function getOverridableProp({
|
|
2035
2168
|
componentId,
|
|
2036
2169
|
overrideKey
|
|
2037
2170
|
}) {
|
|
2038
|
-
const overridableProps = selectOverridableProps(
|
|
2171
|
+
const overridableProps = selectOverridableProps(getState9(), componentId);
|
|
2039
2172
|
if (!overridableProps) {
|
|
2040
2173
|
return void 0;
|
|
2041
2174
|
}
|
|
@@ -2046,18 +2179,18 @@ function getOverridableProp({
|
|
|
2046
2179
|
var FORBIDDEN_KEYS = ["_cssid", "attributes"];
|
|
2047
2180
|
function OverridablePropIndicator() {
|
|
2048
2181
|
const { bind } = useBoundProp2();
|
|
2049
|
-
const componentId = selectCurrentComponentId(
|
|
2182
|
+
const componentId = selectCurrentComponentId(getState10());
|
|
2050
2183
|
if (!isPropAllowed(bind) || !componentId) {
|
|
2051
2184
|
return null;
|
|
2052
2185
|
}
|
|
2053
|
-
const overridableProps = selectOverridableProps(
|
|
2054
|
-
return /* @__PURE__ */
|
|
2186
|
+
const overridableProps = selectOverridableProps(getState10(), componentId);
|
|
2187
|
+
return /* @__PURE__ */ React20.createElement(Content2, { componentId, overridableProps });
|
|
2055
2188
|
}
|
|
2056
2189
|
function Content2({ componentId, overridableProps }) {
|
|
2057
2190
|
const {
|
|
2058
2191
|
element: { id: elementId },
|
|
2059
2192
|
elementType
|
|
2060
|
-
} =
|
|
2193
|
+
} = useElement3();
|
|
2061
2194
|
const { value, bind, propType } = useBoundProp2();
|
|
2062
2195
|
const contextOverridableValue = useOverridablePropValue();
|
|
2063
2196
|
const { value: boundPropOverridableValue, setValue: setOverridableValue } = useBoundProp2(
|
|
@@ -2092,7 +2225,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2092
2225
|
popupState.close();
|
|
2093
2226
|
};
|
|
2094
2227
|
const overridableConfig = overridableValue ? getOverridableProp({ componentId, overrideKey: overridableValue.override_key }) : void 0;
|
|
2095
|
-
return /* @__PURE__ */
|
|
2228
|
+
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Tooltip3, { placement: "top", title: __16("Override Property", "elementor") }, /* @__PURE__ */ React20.createElement(Indicator, { ...triggerProps, isOpen: !!popoverProps.open, isOverridable: !!overridableValue })), /* @__PURE__ */ React20.createElement(
|
|
2096
2229
|
Popover2,
|
|
2097
2230
|
{
|
|
2098
2231
|
disableScrollLock: true,
|
|
@@ -2109,7 +2242,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2109
2242
|
},
|
|
2110
2243
|
...popoverProps
|
|
2111
2244
|
},
|
|
2112
|
-
/* @__PURE__ */
|
|
2245
|
+
/* @__PURE__ */ React20.createElement(
|
|
2113
2246
|
OverridablePropForm,
|
|
2114
2247
|
{
|
|
2115
2248
|
onSubmit: handleSubmit,
|
|
@@ -2132,16 +2265,16 @@ import { getMCPByDomain as getMCPByDomain2 } from "@elementor/editor-mcp";
|
|
|
2132
2265
|
// src/mcp/save-as-component-tool.ts
|
|
2133
2266
|
import { getContainer as getContainer2 } from "@elementor/editor-elements";
|
|
2134
2267
|
import { getMCPByDomain } from "@elementor/editor-mcp";
|
|
2135
|
-
import { z as
|
|
2268
|
+
import { z as z6 } from "@elementor/schema";
|
|
2136
2269
|
var InputSchema = {
|
|
2137
|
-
element_id:
|
|
2270
|
+
element_id: z6.string().describe(
|
|
2138
2271
|
'The unique identifier of the element to save as a component. Use the "list-elements" tool to find available element IDs in the current document.'
|
|
2139
2272
|
),
|
|
2140
|
-
component_name:
|
|
2273
|
+
component_name: z6.string().describe("The name for the new component. Should be descriptive and unique among existing components.")
|
|
2141
2274
|
};
|
|
2142
2275
|
var OutputSchema = {
|
|
2143
|
-
message:
|
|
2144
|
-
component_uid:
|
|
2276
|
+
message: z6.string().optional().describe("Additional information about the operation result"),
|
|
2277
|
+
component_uid: z6.string().optional().describe("The unique identifier of the newly created component (only present on success)")
|
|
2145
2278
|
};
|
|
2146
2279
|
var VALID_ELEMENT_TYPES = ["e-div-block", "e-flexbox", "e-tabs"];
|
|
2147
2280
|
var ERROR_MESSAGES = {
|
|
@@ -2229,7 +2362,7 @@ function removeComponentStyles(id) {
|
|
|
2229
2362
|
|
|
2230
2363
|
// src/store/components-styles-provider.ts
|
|
2231
2364
|
import { createStylesProvider } from "@elementor/editor-styles-repository";
|
|
2232
|
-
import { __getState as
|
|
2365
|
+
import { __getState as getState11, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
|
|
2233
2366
|
var componentsStylesProvider = createStylesProvider({
|
|
2234
2367
|
key: "components-styles",
|
|
2235
2368
|
priority: 100,
|
|
@@ -2241,22 +2374,22 @@ var componentsStylesProvider = createStylesProvider({
|
|
|
2241
2374
|
),
|
|
2242
2375
|
actions: {
|
|
2243
2376
|
all: () => {
|
|
2244
|
-
return selectFlatStyles(
|
|
2377
|
+
return selectFlatStyles(getState11());
|
|
2245
2378
|
},
|
|
2246
2379
|
get: (id) => {
|
|
2247
|
-
return selectFlatStyles(
|
|
2380
|
+
return selectFlatStyles(getState11()).find((style) => style.id === id) ?? null;
|
|
2248
2381
|
}
|
|
2249
2382
|
}
|
|
2250
2383
|
});
|
|
2251
2384
|
|
|
2252
2385
|
// src/sync/create-components-before-save.ts
|
|
2253
2386
|
import { updateElementSettings } from "@elementor/editor-elements";
|
|
2254
|
-
import { __dispatch as dispatch8, __getState as
|
|
2387
|
+
import { __dispatch as dispatch8, __getState as getState12 } from "@elementor/store";
|
|
2255
2388
|
async function createComponentsBeforeSave({
|
|
2256
2389
|
elements,
|
|
2257
2390
|
status
|
|
2258
2391
|
}) {
|
|
2259
|
-
const unpublishedComponents = selectUnpublishedComponents(
|
|
2392
|
+
const unpublishedComponents = selectUnpublishedComponents(getState12());
|
|
2260
2393
|
if (!unpublishedComponents.length) {
|
|
2261
2394
|
return;
|
|
2262
2395
|
}
|
|
@@ -2328,7 +2461,7 @@ function updateElementComponentId(elementId, componentId) {
|
|
|
2328
2461
|
}
|
|
2329
2462
|
|
|
2330
2463
|
// src/sync/set-component-overridable-props-settings-before-save.ts
|
|
2331
|
-
import { __getState as
|
|
2464
|
+
import { __getState as getState13 } from "@elementor/store";
|
|
2332
2465
|
var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
2333
2466
|
container
|
|
2334
2467
|
}) => {
|
|
@@ -2336,7 +2469,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
2336
2469
|
if (!currentDocument || currentDocument.config.type !== COMPONENT_DOCUMENT_TYPE) {
|
|
2337
2470
|
return;
|
|
2338
2471
|
}
|
|
2339
|
-
const overridableProps = selectOverridableProps(
|
|
2472
|
+
const overridableProps = selectOverridableProps(getState13(), currentDocument.id);
|
|
2340
2473
|
if (overridableProps) {
|
|
2341
2474
|
container.settings.set("overridable_props", overridableProps);
|
|
2342
2475
|
}
|
|
@@ -2344,7 +2477,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
2344
2477
|
|
|
2345
2478
|
// src/sync/update-archived-component-before-save.ts
|
|
2346
2479
|
import { notify } from "@elementor/editor-notifications";
|
|
2347
|
-
import { __getState as
|
|
2480
|
+
import { __getState as getState14 } from "@elementor/store";
|
|
2348
2481
|
var failedNotification = (message) => ({
|
|
2349
2482
|
type: "error",
|
|
2350
2483
|
message: `Failed to archive components: ${message}`,
|
|
@@ -2357,7 +2490,7 @@ var successNotification = (message) => ({
|
|
|
2357
2490
|
});
|
|
2358
2491
|
var updateArchivedComponentBeforeSave = async () => {
|
|
2359
2492
|
try {
|
|
2360
|
-
const archivedComponents = selectArchivedComponents(
|
|
2493
|
+
const archivedComponents = selectArchivedComponents(getState14());
|
|
2361
2494
|
if (!archivedComponents.length) {
|
|
2362
2495
|
return;
|
|
2363
2496
|
}
|
|
@@ -2423,7 +2556,7 @@ function init() {
|
|
|
2423
2556
|
window.elementorCommon.__beforeSave = beforeSave;
|
|
2424
2557
|
injectTab({
|
|
2425
2558
|
id: "components",
|
|
2426
|
-
label:
|
|
2559
|
+
label: __17("Components", "elementor"),
|
|
2427
2560
|
component: Components
|
|
2428
2561
|
});
|
|
2429
2562
|
injectIntoTop({
|
|
@@ -2459,6 +2592,11 @@ function init() {
|
|
|
2459
2592
|
component: OverridablePropControl,
|
|
2460
2593
|
condition: ({ value }) => componentOverridablePropTypeUtil.isValid(value)
|
|
2461
2594
|
});
|
|
2595
|
+
registerEditingPanelReplacement({
|
|
2596
|
+
id: "component-instance-edit-panel",
|
|
2597
|
+
condition: (_, elementType) => elementType.key === "e-component",
|
|
2598
|
+
component: InstanceEditingPanel
|
|
2599
|
+
});
|
|
2462
2600
|
settingsTransformersRegistry2.register("component-instance", componentInstanceTransformer);
|
|
2463
2601
|
settingsTransformersRegistry2.register("overridable", componentOverridableTransformer);
|
|
2464
2602
|
initMcp();
|