@elementor/editor-components 3.35.0-432 → 3.35.0-434
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 +184 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +180 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/components/consts.ts +1 -0
- package/src/components/instance-editing-panel/instance-editing-panel.tsx +9 -7
- package/src/components/instance-editing-panel/override-prop-control.tsx +125 -51
- package/src/components/overridable-props/overridable-prop-control.tsx +16 -8
- package/src/components/overridable-props/overridable-prop-indicator.tsx +8 -4
- package/src/init.ts +2 -1
- package/src/prop-types/component-instance-overrides-prop-type.ts +2 -0
- package/src/prop-types/component-overridable-prop-type.ts +3 -1
- package/src/provider/overridable-prop-context.tsx +5 -1
- package/src/store/actions/update-overridable-prop.ts +5 -2
- package/src/types.ts +1 -1
- package/src/utils/get-prop-type-for-component-override.ts +2 -1
- package/src/utils/resolve-override-prop-value.ts +51 -0
package/dist/index.mjs
CHANGED
|
@@ -2762,6 +2762,7 @@ var Components = () => {
|
|
|
2762
2762
|
|
|
2763
2763
|
// src/components/consts.ts
|
|
2764
2764
|
var COMPONENT_DOCUMENT_TYPE = "elementor_component";
|
|
2765
|
+
var OVERRIDABLE_PROP_REPLACEMENT_ID = "overridable-prop";
|
|
2765
2766
|
|
|
2766
2767
|
// src/components/create-component-form/create-component-form.tsx
|
|
2767
2768
|
import * as React19 from "react";
|
|
@@ -3437,13 +3438,13 @@ var EditModeDialog = ({ lockedBy }) => {
|
|
|
3437
3438
|
};
|
|
3438
3439
|
|
|
3439
3440
|
// src/components/instance-editing-panel/instance-editing-panel.tsx
|
|
3440
|
-
import * as
|
|
3441
|
+
import * as React28 from "react";
|
|
3441
3442
|
import { ControlAdornmentsProvider } from "@elementor/editor-controls";
|
|
3442
3443
|
import { getFieldIndicators } from "@elementor/editor-editing-panel";
|
|
3443
3444
|
import { useSelectedElement as useSelectedElement2 } from "@elementor/editor-elements";
|
|
3444
3445
|
import { PanelBody as PanelBody2, PanelHeader as PanelHeader2, PanelHeaderTitle as PanelHeaderTitle2 } from "@elementor/editor-panels";
|
|
3445
3446
|
import { ComponentsIcon as ComponentsIcon4, PencilIcon as PencilIcon2 } from "@elementor/icons";
|
|
3446
|
-
import { IconButton as IconButton6, Stack as Stack17, Tooltip as Tooltip4 } from "@elementor/ui";
|
|
3447
|
+
import { Divider as Divider4, IconButton as IconButton6, Stack as Stack17, Tooltip as Tooltip4 } from "@elementor/ui";
|
|
3447
3448
|
import { __ as __26 } from "@wordpress/i18n";
|
|
3448
3449
|
|
|
3449
3450
|
// src/hooks/use-component-instance-settings.ts
|
|
@@ -3536,20 +3537,25 @@ var EmptyState2 = ({ onEditComponent }) => {
|
|
|
3536
3537
|
};
|
|
3537
3538
|
|
|
3538
3539
|
// src/components/instance-editing-panel/override-props-group.tsx
|
|
3539
|
-
import * as
|
|
3540
|
+
import * as React27 from "react";
|
|
3540
3541
|
import { useId } from "react";
|
|
3541
3542
|
import { useStateByElement } from "@elementor/editor-editing-panel";
|
|
3542
3543
|
import { CollapseIcon } from "@elementor/editor-ui";
|
|
3543
3544
|
import { Box as Box13, Collapse, ListItemButton as ListItemButton3, ListItemText, Stack as Stack16 } from "@elementor/ui";
|
|
3544
3545
|
|
|
3545
3546
|
// src/components/instance-editing-panel/override-prop-control.tsx
|
|
3546
|
-
import * as
|
|
3547
|
-
import { PropKeyProvider, PropProvider, useBoundProp } from "@elementor/editor-controls";
|
|
3547
|
+
import * as React26 from "react";
|
|
3548
|
+
import { ControlReplacementsProvider, PropKeyProvider, PropProvider, useBoundProp } from "@elementor/editor-controls";
|
|
3548
3549
|
import {
|
|
3550
|
+
BaseControl,
|
|
3549
3551
|
controlsRegistry,
|
|
3550
3552
|
createTopLevelObjectType,
|
|
3551
|
-
|
|
3553
|
+
ElementProvider as ElementProvider2,
|
|
3554
|
+
getControlReplacements,
|
|
3555
|
+
SettingsField,
|
|
3556
|
+
useElement as useElement2
|
|
3552
3557
|
} from "@elementor/editor-editing-panel";
|
|
3558
|
+
import { getElementType as getElementType3 } from "@elementor/editor-elements";
|
|
3553
3559
|
import { Stack as Stack15 } from "@elementor/ui";
|
|
3554
3560
|
|
|
3555
3561
|
// src/hooks/use-controls-by-widget-type.ts
|
|
@@ -3583,8 +3589,51 @@ function getControlsByBind(controls) {
|
|
|
3583
3589
|
);
|
|
3584
3590
|
}
|
|
3585
3591
|
|
|
3592
|
+
// src/provider/overridable-prop-context.tsx
|
|
3593
|
+
import * as React24 from "react";
|
|
3594
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
3595
|
+
var OverridablePropContext = createContext2(null);
|
|
3596
|
+
function OverridablePropProvider({ children, ...props }) {
|
|
3597
|
+
return /* @__PURE__ */ React24.createElement(OverridablePropContext.Provider, { value: props }, children);
|
|
3598
|
+
}
|
|
3599
|
+
var useOverridablePropValue = () => useContext2(OverridablePropContext)?.value;
|
|
3600
|
+
var useComponentInstanceElement = () => useContext2(OverridablePropContext)?.componentInstanceElement;
|
|
3601
|
+
|
|
3586
3602
|
// src/store/actions/update-overridable-prop.ts
|
|
3587
3603
|
import { __dispatch as dispatch13, __getState as getState16 } from "@elementor/store";
|
|
3604
|
+
|
|
3605
|
+
// src/utils/resolve-override-prop-value.ts
|
|
3606
|
+
var resolveOverridePropValue = (originalPropValue) => {
|
|
3607
|
+
const isOverridable = componentOverridablePropTypeUtil.isValid(originalPropValue);
|
|
3608
|
+
if (isOverridable) {
|
|
3609
|
+
return getOverridableValue(originalPropValue);
|
|
3610
|
+
}
|
|
3611
|
+
const isOverride = componentInstanceOverridePropTypeUtil.isValid(originalPropValue);
|
|
3612
|
+
if (isOverride) {
|
|
3613
|
+
return getOverrideValue(originalPropValue);
|
|
3614
|
+
}
|
|
3615
|
+
return originalPropValue;
|
|
3616
|
+
};
|
|
3617
|
+
function getOverridableValue(overridableProp) {
|
|
3618
|
+
const overridableValue = componentOverridablePropTypeUtil.extract(overridableProp);
|
|
3619
|
+
if (!overridableValue) {
|
|
3620
|
+
return null;
|
|
3621
|
+
}
|
|
3622
|
+
const isOverride = componentInstanceOverridePropTypeUtil.isValid(overridableValue.origin_value);
|
|
3623
|
+
if (isOverride) {
|
|
3624
|
+
return getOverrideValue(overridableValue.origin_value);
|
|
3625
|
+
}
|
|
3626
|
+
return overridableValue.origin_value;
|
|
3627
|
+
}
|
|
3628
|
+
function getOverrideValue(overrideProp) {
|
|
3629
|
+
const overrideValue = componentInstanceOverridePropTypeUtil.extract(overrideProp);
|
|
3630
|
+
if (!overrideValue) {
|
|
3631
|
+
return null;
|
|
3632
|
+
}
|
|
3633
|
+
return overrideValue.override_value;
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
// src/store/actions/update-overridable-prop.ts
|
|
3588
3637
|
function updateOverridableProp(componentId, propValue, originPropFields) {
|
|
3589
3638
|
const overridableProps = selectOverridableProps(getState16(), componentId);
|
|
3590
3639
|
if (!overridableProps) {
|
|
@@ -3594,11 +3643,12 @@ function updateOverridableProp(componentId, propValue, originPropFields) {
|
|
|
3594
3643
|
if (!existingOverridableProp) {
|
|
3595
3644
|
return;
|
|
3596
3645
|
}
|
|
3646
|
+
const originValue = resolveOverridePropValue(propValue.origin_value);
|
|
3597
3647
|
const newOverridableProp = originPropFields ? {
|
|
3598
|
-
originValue
|
|
3648
|
+
originValue,
|
|
3599
3649
|
originPropFields
|
|
3600
3650
|
} : {
|
|
3601
|
-
originValue
|
|
3651
|
+
originValue
|
|
3602
3652
|
};
|
|
3603
3653
|
const newOverridableProps = {
|
|
3604
3654
|
...overridableProps,
|
|
@@ -3624,11 +3674,12 @@ var getPropTypeForComponentOverride = (overridableProp) => {
|
|
|
3624
3674
|
if (overridableProp.originPropFields) {
|
|
3625
3675
|
return getPropType(overridableProp.originPropFields);
|
|
3626
3676
|
}
|
|
3627
|
-
const { elType, widgetType, propKey } = overridableProp;
|
|
3677
|
+
const { elType, widgetType, propKey, elementId } = overridableProp;
|
|
3628
3678
|
return getPropType({
|
|
3629
3679
|
elType,
|
|
3630
3680
|
widgetType,
|
|
3631
|
-
propKey
|
|
3681
|
+
propKey,
|
|
3682
|
+
elementId
|
|
3632
3683
|
});
|
|
3633
3684
|
};
|
|
3634
3685
|
function getPropType({ widgetType, propKey }) {
|
|
@@ -3637,23 +3688,25 @@ function getPropType({ widgetType, propKey }) {
|
|
|
3637
3688
|
}
|
|
3638
3689
|
|
|
3639
3690
|
// src/components/control-label.tsx
|
|
3640
|
-
import * as
|
|
3691
|
+
import * as React25 from "react";
|
|
3641
3692
|
import { ControlAdornments, ControlFormLabel } from "@elementor/editor-controls";
|
|
3642
3693
|
import { Stack as Stack14 } from "@elementor/ui";
|
|
3643
3694
|
var ControlLabel = ({ children, ...props }) => {
|
|
3644
|
-
return /* @__PURE__ */
|
|
3695
|
+
return /* @__PURE__ */ React25.createElement(Stack14, { direction: "row", alignItems: "center", justifyItems: "start", gap: 0.25 }, /* @__PURE__ */ React25.createElement(ControlFormLabel, { ...props }, children), /* @__PURE__ */ React25.createElement(ControlAdornments, null));
|
|
3645
3696
|
};
|
|
3646
3697
|
|
|
3647
3698
|
// src/components/instance-editing-panel/override-prop-control.tsx
|
|
3648
3699
|
function OverridePropControl({ overridableProp, overrides }) {
|
|
3649
|
-
return /* @__PURE__ */
|
|
3700
|
+
return /* @__PURE__ */ React26.createElement(SettingsField, { bind: "component_instance", propDisplayName: overridableProp.label }, /* @__PURE__ */ React26.createElement(OverrideControl, { overridableProp, overrides }));
|
|
3650
3701
|
}
|
|
3651
3702
|
function OverrideControl({ overridableProp, overrides }) {
|
|
3703
|
+
const componentInstanceElement = useElement2();
|
|
3652
3704
|
const componentId = useCurrentComponentId();
|
|
3653
3705
|
const { value: instanceValue, setValue: setInstanceValue } = useBoundProp(componentInstancePropTypeUtil);
|
|
3654
3706
|
const controls = useControlsByWidgetType(
|
|
3655
3707
|
overridableProp?.originPropFields?.widgetType ?? overridableProp.widgetType
|
|
3656
3708
|
);
|
|
3709
|
+
const controlReplacements = getControlReplacements();
|
|
3657
3710
|
const propType = getPropTypeForComponentOverride(overridableProp);
|
|
3658
3711
|
if (!propType) {
|
|
3659
3712
|
return null;
|
|
@@ -3668,13 +3721,18 @@ function OverrideControl({ overridableProp, overrides }) {
|
|
|
3668
3721
|
throw new Error("Component ID is required");
|
|
3669
3722
|
}
|
|
3670
3723
|
const matchingOverride = getMatchingOverride(overrides, overridableProp.overrideKey);
|
|
3671
|
-
const propValue = matchingOverride ?
|
|
3724
|
+
const propValue = matchingOverride ? resolveOverridePropValue(matchingOverride) : overridableProp.originValue;
|
|
3672
3725
|
const value = {
|
|
3673
3726
|
[overridableProp.overrideKey]: propValue
|
|
3674
3727
|
};
|
|
3675
3728
|
const setValue = (newValue) => {
|
|
3676
3729
|
const newPropValue = newValue[overridableProp.overrideKey];
|
|
3677
|
-
const newOverrideValue = createOverrideValue(
|
|
3730
|
+
const newOverrideValue = createOverrideValue({
|
|
3731
|
+
matchingOverride,
|
|
3732
|
+
overrideKey: overridableProp.overrideKey,
|
|
3733
|
+
overrideValue: newPropValue,
|
|
3734
|
+
componentId: componentInstanceId
|
|
3735
|
+
});
|
|
3678
3736
|
let newOverrides = overrides?.map((override) => override === matchingOverride ? newOverrideValue : override) ?? [];
|
|
3679
3737
|
if (!matchingOverride) {
|
|
3680
3738
|
newOverrides = [...newOverrides, newOverrideValue];
|
|
@@ -3689,33 +3747,41 @@ function OverrideControl({ overridableProp, overrides }) {
|
|
|
3689
3747
|
updateOverridableProp(componentId, overridableValue, overridableProp.originPropFields);
|
|
3690
3748
|
return;
|
|
3691
3749
|
}
|
|
3692
|
-
const { elType, widgetType, propKey } = overridableProp;
|
|
3693
|
-
updateOverridableProp(componentId, overridableValue, { elType, widgetType, propKey });
|
|
3750
|
+
const { elType: elType2, widgetType: widgetType2, propKey: propKey2, elementId: elementId2 } = overridableProp;
|
|
3751
|
+
updateOverridableProp(componentId, overridableValue, { elType: elType2, widgetType: widgetType2, propKey: propKey2, elementId: elementId2 });
|
|
3694
3752
|
}
|
|
3695
3753
|
};
|
|
3696
|
-
|
|
3697
|
-
|
|
3754
|
+
const { control, controlProps, layout } = getControlParams(
|
|
3755
|
+
controls,
|
|
3756
|
+
overridableProp?.originPropFields ?? overridableProp,
|
|
3757
|
+
overridableProp.label
|
|
3758
|
+
);
|
|
3759
|
+
const { elementId, widgetType, elType, propKey } = overridableProp.originPropFields ?? overridableProp;
|
|
3760
|
+
const type = elType === "widget" ? widgetType : elType;
|
|
3761
|
+
const elementType = getElementType3(type);
|
|
3762
|
+
if (!elementType) {
|
|
3763
|
+
return null;
|
|
3764
|
+
}
|
|
3765
|
+
return /* @__PURE__ */ React26.createElement(
|
|
3766
|
+
OverridablePropProvider,
|
|
3698
3767
|
{
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
setValue,
|
|
3702
|
-
isDisabled: () => {
|
|
3703
|
-
return false;
|
|
3704
|
-
}
|
|
3768
|
+
value: componentOverridablePropTypeUtil.extract(matchingOverride) ?? void 0,
|
|
3769
|
+
componentInstanceElement
|
|
3705
3770
|
},
|
|
3706
|
-
/* @__PURE__ */
|
|
3771
|
+
/* @__PURE__ */ React26.createElement(ElementProvider2, { element: { id: elementId, type }, elementType }, /* @__PURE__ */ React26.createElement(SettingsField, { bind: propKey, propDisplayName: overridableProp.label }, /* @__PURE__ */ React26.createElement(
|
|
3772
|
+
PropProvider,
|
|
3773
|
+
{
|
|
3774
|
+
propType: propTypeSchema,
|
|
3775
|
+
value,
|
|
3776
|
+
setValue,
|
|
3777
|
+
isDisabled: () => {
|
|
3778
|
+
return false;
|
|
3779
|
+
}
|
|
3780
|
+
},
|
|
3781
|
+
/* @__PURE__ */ React26.createElement(PropKeyProvider, { bind: overridableProp.overrideKey }, /* @__PURE__ */ React26.createElement(ControlReplacementsProvider, { replacements: controlReplacements }, /* @__PURE__ */ React26.createElement(Stack15, { direction: "column", gap: 1, mb: 1.5 }, layout !== "custom" && /* @__PURE__ */ React26.createElement(ControlLabel, null, overridableProp.label), /* @__PURE__ */ React26.createElement(OriginalControl, { control, controlProps }))))
|
|
3782
|
+
)))
|
|
3707
3783
|
);
|
|
3708
3784
|
}
|
|
3709
|
-
function getPropValue(value) {
|
|
3710
|
-
const overridableValue = componentOverridablePropTypeUtil.extract(value);
|
|
3711
|
-
if (overridableValue) {
|
|
3712
|
-
return value;
|
|
3713
|
-
}
|
|
3714
|
-
if (componentInstanceOverridePropTypeUtil.isValid(value)) {
|
|
3715
|
-
return value.value.override_value;
|
|
3716
|
-
}
|
|
3717
|
-
return null;
|
|
3718
|
-
}
|
|
3719
3785
|
function getMatchingOverride(overrides, overrideKey) {
|
|
3720
3786
|
return overrides?.find((override) => {
|
|
3721
3787
|
const overridableValue = componentOverridablePropTypeUtil.extract(override);
|
|
@@ -3728,19 +3794,26 @@ function getMatchingOverride(overrides, overrideKey) {
|
|
|
3728
3794
|
return comparedOverrideKey === overrideKey;
|
|
3729
3795
|
}) ?? null;
|
|
3730
3796
|
}
|
|
3731
|
-
function createOverrideValue(
|
|
3732
|
-
|
|
3733
|
-
|
|
3797
|
+
function createOverrideValue({
|
|
3798
|
+
matchingOverride,
|
|
3799
|
+
overrideKey,
|
|
3800
|
+
overrideValue,
|
|
3801
|
+
componentId
|
|
3802
|
+
}) {
|
|
3803
|
+
const overridableValue = componentOverridablePropTypeUtil.extract(matchingOverride);
|
|
3804
|
+
const newOverridableValue = componentOverridablePropTypeUtil.extract(overrideValue);
|
|
3805
|
+
const anyOverridable = newOverridableValue ?? overridableValue;
|
|
3806
|
+
if (anyOverridable) {
|
|
3734
3807
|
const innerOverride = componentInstanceOverridePropTypeUtil.create({
|
|
3735
3808
|
override_key: overrideKey,
|
|
3736
|
-
override_value:
|
|
3809
|
+
override_value: resolveOverridePropValue(overrideValue),
|
|
3737
3810
|
schema_source: {
|
|
3738
3811
|
type: "component",
|
|
3739
3812
|
id: componentId
|
|
3740
3813
|
}
|
|
3741
3814
|
});
|
|
3742
3815
|
return componentOverridablePropTypeUtil.create({
|
|
3743
|
-
override_key:
|
|
3816
|
+
override_key: anyOverridable.override_key,
|
|
3744
3817
|
origin_value: innerOverride
|
|
3745
3818
|
});
|
|
3746
3819
|
}
|
|
@@ -3753,10 +3826,41 @@ function createOverrideValue(overrideKey, overrideValue, componentId) {
|
|
|
3753
3826
|
}
|
|
3754
3827
|
});
|
|
3755
3828
|
}
|
|
3756
|
-
function
|
|
3757
|
-
const
|
|
3758
|
-
const
|
|
3759
|
-
|
|
3829
|
+
function getControlParams(controls, originPropFields, label) {
|
|
3830
|
+
const control = controls[originPropFields.propKey];
|
|
3831
|
+
const { value } = control;
|
|
3832
|
+
const layout = getControlLayout(control);
|
|
3833
|
+
const controlProps = populateChildControlProps(value.props);
|
|
3834
|
+
if (layout === "custom") {
|
|
3835
|
+
controlProps.label = label ?? value.label;
|
|
3836
|
+
}
|
|
3837
|
+
return {
|
|
3838
|
+
control,
|
|
3839
|
+
controlProps,
|
|
3840
|
+
layout
|
|
3841
|
+
};
|
|
3842
|
+
}
|
|
3843
|
+
function OriginalControl({ control, controlProps }) {
|
|
3844
|
+
const { value } = control;
|
|
3845
|
+
return /* @__PURE__ */ React26.createElement(BaseControl, { type: value.type, props: controlProps });
|
|
3846
|
+
}
|
|
3847
|
+
function getControlLayout(control) {
|
|
3848
|
+
return control.value.meta?.layout || controlsRegistry.getLayout(control.value.type);
|
|
3849
|
+
}
|
|
3850
|
+
function populateChildControlProps(props) {
|
|
3851
|
+
if (props.childControlType) {
|
|
3852
|
+
const childComponent = controlsRegistry.get(props.childControlType);
|
|
3853
|
+
const childPropType = controlsRegistry.getPropTypeUtil(props.childControlType);
|
|
3854
|
+
props = {
|
|
3855
|
+
...props,
|
|
3856
|
+
childControlConfig: {
|
|
3857
|
+
component: childComponent,
|
|
3858
|
+
props: props.childControlProps || {},
|
|
3859
|
+
propTypeUtil: childPropType
|
|
3860
|
+
}
|
|
3861
|
+
};
|
|
3862
|
+
}
|
|
3863
|
+
return props;
|
|
3760
3864
|
}
|
|
3761
3865
|
|
|
3762
3866
|
// src/components/instance-editing-panel/override-props-group.tsx
|
|
@@ -3769,7 +3873,7 @@ function OverridePropsGroup({ group, props, overrides }) {
|
|
|
3769
3873
|
const labelId = `label-${id2}`;
|
|
3770
3874
|
const contentId = `content-${id2}`;
|
|
3771
3875
|
const title = group.label;
|
|
3772
|
-
return /* @__PURE__ */
|
|
3876
|
+
return /* @__PURE__ */ React27.createElement(Box13, { "aria-label": `${title} section` }, /* @__PURE__ */ React27.createElement(
|
|
3773
3877
|
ListItemButton3,
|
|
3774
3878
|
{
|
|
3775
3879
|
id: labelId,
|
|
@@ -3779,7 +3883,7 @@ function OverridePropsGroup({ group, props, overrides }) {
|
|
|
3779
3883
|
p: 0,
|
|
3780
3884
|
sx: { "&:hover": { backgroundColor: "transparent" } }
|
|
3781
3885
|
},
|
|
3782
|
-
/* @__PURE__ */
|
|
3886
|
+
/* @__PURE__ */ React27.createElement(Stack16, { direction: "row", alignItems: "center", justifyItems: "start", flexGrow: 1, gap: 0.5 }, /* @__PURE__ */ React27.createElement(
|
|
3783
3887
|
ListItemText,
|
|
3784
3888
|
{
|
|
3785
3889
|
secondary: title,
|
|
@@ -3787,8 +3891,8 @@ function OverridePropsGroup({ group, props, overrides }) {
|
|
|
3787
3891
|
sx: { flexGrow: 0, flexShrink: 1, marginInlineEnd: 1 }
|
|
3788
3892
|
}
|
|
3789
3893
|
)),
|
|
3790
|
-
/* @__PURE__ */
|
|
3791
|
-
), /* @__PURE__ */
|
|
3894
|
+
/* @__PURE__ */ React27.createElement(CollapseIcon, { open: isOpen, color: "secondary", fontSize: "tiny" })
|
|
3895
|
+
), /* @__PURE__ */ React27.createElement(Collapse, { id: contentId, "aria-labelledby": labelId, in: isOpen, timeout: "auto" }, /* @__PURE__ */ React27.createElement(Stack16, { direction: "column", gap: 1, p: 2 }, group.props.map((overrideKey) => /* @__PURE__ */ React27.createElement(
|
|
3792
3896
|
OverridePropControl,
|
|
3793
3897
|
{
|
|
3794
3898
|
key: overrideKey,
|
|
@@ -3814,40 +3918,31 @@ function InstanceEditingPanel() {
|
|
|
3814
3918
|
const isNonEmptyGroup = (group) => group !== null && group.props.length > 0;
|
|
3815
3919
|
const groups = overridableProps.groups.order.map((groupId) => overridableProps.groups.items[groupId] ?? null).filter(isNonEmptyGroup);
|
|
3816
3920
|
const isEmpty = groups.length === 0 || Object.keys(overridableProps.props).length === 0;
|
|
3817
|
-
return /* @__PURE__ */
|
|
3921
|
+
return /* @__PURE__ */ React28.createElement(React28.Fragment, null, /* @__PURE__ */ React28.createElement(PanelHeader2, { sx: { justifyContent: "start", px: 2 } }, /* @__PURE__ */ React28.createElement(Stack17, { direction: "row", alignContent: "space-between", flexGrow: 1 }, /* @__PURE__ */ React28.createElement(Stack17, { direction: "row", alignItems: "center", justifyContent: "start", gap: 1, flexGrow: 1 }, /* @__PURE__ */ React28.createElement(ComponentsIcon4, { fontSize: "small", sx: { color: "text.tertiary" } }), /* @__PURE__ */ React28.createElement(PanelHeaderTitle2, null, component.name)), /* @__PURE__ */ React28.createElement(Tooltip4, { title: panelTitle }, /* @__PURE__ */ React28.createElement(IconButton6, { size: "tiny", onClick: handleEditComponent, "aria-label": panelTitle }, /* @__PURE__ */ React28.createElement(PencilIcon2, { fontSize: "tiny" }))))), /* @__PURE__ */ React28.createElement(PanelBody2, null, /* @__PURE__ */ React28.createElement(ControlAdornmentsProvider, { items: getFieldIndicators("settings") }, isEmpty ? /* @__PURE__ */ React28.createElement(EmptyState2, { onEditComponent: handleEditComponent }) : /* @__PURE__ */ React28.createElement(Stack17, { direction: "column", alignItems: "stretch" }, groups.map((group) => /* @__PURE__ */ React28.createElement(React28.Fragment, { key: group.id }, /* @__PURE__ */ React28.createElement(
|
|
3818
3922
|
OverridePropsGroup,
|
|
3819
3923
|
{
|
|
3820
|
-
key: group.id,
|
|
3821
3924
|
group,
|
|
3822
3925
|
props: overridableProps.props,
|
|
3823
3926
|
overrides
|
|
3824
3927
|
}
|
|
3825
|
-
))))));
|
|
3928
|
+
), /* @__PURE__ */ React28.createElement(Divider4, null)))))));
|
|
3826
3929
|
}
|
|
3827
3930
|
|
|
3828
3931
|
// src/components/overridable-props/overridable-prop-control.tsx
|
|
3829
3932
|
import * as React29 from "react";
|
|
3830
|
-
import { ControlReplacementsProvider, PropKeyProvider as PropKeyProvider2, PropProvider as PropProvider2, useBoundProp as useBoundProp2 } from "@elementor/editor-controls";
|
|
3831
|
-
import { createTopLevelObjectType as createTopLevelObjectType2, useElement as
|
|
3832
|
-
|
|
3833
|
-
// src/provider/overridable-prop-context.tsx
|
|
3834
|
-
import * as React28 from "react";
|
|
3835
|
-
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
3836
|
-
var OverridablePropContext = createContext2(null);
|
|
3837
|
-
function OverridablePropProvider({ children, ...props }) {
|
|
3838
|
-
return /* @__PURE__ */ React28.createElement(OverridablePropContext.Provider, { value: props }, children);
|
|
3839
|
-
}
|
|
3840
|
-
var useOverridablePropValue = () => useContext2(OverridablePropContext)?.value;
|
|
3841
|
-
|
|
3842
|
-
// src/components/overridable-props/overridable-prop-control.tsx
|
|
3933
|
+
import { ControlReplacementsProvider as ControlReplacementsProvider2, PropKeyProvider as PropKeyProvider2, PropProvider as PropProvider2, useBoundProp as useBoundProp2 } from "@elementor/editor-controls";
|
|
3934
|
+
import { createTopLevelObjectType as createTopLevelObjectType2, getControlReplacements as getControlReplacements2, useElement as useElement3 } from "@elementor/editor-editing-panel";
|
|
3843
3935
|
function OverridablePropControl({
|
|
3844
|
-
OriginalControl,
|
|
3936
|
+
OriginalControl: OriginalControl2,
|
|
3845
3937
|
...props
|
|
3846
3938
|
}) {
|
|
3847
|
-
const { elementType } =
|
|
3939
|
+
const { elementType } = useElement3();
|
|
3848
3940
|
const { value, bind, setValue, placeholder, ...propContext } = useBoundProp2(componentOverridablePropTypeUtil);
|
|
3849
3941
|
const componentId = useCurrentComponentId();
|
|
3850
3942
|
const overridableProps = useOverridableProps(componentId);
|
|
3943
|
+
const filteredReplacements = getControlReplacements2().filter(
|
|
3944
|
+
(r) => !r.id || r.id !== OVERRIDABLE_PROP_REPLACEMENT_ID
|
|
3945
|
+
);
|
|
3851
3946
|
if (!componentId) {
|
|
3852
3947
|
return null;
|
|
3853
3948
|
}
|
|
@@ -3855,6 +3950,7 @@ function OverridablePropControl({
|
|
|
3855
3950
|
throw new Error("Override key is required");
|
|
3856
3951
|
}
|
|
3857
3952
|
const isComponentInstance2 = elementType.key === "e-component";
|
|
3953
|
+
const overridablePropData = overridableProps?.props?.[value.override_key];
|
|
3858
3954
|
const setOverridableValue = (newValue) => {
|
|
3859
3955
|
const propValue2 = {
|
|
3860
3956
|
...value,
|
|
@@ -3862,14 +3958,18 @@ function OverridablePropControl({
|
|
|
3862
3958
|
};
|
|
3863
3959
|
setValue(propValue2);
|
|
3864
3960
|
if (!isComponentInstance2) {
|
|
3865
|
-
|
|
3866
|
-
updateOverridableProp(componentId, propValue2, existingProp?.originPropFields);
|
|
3961
|
+
updateOverridableProp(componentId, propValue2, overridablePropData?.originPropFields);
|
|
3867
3962
|
}
|
|
3868
3963
|
};
|
|
3869
3964
|
const defaultPropType = elementType.propsSchema[bind];
|
|
3965
|
+
const overridePropType = overridablePropData ? getPropTypeForComponentOverride(overridablePropData) : void 0;
|
|
3966
|
+
const resolvedPropType = overridePropType ?? defaultPropType;
|
|
3967
|
+
if (!resolvedPropType) {
|
|
3968
|
+
return null;
|
|
3969
|
+
}
|
|
3870
3970
|
const propType = createTopLevelObjectType2({
|
|
3871
3971
|
schema: {
|
|
3872
|
-
[bind]:
|
|
3972
|
+
[bind]: resolvedPropType
|
|
3873
3973
|
}
|
|
3874
3974
|
});
|
|
3875
3975
|
const propValue = isComponentInstance2 ? (value.origin_value?.value).override_value : value.origin_value;
|
|
@@ -3885,14 +3985,14 @@ function OverridablePropControl({
|
|
|
3885
3985
|
},
|
|
3886
3986
|
placeholder: objectPlaceholder
|
|
3887
3987
|
},
|
|
3888
|
-
/* @__PURE__ */ React29.createElement(PropKeyProvider2, { bind }, /* @__PURE__ */ React29.createElement(
|
|
3988
|
+
/* @__PURE__ */ React29.createElement(PropKeyProvider2, { bind }, /* @__PURE__ */ React29.createElement(ControlReplacementsProvider2, { replacements: filteredReplacements }, /* @__PURE__ */ React29.createElement(OriginalControl2, { ...props })))
|
|
3889
3989
|
));
|
|
3890
3990
|
}
|
|
3891
3991
|
|
|
3892
3992
|
// src/components/overridable-props/overridable-prop-indicator.tsx
|
|
3893
3993
|
import * as React31 from "react";
|
|
3894
3994
|
import { useBoundProp as useBoundProp3 } from "@elementor/editor-controls";
|
|
3895
|
-
import { useElement as
|
|
3995
|
+
import { useElement as useElement4 } from "@elementor/editor-editing-panel";
|
|
3896
3996
|
import { getWidgetsCache as getWidgetsCache3 } from "@elementor/editor-elements";
|
|
3897
3997
|
import { bindPopover as bindPopover2, bindTrigger as bindTrigger4, Popover as Popover4, Tooltip as Tooltip5, usePopupState as usePopupState4 } from "@elementor/ui";
|
|
3898
3998
|
import { __ as __28 } from "@wordpress/i18n";
|
|
@@ -4059,9 +4159,10 @@ function Content2({ componentId, overridableProps }) {
|
|
|
4059
4159
|
const {
|
|
4060
4160
|
element: { id: elementId },
|
|
4061
4161
|
elementType
|
|
4062
|
-
} =
|
|
4162
|
+
} = useElement4();
|
|
4063
4163
|
const { value, bind, propType } = useBoundProp3();
|
|
4064
4164
|
const contextOverridableValue = useOverridablePropValue();
|
|
4165
|
+
const componentInstanceElement = useComponentInstanceElement();
|
|
4065
4166
|
const { value: boundPropOverridableValue, setValue: setOverridableValue } = useBoundProp3(
|
|
4066
4167
|
componentOverridablePropTypeUtil
|
|
4067
4168
|
);
|
|
@@ -4074,17 +4175,17 @@ function Content2({ componentId, overridableProps }) {
|
|
|
4074
4175
|
const { elType } = getWidgetsCache3()?.[elementType.key] ?? { elType: "widget" };
|
|
4075
4176
|
const handleSubmit = ({ label, group }) => {
|
|
4076
4177
|
const propTypeDefault = propType.default ?? {};
|
|
4077
|
-
const originValue = (
|
|
4178
|
+
const originValue = resolveOverridePropValue(overridableValue?.origin_value) ?? value ?? propTypeDefault;
|
|
4078
4179
|
const matchingOverridableProp = overridableValue ? overridableProps?.props?.[overridableValue.override_key] : void 0;
|
|
4079
4180
|
const overridablePropConfig = setOverridableProp({
|
|
4080
4181
|
componentId,
|
|
4081
4182
|
overrideKey: overridableValue?.override_key ?? null,
|
|
4082
|
-
elementId,
|
|
4183
|
+
elementId: componentInstanceElement?.element.id ?? elementId,
|
|
4083
4184
|
label,
|
|
4084
4185
|
groupId: group,
|
|
4085
4186
|
propKey: bind,
|
|
4086
4187
|
elType: elType ?? "widget",
|
|
4087
|
-
widgetType: elementType.key,
|
|
4188
|
+
widgetType: componentInstanceElement?.elementType.key ?? elementType.key,
|
|
4088
4189
|
originValue,
|
|
4089
4190
|
originPropFields: matchingOverridableProp?.originPropFields
|
|
4090
4191
|
});
|
|
@@ -4216,7 +4317,7 @@ import { getMCPByDomain as getMCPByDomain2 } from "@elementor/editor-mcp";
|
|
|
4216
4317
|
|
|
4217
4318
|
// src/mcp/save-as-component-tool.ts
|
|
4218
4319
|
import { DOCUMENT_STRUCTURE_URI, WIDGET_SCHEMA_URI } from "@elementor/editor-canvas";
|
|
4219
|
-
import { getContainer as getContainer4, getElementType as
|
|
4320
|
+
import { getContainer as getContainer4, getElementType as getElementType4, getWidgetsCache as getWidgetsCache4 } from "@elementor/editor-elements";
|
|
4220
4321
|
import { getMCPByDomain, toolPrompts } from "@elementor/editor-mcp";
|
|
4221
4322
|
import { AxiosError } from "@elementor/http-client";
|
|
4222
4323
|
import { z as z6 } from "@elementor/schema";
|
|
@@ -4301,7 +4402,7 @@ function enrichOverridableProps(input, rootElement) {
|
|
|
4301
4402
|
}
|
|
4302
4403
|
const elType = element.elType;
|
|
4303
4404
|
const widgetType = element.widgetType || element.elType;
|
|
4304
|
-
const elementType =
|
|
4405
|
+
const elementType = getElementType4(widgetType);
|
|
4305
4406
|
if (!elementType) {
|
|
4306
4407
|
throw new Error(
|
|
4307
4408
|
`Element type "${widgetType}" is not atomic or does not have a settings schema. Cannot expose property "${propKey}" for element "${elementId}".`
|
|
@@ -4931,6 +5032,7 @@ function init() {
|
|
|
4931
5032
|
indicator: OverridablePropIndicator
|
|
4932
5033
|
});
|
|
4933
5034
|
registerControlReplacement({
|
|
5035
|
+
id: OVERRIDABLE_PROP_REPLACEMENT_ID,
|
|
4934
5036
|
component: OverridablePropControl,
|
|
4935
5037
|
condition: ({ value }) => componentOverridablePropTypeUtil.isValid(value)
|
|
4936
5038
|
});
|