@elementor/editor-components 4.1.0-748 → 4.1.0-750
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.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +246 -179
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +230 -158
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -23
- package/src/components/errors.ts +7 -0
- package/src/components/instance-editing-panel/override-prop-control.tsx +57 -143
- package/src/components/instance-editing-panel/utils/resolve-element-settings.ts +1 -1
- package/src/components/instance-editing-panel/utils/use-override-dependencies.ts +73 -0
- package/src/components/instance-editing-panel/utils/use-resolved-inner-element.ts +111 -0
- package/src/provider/component-instance-context.tsx +13 -3
- package/src/utils/resolve-override-prop-value.ts +9 -7
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _elementor_editor_elements from '@elementor/editor-elements';
|
|
|
3
3
|
import { V1ElementData, V1Element, V1ElementModelProps } from '@elementor/editor-elements';
|
|
4
4
|
import { HttpResponse } from '@elementor/http-client';
|
|
5
5
|
import * as _elementor_editor_props from '@elementor/editor-props';
|
|
6
|
-
import { PropValue } from '@elementor/editor-props';
|
|
6
|
+
import { PropValue, AnyTransformable } from '@elementor/editor-props';
|
|
7
7
|
import { StyleDefinition } from '@elementor/editor-styles';
|
|
8
8
|
import * as React from 'react';
|
|
9
9
|
import { ElementType, PropsWithChildren } from 'react';
|
|
@@ -1409,7 +1409,7 @@ declare const getPropTypeForComponentOverride: (overridableProp: OverridableProp
|
|
|
1409
1409
|
|
|
1410
1410
|
declare function isComponentInstance(elementModel: Partial<V1ElementModelProps>): boolean;
|
|
1411
1411
|
|
|
1412
|
-
declare const resolveOverridePropValue: (originalPropValue: ComponentInstanceOverride | PropValue) =>
|
|
1412
|
+
declare const resolveOverridePropValue: (originalPropValue: ComponentInstanceOverride | PropValue) => AnyTransformable | null;
|
|
1413
1413
|
|
|
1414
1414
|
declare function switchToComponent(componentId: number, componentInstanceId?: string | null, element?: HTMLElement | null): Promise<void>;
|
|
1415
1415
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _elementor_editor_elements from '@elementor/editor-elements';
|
|
|
3
3
|
import { V1ElementData, V1Element, V1ElementModelProps } from '@elementor/editor-elements';
|
|
4
4
|
import { HttpResponse } from '@elementor/http-client';
|
|
5
5
|
import * as _elementor_editor_props from '@elementor/editor-props';
|
|
6
|
-
import { PropValue } from '@elementor/editor-props';
|
|
6
|
+
import { PropValue, AnyTransformable } from '@elementor/editor-props';
|
|
7
7
|
import { StyleDefinition } from '@elementor/editor-styles';
|
|
8
8
|
import * as React from 'react';
|
|
9
9
|
import { ElementType, PropsWithChildren } from 'react';
|
|
@@ -1409,7 +1409,7 @@ declare const getPropTypeForComponentOverride: (overridableProp: OverridableProp
|
|
|
1409
1409
|
|
|
1410
1410
|
declare function isComponentInstance(elementModel: Partial<V1ElementModelProps>): boolean;
|
|
1411
1411
|
|
|
1412
|
-
declare const resolveOverridePropValue: (originalPropValue: ComponentInstanceOverride | PropValue) =>
|
|
1412
|
+
declare const resolveOverridePropValue: (originalPropValue: ComponentInstanceOverride | PropValue) => AnyTransformable | null;
|
|
1413
1413
|
|
|
1414
1414
|
declare function switchToComponent(componentId: number, componentInstanceId?: string | null, element?: HTMLElement | null): Promise<void>;
|
|
1415
1415
|
|
package/dist/index.js
CHANGED
|
@@ -90,7 +90,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
90
90
|
var import_editor = require("@elementor/editor");
|
|
91
91
|
var import_editor_canvas5 = require("@elementor/editor-canvas");
|
|
92
92
|
var import_editor_documents6 = require("@elementor/editor-documents");
|
|
93
|
-
var
|
|
93
|
+
var import_editor_editing_panel7 = require("@elementor/editor-editing-panel");
|
|
94
94
|
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
95
95
|
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
96
96
|
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
@@ -1101,9 +1101,16 @@ var ComponentInstanceContext = (0, import_react4.createContext)(null);
|
|
|
1101
1101
|
function ComponentInstanceProvider({ children, ...props }) {
|
|
1102
1102
|
return /* @__PURE__ */ React13.createElement(ComponentInstanceContext.Provider, { value: props }, children);
|
|
1103
1103
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1104
|
+
function useComponentInstanceContext() {
|
|
1105
|
+
const context = (0, import_react4.useContext)(ComponentInstanceContext);
|
|
1106
|
+
if (!context) {
|
|
1107
|
+
throw new Error("useComponentInstanceContext must be used within a ComponentInstanceProvider");
|
|
1108
|
+
}
|
|
1109
|
+
return context;
|
|
1110
|
+
}
|
|
1111
|
+
var useComponentId = () => useComponentInstanceContext().componentId;
|
|
1112
|
+
var useComponentInstanceOverrides = () => useComponentInstanceContext().overrides;
|
|
1113
|
+
var useComponentOverridableProps = () => useComponentInstanceContext().overridableProps;
|
|
1107
1114
|
|
|
1108
1115
|
// src/components/instance-editing-panel/detach-action.tsx
|
|
1109
1116
|
var React15 = __toESM(require("react"));
|
|
@@ -1592,23 +1599,21 @@ var EmptyState2 = ({ onEditComponent }) => {
|
|
|
1592
1599
|
// src/components/instance-editing-panel/instance-panel-body.tsx
|
|
1593
1600
|
var React21 = __toESM(require("react"));
|
|
1594
1601
|
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
1595
|
-
var
|
|
1602
|
+
var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
|
|
1596
1603
|
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
1597
1604
|
var import_ui14 = require("@elementor/ui");
|
|
1598
1605
|
|
|
1599
1606
|
// src/components/instance-editing-panel/override-props-group.tsx
|
|
1600
1607
|
var React20 = __toESM(require("react"));
|
|
1601
|
-
var
|
|
1602
|
-
var
|
|
1608
|
+
var import_react9 = require("react");
|
|
1609
|
+
var import_editor_editing_panel4 = require("@elementor/editor-editing-panel");
|
|
1603
1610
|
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
1604
1611
|
var import_ui13 = require("@elementor/ui");
|
|
1605
1612
|
|
|
1606
1613
|
// src/components/instance-editing-panel/override-prop-control.tsx
|
|
1607
1614
|
var React19 = __toESM(require("react"));
|
|
1608
|
-
var import_react7 = require("react");
|
|
1609
1615
|
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
1610
|
-
var
|
|
1611
|
-
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
1616
|
+
var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
|
|
1612
1617
|
var import_ui12 = require("@elementor/ui");
|
|
1613
1618
|
|
|
1614
1619
|
// src/hooks/use-controls-by-widget-type.ts
|
|
@@ -1840,6 +1845,128 @@ function getMatchingOverride(overrides, overrideKey) {
|
|
|
1840
1845
|
}) ?? null;
|
|
1841
1846
|
}
|
|
1842
1847
|
|
|
1848
|
+
// src/components/control-label.tsx
|
|
1849
|
+
var React18 = __toESM(require("react"));
|
|
1850
|
+
var import_editor_controls = require("@elementor/editor-controls");
|
|
1851
|
+
var import_ui11 = require("@elementor/ui");
|
|
1852
|
+
var ControlLabel = ({ children, ...props }) => {
|
|
1853
|
+
return /* @__PURE__ */ React18.createElement(import_ui11.Stack, { direction: "row", alignItems: "center", justifyItems: "start", gap: 0.25 }, /* @__PURE__ */ React18.createElement(import_editor_controls.ControlFormLabel, { ...props }, children), /* @__PURE__ */ React18.createElement(import_editor_controls.ControlAdornments, null));
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1856
|
+
// src/components/errors.ts
|
|
1857
|
+
var import_utils3 = require("@elementor/utils");
|
|
1858
|
+
var OverrideControlInnerElementNotFoundError = (0, import_utils3.createError)({
|
|
1859
|
+
code: "override_control_inner_element_not_found",
|
|
1860
|
+
message: `Component inner element not found for override control. The element may have been deleted without updating the overridable props, or the component has not finished rendering yet.`
|
|
1861
|
+
});
|
|
1862
|
+
var OverrideControlPropTypeNotFoundError = (0, import_utils3.createError)({
|
|
1863
|
+
code: "override_control_prop_type_not_found",
|
|
1864
|
+
message: "Prop type not found for override control."
|
|
1865
|
+
});
|
|
1866
|
+
|
|
1867
|
+
// src/components/instance-editing-panel/utils/correct-exposed-empty-override.ts
|
|
1868
|
+
function correctExposedEmptyOverride(newPropValue, matchingOverride) {
|
|
1869
|
+
const newOverridableValue = componentOverridablePropTypeUtil.extract(newPropValue);
|
|
1870
|
+
const isExposingEmptyOverride = newOverridableValue && matchingOverride === null;
|
|
1871
|
+
if (!isExposingEmptyOverride) {
|
|
1872
|
+
return newPropValue;
|
|
1873
|
+
}
|
|
1874
|
+
return componentOverridablePropTypeUtil.create({
|
|
1875
|
+
override_key: newOverridableValue.override_key,
|
|
1876
|
+
origin_value: null
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
// src/components/instance-editing-panel/utils/resolve-element-settings.ts
|
|
1881
|
+
function applyOverridesToSettings(elementSettings, overrides) {
|
|
1882
|
+
const result = {};
|
|
1883
|
+
for (const [propKey, propValue] of Object.entries(elementSettings)) {
|
|
1884
|
+
const overridable = componentOverridablePropTypeUtil.extract(propValue);
|
|
1885
|
+
if (!overridable) {
|
|
1886
|
+
result[propKey] = propValue;
|
|
1887
|
+
continue;
|
|
1888
|
+
}
|
|
1889
|
+
const override = overrides[overridable.override_key];
|
|
1890
|
+
if (!override) {
|
|
1891
|
+
result[propKey] = propValue;
|
|
1892
|
+
continue;
|
|
1893
|
+
}
|
|
1894
|
+
if (override.outermostKey && override.outermostKey !== overridable.override_key) {
|
|
1895
|
+
const originValue = overridable.origin_value;
|
|
1896
|
+
result[propKey] = componentOverridablePropTypeUtil.create({
|
|
1897
|
+
override_key: override.outermostKey,
|
|
1898
|
+
origin_value: override.value ?? originValue
|
|
1899
|
+
});
|
|
1900
|
+
} else {
|
|
1901
|
+
result[propKey] = override.value ?? propValue;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
return result;
|
|
1905
|
+
}
|
|
1906
|
+
function unwrapOverridableSettings(elementSettings) {
|
|
1907
|
+
const result = {};
|
|
1908
|
+
for (const [propKey, propValue] of Object.entries(elementSettings)) {
|
|
1909
|
+
const overridable = componentOverridablePropTypeUtil.extract(propValue);
|
|
1910
|
+
if (!overridable) {
|
|
1911
|
+
result[propKey] = propValue;
|
|
1912
|
+
continue;
|
|
1913
|
+
}
|
|
1914
|
+
result[propKey] = overridable.origin_value;
|
|
1915
|
+
}
|
|
1916
|
+
return result;
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
// src/components/instance-editing-panel/utils/use-override-dependencies.ts
|
|
1920
|
+
var import_react7 = require("react");
|
|
1921
|
+
var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
1922
|
+
function useOverrideControlDependencies({
|
|
1923
|
+
existingOverride,
|
|
1924
|
+
resolvedElementSettings,
|
|
1925
|
+
elementId,
|
|
1926
|
+
elementType,
|
|
1927
|
+
propKey
|
|
1928
|
+
}) {
|
|
1929
|
+
return (0, import_react7.useMemo)(() => {
|
|
1930
|
+
const { isDisabled, isHidden } = (0, import_editor_editing_panel.extractDependencyEffect)(
|
|
1931
|
+
propKey,
|
|
1932
|
+
elementType.propsSchema,
|
|
1933
|
+
resolvedElementSettings
|
|
1934
|
+
);
|
|
1935
|
+
const existingOverrideValue = existingOverride ? resolveOverridePropValue(existingOverride) : null;
|
|
1936
|
+
const settingsForDepsNewValuesCalculation = { ...resolvedElementSettings, [propKey]: existingOverrideValue };
|
|
1937
|
+
const resolvedSettingsWithDefaults = (0, import_editor_editing_panel.getElementSettingsWithDefaults)(
|
|
1938
|
+
elementType.propsSchema,
|
|
1939
|
+
settingsForDepsNewValuesCalculation
|
|
1940
|
+
);
|
|
1941
|
+
const dependents = (0, import_editor_editing_panel.extractOrderedDependencies)(elementType.dependenciesPerTargetMapping ?? {});
|
|
1942
|
+
const settingsWithDepsNewValues = (0, import_editor_editing_panel.getUpdatedValues)(
|
|
1943
|
+
settingsForDepsNewValuesCalculation,
|
|
1944
|
+
dependents,
|
|
1945
|
+
elementType.propsSchema,
|
|
1946
|
+
resolvedSettingsWithDefaults,
|
|
1947
|
+
elementId
|
|
1948
|
+
);
|
|
1949
|
+
const overrideValue = settingsWithDepsNewValues[propKey];
|
|
1950
|
+
return {
|
|
1951
|
+
overrideValue,
|
|
1952
|
+
isDisabled,
|
|
1953
|
+
isHidden
|
|
1954
|
+
};
|
|
1955
|
+
}, [
|
|
1956
|
+
existingOverride,
|
|
1957
|
+
resolvedElementSettings,
|
|
1958
|
+
propKey,
|
|
1959
|
+
elementType.propsSchema,
|
|
1960
|
+
elementType.dependenciesPerTargetMapping,
|
|
1961
|
+
elementId
|
|
1962
|
+
]);
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
// src/components/instance-editing-panel/utils/use-resolved-inner-element.ts
|
|
1966
|
+
var import_react8 = require("react");
|
|
1967
|
+
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
1968
|
+
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
1969
|
+
|
|
1843
1970
|
// src/utils/get-container-by-origin-id.ts
|
|
1844
1971
|
var import_editor_elements6 = require("@elementor/editor-elements");
|
|
1845
1972
|
function getContainerByOriginId(originElementId, instanceElementId) {
|
|
@@ -1974,109 +2101,18 @@ function findOverrideByOuterKey(overrides, outerKey) {
|
|
|
1974
2101
|
return override;
|
|
1975
2102
|
}
|
|
1976
2103
|
|
|
1977
|
-
// src/components/
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
var import_ui11 = require("@elementor/ui");
|
|
1981
|
-
var ControlLabel = ({ children, ...props }) => {
|
|
1982
|
-
return /* @__PURE__ */ React18.createElement(import_ui11.Stack, { direction: "row", alignItems: "center", justifyItems: "start", gap: 0.25 }, /* @__PURE__ */ React18.createElement(import_editor_controls.ControlFormLabel, { ...props }, children), /* @__PURE__ */ React18.createElement(import_editor_controls.ControlAdornments, null));
|
|
1983
|
-
};
|
|
1984
|
-
|
|
1985
|
-
// src/components/errors.ts
|
|
1986
|
-
var import_utils3 = require("@elementor/utils");
|
|
1987
|
-
var OverrideControlInnerElementNotFoundError = (0, import_utils3.createError)({
|
|
1988
|
-
code: "override_control_inner_element_not_found",
|
|
1989
|
-
message: `Component inner element not found for override control. The element may have been deleted without updating the overridable props, or the component has not finished rendering yet.`
|
|
1990
|
-
});
|
|
1991
|
-
|
|
1992
|
-
// src/components/instance-editing-panel/utils/correct-exposed-empty-override.ts
|
|
1993
|
-
function correctExposedEmptyOverride(newPropValue, matchingOverride) {
|
|
1994
|
-
const newOverridableValue = componentOverridablePropTypeUtil.extract(newPropValue);
|
|
1995
|
-
const isExposingEmptyOverride = newOverridableValue && matchingOverride === null;
|
|
1996
|
-
if (!isExposingEmptyOverride) {
|
|
1997
|
-
return newPropValue;
|
|
1998
|
-
}
|
|
1999
|
-
return componentOverridablePropTypeUtil.create({
|
|
2000
|
-
override_key: newOverridableValue.override_key,
|
|
2001
|
-
origin_value: null
|
|
2002
|
-
});
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
|
-
// src/components/instance-editing-panel/utils/resolve-element-settings.ts
|
|
2006
|
-
function applyOverridesToSettings(elementSettings, overrides) {
|
|
2007
|
-
const result = {};
|
|
2008
|
-
for (const [propKey, propValue] of Object.entries(elementSettings)) {
|
|
2009
|
-
const overridable = componentOverridablePropTypeUtil.extract(propValue);
|
|
2010
|
-
if (!overridable) {
|
|
2011
|
-
result[propKey] = propValue;
|
|
2012
|
-
continue;
|
|
2013
|
-
}
|
|
2014
|
-
const override = overrides[overridable.override_key];
|
|
2015
|
-
if (!override) {
|
|
2016
|
-
result[propKey] = propValue;
|
|
2017
|
-
continue;
|
|
2018
|
-
}
|
|
2019
|
-
if (override.outermostKey && override.outermostKey !== overridable.override_key) {
|
|
2020
|
-
const originValue = overridable.origin_value;
|
|
2021
|
-
result[propKey] = componentOverridablePropTypeUtil.create({
|
|
2022
|
-
override_key: override.outermostKey,
|
|
2023
|
-
origin_value: override.value ?? originValue
|
|
2024
|
-
});
|
|
2025
|
-
} else {
|
|
2026
|
-
result[propKey] = override.value ?? propValue;
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
2029
|
-
return result;
|
|
2030
|
-
}
|
|
2031
|
-
function unwrapOverridableSettings(elementSettings) {
|
|
2032
|
-
const result = {};
|
|
2033
|
-
for (const [propKey, propValue] of Object.entries(elementSettings)) {
|
|
2034
|
-
const overridable = componentOverridablePropTypeUtil.extract(propValue);
|
|
2035
|
-
if (!overridable) {
|
|
2036
|
-
result[propKey] = propValue;
|
|
2037
|
-
continue;
|
|
2038
|
-
}
|
|
2039
|
-
result[propKey] = overridable.origin_value;
|
|
2040
|
-
}
|
|
2041
|
-
return result;
|
|
2042
|
-
}
|
|
2043
|
-
|
|
2044
|
-
// src/components/instance-editing-panel/override-prop-control.tsx
|
|
2045
|
-
function OverridePropControl({ overrideKey }) {
|
|
2046
|
-
const overridableProps = useComponentOverridableProps();
|
|
2047
|
-
const overridableProp = overridableProps?.props[overrideKey];
|
|
2048
|
-
if (!overridableProp) {
|
|
2049
|
-
return null;
|
|
2050
|
-
}
|
|
2051
|
-
return /* @__PURE__ */ React19.createElement(import_editor_editing_panel.SettingsField, { bind: "component_instance", propDisplayName: overridableProp.label }, /* @__PURE__ */ React19.createElement(OverrideControl, { overridableProp }));
|
|
2052
|
-
}
|
|
2053
|
-
function OverrideControl({ overridableProp }) {
|
|
2054
|
-
const componentInstanceElement = (0, import_editor_editing_panel.useElement)();
|
|
2055
|
-
const { value: instanceValue, setValue: setInstanceValue } = (0, import_editor_controls2.useBoundProp)(componentInstancePropTypeUtil);
|
|
2056
|
-
const wrappingComponentId = useCurrentComponentId();
|
|
2104
|
+
// src/components/instance-editing-panel/utils/use-resolved-inner-element.ts
|
|
2105
|
+
function useResolvedInnerElement(overridableProp) {
|
|
2106
|
+
const componentInstanceElement = (0, import_editor_editing_panel2.useElement)();
|
|
2057
2107
|
const componentId = useComponentId();
|
|
2058
|
-
const overridableProps = useComponentOverridableProps();
|
|
2059
2108
|
const overrides = useComponentInstanceOverrides();
|
|
2060
|
-
const
|
|
2061
|
-
overridableProp?.originPropFields?.widgetType ?? overridableProp.widgetType
|
|
2062
|
-
);
|
|
2063
|
-
const controlReplacements = (0, import_editor_controls2.getControlReplacements)();
|
|
2064
|
-
const matchingOverride = getMatchingOverride(overrides, overridableProp.overrideKey);
|
|
2065
|
-
if (!componentId) {
|
|
2066
|
-
throw new Error("Component ID is required");
|
|
2067
|
-
}
|
|
2068
|
-
if (!overridableProps) {
|
|
2069
|
-
throw new Error("Component has no overridable props");
|
|
2070
|
-
}
|
|
2071
|
-
const {
|
|
2072
|
-
elementId: originElementId,
|
|
2073
|
-
widgetType,
|
|
2074
|
-
elType,
|
|
2075
|
-
propKey
|
|
2076
|
-
} = overridableProp.originPropFields ?? overridableProp;
|
|
2109
|
+
const { elementId: originElementId, widgetType, elType } = overridableProp.originPropFields ?? overridableProp;
|
|
2077
2110
|
const type = elType === "widget" ? widgetType : elType;
|
|
2078
2111
|
const elementType = (0, import_editor_elements7.getElementType)(type);
|
|
2079
|
-
|
|
2112
|
+
if (!elementType) {
|
|
2113
|
+
throw new Error(`Element type not found for ${type}`);
|
|
2114
|
+
}
|
|
2115
|
+
const { elementId, overridesMapping } = (0, import_react8.useMemo)(() => {
|
|
2080
2116
|
const overridesChainResult = resolveOverridesChain({
|
|
2081
2117
|
outerOverridableProp: overridableProp,
|
|
2082
2118
|
outerInstanceId: componentInstanceElement.element.id
|
|
@@ -2091,27 +2127,90 @@ function OverrideControl({ overridableProp }) {
|
|
|
2091
2127
|
overridesMapping: overridesChainResult.overridesMapping
|
|
2092
2128
|
};
|
|
2093
2129
|
}, [overridableProp, componentInstanceElement.element.id, componentId, originElementId]);
|
|
2094
|
-
const settingsWithInnerOverrides = (0,
|
|
2130
|
+
const settingsWithInnerOverrides = (0, import_react8.useMemo)(() => {
|
|
2095
2131
|
const settings = (0, import_editor_elements7.getElementSettings)(
|
|
2096
2132
|
elementId,
|
|
2097
2133
|
Object.keys(elementType?.propsSchema ?? {})
|
|
2098
2134
|
);
|
|
2099
2135
|
return applyOverridesToSettings(settings, overridesMapping);
|
|
2100
2136
|
}, [elementId, elementType?.propsSchema, overridesMapping]);
|
|
2101
|
-
const resolvedElementSettings = (0,
|
|
2137
|
+
const resolvedElementSettings = (0, import_react8.useMemo)(() => {
|
|
2102
2138
|
const withAllOverrides = applyOverridesToSettings(
|
|
2103
2139
|
settingsWithInnerOverrides,
|
|
2104
2140
|
formatOverridesToApply(overrides)
|
|
2105
2141
|
);
|
|
2106
2142
|
return unwrapOverridableSettings(withAllOverrides);
|
|
2107
2143
|
}, [settingsWithInnerOverrides, overrides]);
|
|
2144
|
+
return {
|
|
2145
|
+
elementId,
|
|
2146
|
+
elementType,
|
|
2147
|
+
resolvedOriginValues: settingsWithInnerOverrides,
|
|
2148
|
+
resolvedElementSettings
|
|
2149
|
+
};
|
|
2150
|
+
}
|
|
2151
|
+
function formatOverridesToApply(overrides) {
|
|
2152
|
+
if (!overrides) {
|
|
2153
|
+
return {};
|
|
2154
|
+
}
|
|
2155
|
+
const result = {};
|
|
2156
|
+
for (const item of overrides) {
|
|
2157
|
+
const overridable = componentOverridablePropTypeUtil.extract(item);
|
|
2158
|
+
let override = item;
|
|
2159
|
+
if (overridable) {
|
|
2160
|
+
override = overridable.origin_value;
|
|
2161
|
+
}
|
|
2162
|
+
const extractedOverride = componentInstanceOverridePropTypeUtil.extract(override);
|
|
2163
|
+
if (!extractedOverride) {
|
|
2164
|
+
continue;
|
|
2165
|
+
}
|
|
2166
|
+
result[extractedOverride.override_key] = {
|
|
2167
|
+
value: extractedOverride.override_value
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
return result;
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
// src/components/instance-editing-panel/override-prop-control.tsx
|
|
2174
|
+
function OverridePropControl({ overrideKey }) {
|
|
2175
|
+
const overridableProps = useComponentOverridableProps();
|
|
2176
|
+
const overridableProp = overridableProps.props[overrideKey];
|
|
2177
|
+
if (!overridableProp) {
|
|
2178
|
+
return null;
|
|
2179
|
+
}
|
|
2180
|
+
return /* @__PURE__ */ React19.createElement(import_editor_editing_panel3.SettingsField, { bind: "component_instance", propDisplayName: overridableProp.label }, /* @__PURE__ */ React19.createElement(OverrideControl, { overridableProp }));
|
|
2181
|
+
}
|
|
2182
|
+
function OverrideControl({ overridableProp }) {
|
|
2183
|
+
const componentInstanceElement = (0, import_editor_editing_panel3.useElement)();
|
|
2184
|
+
const { value: instanceValue, setValue: setInstanceValue } = (0, import_editor_controls2.useBoundProp)(componentInstancePropTypeUtil);
|
|
2185
|
+
const wrappingComponentId = useCurrentComponentId();
|
|
2186
|
+
const componentId = useComponentId();
|
|
2187
|
+
const overridableProps = useComponentOverridableProps();
|
|
2188
|
+
const overrides = useComponentInstanceOverrides();
|
|
2189
|
+
const controls = useControlsByWidgetType(
|
|
2190
|
+
overridableProp.originPropFields?.widgetType ?? overridableProp.widgetType
|
|
2191
|
+
);
|
|
2192
|
+
const controlReplacements = (0, import_editor_controls2.getControlReplacements)();
|
|
2193
|
+
const matchingOverride = getMatchingOverride(overrides, overridableProp.overrideKey);
|
|
2194
|
+
const { propKey } = overridableProp.originPropFields ?? overridableProp;
|
|
2108
2195
|
const propType = getPropTypeForComponentOverride(overridableProp);
|
|
2109
|
-
if (!propType
|
|
2196
|
+
if (!propType) {
|
|
2197
|
+
throw new OverrideControlPropTypeNotFoundError({ context: { overridableProp } });
|
|
2198
|
+
}
|
|
2199
|
+
const { elementId, elementType, resolvedElementSettings, resolvedOriginValues } = useResolvedInnerElement(overridableProp);
|
|
2200
|
+
const { overrideValue, isDisabled, isHidden } = useOverrideControlDependencies({
|
|
2201
|
+
existingOverride: matchingOverride,
|
|
2202
|
+
resolvedElementSettings,
|
|
2203
|
+
elementType,
|
|
2204
|
+
elementId,
|
|
2205
|
+
propKey
|
|
2206
|
+
});
|
|
2207
|
+
if (isHidden) {
|
|
2110
2208
|
return null;
|
|
2111
2209
|
}
|
|
2112
2210
|
const { propValue, placeholderValue } = resolveValueAndPlaceholder(
|
|
2113
2211
|
matchingOverride,
|
|
2114
|
-
|
|
2212
|
+
overrideValue,
|
|
2213
|
+
resolvedOriginValues,
|
|
2115
2214
|
propKey
|
|
2116
2215
|
);
|
|
2117
2216
|
const value = {
|
|
@@ -2120,14 +2219,15 @@ function OverrideControl({ overridableProp }) {
|
|
|
2120
2219
|
const placeholder = {
|
|
2121
2220
|
[overridableProp.overrideKey]: placeholderValue
|
|
2122
2221
|
};
|
|
2222
|
+
const { control, controlProps, layout } = getControlParams(
|
|
2223
|
+
controls,
|
|
2224
|
+
overridableProp.originPropFields ?? overridableProp,
|
|
2225
|
+
overridableProp.label
|
|
2226
|
+
);
|
|
2227
|
+
const propTypeSchema = (0, import_editor_editing_panel3.createTopLevelObjectType)({
|
|
2228
|
+
schema: { [overridableProp.overrideKey]: propType }
|
|
2229
|
+
});
|
|
2123
2230
|
const setValue = (newValue) => {
|
|
2124
|
-
if (!overridableProps) {
|
|
2125
|
-
setInstanceValue({
|
|
2126
|
-
...instanceValue,
|
|
2127
|
-
overrides: void 0
|
|
2128
|
-
});
|
|
2129
|
-
return;
|
|
2130
|
-
}
|
|
2131
2231
|
let newPropValue = getTempNewValueForDynamicProp(
|
|
2132
2232
|
propType,
|
|
2133
2233
|
propValue,
|
|
@@ -2163,16 +2263,6 @@ function OverrideControl({ overridableProp }) {
|
|
|
2163
2263
|
updateOverridableProp(wrappingComponentId, overridableValue, originPropFields);
|
|
2164
2264
|
}
|
|
2165
2265
|
};
|
|
2166
|
-
const { control, controlProps, layout } = getControlParams(
|
|
2167
|
-
controls,
|
|
2168
|
-
overridableProp?.originPropFields ?? overridableProp,
|
|
2169
|
-
overridableProp.label
|
|
2170
|
-
);
|
|
2171
|
-
const propTypeSchema = (0, import_editor_editing_panel.createTopLevelObjectType)({
|
|
2172
|
-
schema: {
|
|
2173
|
-
[overridableProp.overrideKey]: propType
|
|
2174
|
-
}
|
|
2175
|
-
});
|
|
2176
2266
|
return /* @__PURE__ */ React19.createElement(
|
|
2177
2267
|
OverridablePropProvider,
|
|
2178
2268
|
{
|
|
@@ -2180,40 +2270,38 @@ function OverrideControl({ overridableProp }) {
|
|
|
2180
2270
|
componentInstanceElement
|
|
2181
2271
|
},
|
|
2182
2272
|
/* @__PURE__ */ React19.createElement(
|
|
2183
|
-
|
|
2273
|
+
import_editor_editing_panel3.ElementProvider,
|
|
2184
2274
|
{
|
|
2185
|
-
element: { id: elementId, type },
|
|
2275
|
+
element: { id: elementId, type: elementType.key },
|
|
2186
2276
|
elementType,
|
|
2187
2277
|
settings: resolvedElementSettings
|
|
2188
2278
|
},
|
|
2189
|
-
/* @__PURE__ */ React19.createElement(
|
|
2279
|
+
/* @__PURE__ */ React19.createElement(
|
|
2190
2280
|
import_editor_controls2.PropProvider,
|
|
2191
2281
|
{
|
|
2192
2282
|
propType: propTypeSchema,
|
|
2193
2283
|
value,
|
|
2194
2284
|
setValue,
|
|
2195
2285
|
placeholder,
|
|
2196
|
-
isDisabled
|
|
2197
|
-
return false;
|
|
2198
|
-
}
|
|
2286
|
+
isDisabled
|
|
2199
2287
|
},
|
|
2200
|
-
/* @__PURE__ */ React19.createElement(import_editor_controls2.PropKeyProvider, { bind: overridableProp.overrideKey }, /* @__PURE__ */ React19.createElement(import_editor_controls2.ControlReplacementsProvider, { replacements: controlReplacements }, /* @__PURE__ */ React19.createElement(import_ui12.Box, { mb: 1.5 }, /* @__PURE__ */ React19.createElement(
|
|
2201
|
-
)
|
|
2288
|
+
/* @__PURE__ */ React19.createElement(import_editor_controls2.PropKeyProvider, { bind: overridableProp.overrideKey }, /* @__PURE__ */ React19.createElement(import_editor_controls2.ControlReplacementsProvider, { replacements: controlReplacements }, /* @__PURE__ */ React19.createElement(import_ui12.Box, { mb: 1.5 }, /* @__PURE__ */ React19.createElement(import_editor_editing_panel3.ControlTypeContainer, { layout }, layout !== "custom" && /* @__PURE__ */ React19.createElement(ControlLabel, null, overridableProp.label), /* @__PURE__ */ React19.createElement(OriginalControl, { control, controlProps })))))
|
|
2289
|
+
)
|
|
2202
2290
|
)
|
|
2203
2291
|
);
|
|
2204
2292
|
}
|
|
2205
|
-
function resolveValueAndPlaceholder(matchingOverride,
|
|
2206
|
-
const
|
|
2207
|
-
const placeholderSettings = unwrapOverridableSettings(settingsWithInnerOverrides);
|
|
2293
|
+
function resolveValueAndPlaceholder(matchingOverride, overrideValue, resolvedOriginValues, propKey) {
|
|
2294
|
+
const placeholderSettings = unwrapOverridableSettings(resolvedOriginValues);
|
|
2208
2295
|
const inheritedValue = placeholderSettings[propKey] ?? null;
|
|
2209
|
-
const isInheritedDynamic = (0,
|
|
2210
|
-
const
|
|
2296
|
+
const isInheritedDynamic = (0, import_editor_editing_panel3.isDynamicPropValue)(inheritedValue);
|
|
2297
|
+
const shouldUseInheritedAsValue = isInheritedDynamic && !matchingOverride;
|
|
2298
|
+
const propValue = shouldUseInheritedAsValue ? inheritedValue : overrideValue;
|
|
2211
2299
|
const placeholderValue = matchingOverride || isInheritedDynamic ? null : inheritedValue;
|
|
2212
2300
|
return { propValue, placeholderValue };
|
|
2213
2301
|
}
|
|
2214
2302
|
function getTempNewValueForDynamicProp(propType, propValue, newPropValue) {
|
|
2215
2303
|
const isRemovingOverride = newPropValue === null;
|
|
2216
|
-
if (isRemovingOverride && (0,
|
|
2304
|
+
if (isRemovingOverride && (0, import_editor_editing_panel3.isDynamicPropValue)(propValue)) {
|
|
2217
2305
|
return propType.default ?? null;
|
|
2218
2306
|
}
|
|
2219
2307
|
return newPropValue;
|
|
@@ -2266,15 +2354,15 @@ function getControlParams(controls, originPropFields, label) {
|
|
|
2266
2354
|
}
|
|
2267
2355
|
function OriginalControl({ control, controlProps }) {
|
|
2268
2356
|
const { value } = control;
|
|
2269
|
-
return /* @__PURE__ */ React19.createElement(
|
|
2357
|
+
return /* @__PURE__ */ React19.createElement(import_editor_editing_panel3.BaseControl, { type: value.type, props: controlProps });
|
|
2270
2358
|
}
|
|
2271
2359
|
function getControlLayout(control) {
|
|
2272
|
-
return control.value.meta?.layout ||
|
|
2360
|
+
return control.value.meta?.layout || import_editor_editing_panel3.controlsRegistry.getLayout(control.value.type);
|
|
2273
2361
|
}
|
|
2274
2362
|
function populateChildControlProps(props) {
|
|
2275
2363
|
if (props.childControlType) {
|
|
2276
|
-
const childComponent =
|
|
2277
|
-
const childPropType =
|
|
2364
|
+
const childComponent = import_editor_editing_panel3.controlsRegistry.get(props.childControlType);
|
|
2365
|
+
const childPropType = import_editor_editing_panel3.controlsRegistry.getPropTypeUtil(props.childControlType);
|
|
2278
2366
|
props = {
|
|
2279
2367
|
...props,
|
|
2280
2368
|
childControlConfig: {
|
|
@@ -2290,35 +2378,14 @@ function isValidOverride(overridableProps, override) {
|
|
|
2290
2378
|
const overridableKey = componentOverridablePropTypeUtil.isValid(override) ? override.value.origin_value?.value.override_key : override.value.override_key;
|
|
2291
2379
|
return !!overridableProps.props[overridableKey];
|
|
2292
2380
|
}
|
|
2293
|
-
function formatOverridesToApply(overrides) {
|
|
2294
|
-
if (!overrides) {
|
|
2295
|
-
return {};
|
|
2296
|
-
}
|
|
2297
|
-
const result = {};
|
|
2298
|
-
for (const item of overrides) {
|
|
2299
|
-
const overridable = componentOverridablePropTypeUtil.extract(item);
|
|
2300
|
-
let override = item;
|
|
2301
|
-
if (overridable) {
|
|
2302
|
-
override = overridable.origin_value;
|
|
2303
|
-
}
|
|
2304
|
-
const extractedOverride = componentInstanceOverridePropTypeUtil.extract(override);
|
|
2305
|
-
if (!extractedOverride) {
|
|
2306
|
-
continue;
|
|
2307
|
-
}
|
|
2308
|
-
result[extractedOverride.override_key] = {
|
|
2309
|
-
value: extractedOverride.override_value
|
|
2310
|
-
};
|
|
2311
|
-
}
|
|
2312
|
-
return result;
|
|
2313
|
-
}
|
|
2314
2381
|
|
|
2315
2382
|
// src/components/instance-editing-panel/override-props-group.tsx
|
|
2316
2383
|
function OverridePropsGroup({ group }) {
|
|
2317
|
-
const [isOpen, setIsOpen] = (0,
|
|
2384
|
+
const [isOpen, setIsOpen] = (0, import_editor_editing_panel4.useStateByElement)(group.id, true);
|
|
2318
2385
|
const handleClick = () => {
|
|
2319
2386
|
setIsOpen(!isOpen);
|
|
2320
2387
|
};
|
|
2321
|
-
const id = (0,
|
|
2388
|
+
const id = (0, import_react9.useId)();
|
|
2322
2389
|
const labelId = `label-${id}`;
|
|
2323
2390
|
const contentId = `content-${id}`;
|
|
2324
2391
|
const title = group.label;
|
|
@@ -2346,11 +2413,11 @@ function OverridePropsGroup({ group }) {
|
|
|
2346
2413
|
|
|
2347
2414
|
// src/components/instance-editing-panel/instance-panel-body.tsx
|
|
2348
2415
|
function InstancePanelBody({ groups, isEmpty, emptyState, componentInstanceId }) {
|
|
2349
|
-
return /* @__PURE__ */ React21.createElement(import_editor_panels2.PanelBody, null, /* @__PURE__ */ React21.createElement(import_editor_controls3.ControlAdornmentsProvider, { items: (0,
|
|
2416
|
+
return /* @__PURE__ */ React21.createElement(import_editor_panels2.PanelBody, null, /* @__PURE__ */ React21.createElement(import_editor_controls3.ControlAdornmentsProvider, { items: (0, import_editor_editing_panel5.getFieldIndicators)("settings") }, isEmpty ? emptyState : /* @__PURE__ */ React21.createElement(import_ui14.Stack, { direction: "column", alignItems: "stretch" }, groups.map((group) => /* @__PURE__ */ React21.createElement(React21.Fragment, { key: group.id + componentInstanceId }, /* @__PURE__ */ React21.createElement(OverridePropsGroup, { group }), /* @__PURE__ */ React21.createElement(import_ui14.Divider, null))))));
|
|
2350
2417
|
}
|
|
2351
2418
|
|
|
2352
2419
|
// src/components/instance-editing-panel/use-instance-panel-data.ts
|
|
2353
|
-
var
|
|
2420
|
+
var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
|
|
2354
2421
|
|
|
2355
2422
|
// src/utils/filter-valid-overridable-props.ts
|
|
2356
2423
|
function filterValidOverridableProps(overridableProps, instanceElementId) {
|
|
@@ -2410,7 +2477,7 @@ function useInstancePanelData() {
|
|
|
2410
2477
|
return { componentId, component, overrides, overridableProps, groups, isEmpty, componentInstanceId };
|
|
2411
2478
|
}
|
|
2412
2479
|
function useComponentInstanceSettings() {
|
|
2413
|
-
const { element, settings } = (0,
|
|
2480
|
+
const { element, settings } = (0, import_editor_editing_panel6.useElement)();
|
|
2414
2481
|
return { element, settings: componentInstancePropTypeUtil.extract(settings.component_instance) };
|
|
2415
2482
|
}
|
|
2416
2483
|
|
|
@@ -2463,7 +2530,7 @@ function InstanceEditingPanel() {
|
|
|
2463
2530
|
|
|
2464
2531
|
// src/components/load-template-components.tsx
|
|
2465
2532
|
var React23 = __toESM(require("react"));
|
|
2466
|
-
var
|
|
2533
|
+
var import_react10 = require("react");
|
|
2467
2534
|
var import_editor_templates = require("@elementor/editor-templates");
|
|
2468
2535
|
|
|
2469
2536
|
// src/store/actions/load-components-assets.ts
|
|
@@ -2592,7 +2659,7 @@ var LoadTemplateComponents = () => {
|
|
|
2592
2659
|
};
|
|
2593
2660
|
function LoadTemplateComponentsInternal() {
|
|
2594
2661
|
const templates = (0, import_editor_templates.useLoadedTemplates)();
|
|
2595
|
-
(0,
|
|
2662
|
+
(0, import_react10.useEffect)(() => {
|
|
2596
2663
|
loadComponentsAssets(templates.flatMap((elements) => elements ?? []));
|
|
2597
2664
|
}, [templates]);
|
|
2598
2665
|
return null;
|
|
@@ -3006,10 +3073,10 @@ function createComponentModel() {
|
|
|
3006
3073
|
}
|
|
3007
3074
|
|
|
3008
3075
|
// src/populate-store.ts
|
|
3009
|
-
var
|
|
3076
|
+
var import_react11 = require("react");
|
|
3010
3077
|
var import_store27 = require("@elementor/store");
|
|
3011
3078
|
function PopulateStore() {
|
|
3012
|
-
(0,
|
|
3079
|
+
(0, import_react11.useEffect)(() => {
|
|
3013
3080
|
(0, import_store27.__dispatch)(loadComponents());
|
|
3014
3081
|
}, []);
|
|
3015
3082
|
return null;
|
|
@@ -3278,7 +3345,7 @@ function init() {
|
|
|
3278
3345
|
id: "templates",
|
|
3279
3346
|
component: LoadTemplateComponents
|
|
3280
3347
|
});
|
|
3281
|
-
(0,
|
|
3348
|
+
(0, import_editor_editing_panel7.registerEditingPanelReplacement)({
|
|
3282
3349
|
id: "component-instance-edit-panel",
|
|
3283
3350
|
condition: (_, elementType) => elementType.key === "e-component",
|
|
3284
3351
|
component: InstanceEditingPanel
|