@elementor/editor-components 3.35.0-432 → 3.35.0-433
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 +183 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +178 -75
- 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/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.js
CHANGED
|
@@ -2740,6 +2740,7 @@ var Components = () => {
|
|
|
2740
2740
|
|
|
2741
2741
|
// src/components/consts.ts
|
|
2742
2742
|
var COMPONENT_DOCUMENT_TYPE = "elementor_component";
|
|
2743
|
+
var OVERRIDABLE_PROP_REPLACEMENT_ID = "overridable-prop";
|
|
2743
2744
|
|
|
2744
2745
|
// src/components/create-component-form/create-component-form.tsx
|
|
2745
2746
|
var React19 = __toESM(require("react"));
|
|
@@ -3415,10 +3416,10 @@ var EditModeDialog = ({ lockedBy }) => {
|
|
|
3415
3416
|
};
|
|
3416
3417
|
|
|
3417
3418
|
// src/components/instance-editing-panel/instance-editing-panel.tsx
|
|
3418
|
-
var
|
|
3419
|
+
var React28 = __toESM(require("react"));
|
|
3419
3420
|
var import_editor_controls4 = require("@elementor/editor-controls");
|
|
3420
3421
|
var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
|
|
3421
|
-
var
|
|
3422
|
+
var import_editor_elements15 = require("@elementor/editor-elements");
|
|
3422
3423
|
var import_editor_panels3 = require("@elementor/editor-panels");
|
|
3423
3424
|
var import_icons14 = require("@elementor/icons");
|
|
3424
3425
|
var import_ui22 = require("@elementor/ui");
|
|
@@ -3514,16 +3515,17 @@ var EmptyState2 = ({ onEditComponent }) => {
|
|
|
3514
3515
|
};
|
|
3515
3516
|
|
|
3516
3517
|
// src/components/instance-editing-panel/override-props-group.tsx
|
|
3517
|
-
var
|
|
3518
|
-
var
|
|
3518
|
+
var React27 = __toESM(require("react"));
|
|
3519
|
+
var import_react16 = require("react");
|
|
3519
3520
|
var import_editor_editing_panel4 = require("@elementor/editor-editing-panel");
|
|
3520
3521
|
var import_editor_ui11 = require("@elementor/editor-ui");
|
|
3521
3522
|
var import_ui21 = require("@elementor/ui");
|
|
3522
3523
|
|
|
3523
3524
|
// src/components/instance-editing-panel/override-prop-control.tsx
|
|
3524
|
-
var
|
|
3525
|
+
var React26 = __toESM(require("react"));
|
|
3525
3526
|
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
3526
3527
|
var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
|
|
3528
|
+
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
3527
3529
|
var import_ui20 = require("@elementor/ui");
|
|
3528
3530
|
|
|
3529
3531
|
// src/hooks/use-controls-by-widget-type.ts
|
|
@@ -3557,8 +3559,51 @@ function getControlsByBind(controls) {
|
|
|
3557
3559
|
);
|
|
3558
3560
|
}
|
|
3559
3561
|
|
|
3562
|
+
// src/provider/overridable-prop-context.tsx
|
|
3563
|
+
var React24 = __toESM(require("react"));
|
|
3564
|
+
var import_react15 = require("react");
|
|
3565
|
+
var OverridablePropContext = (0, import_react15.createContext)(null);
|
|
3566
|
+
function OverridablePropProvider({ children, ...props }) {
|
|
3567
|
+
return /* @__PURE__ */ React24.createElement(OverridablePropContext.Provider, { value: props }, children);
|
|
3568
|
+
}
|
|
3569
|
+
var useOverridablePropValue = () => (0, import_react15.useContext)(OverridablePropContext)?.value;
|
|
3570
|
+
var useComponentInstanceElement = () => (0, import_react15.useContext)(OverridablePropContext)?.componentInstanceElement;
|
|
3571
|
+
|
|
3560
3572
|
// src/store/actions/update-overridable-prop.ts
|
|
3561
3573
|
var import_store53 = require("@elementor/store");
|
|
3574
|
+
|
|
3575
|
+
// src/utils/resolve-override-prop-value.ts
|
|
3576
|
+
var resolveOverridePropValue = (originalPropValue) => {
|
|
3577
|
+
const isOverridable = componentOverridablePropTypeUtil.isValid(originalPropValue);
|
|
3578
|
+
if (isOverridable) {
|
|
3579
|
+
return getOverridableValue(originalPropValue);
|
|
3580
|
+
}
|
|
3581
|
+
const isOverride = componentInstanceOverridePropTypeUtil.isValid(originalPropValue);
|
|
3582
|
+
if (isOverride) {
|
|
3583
|
+
return getOverrideValue(originalPropValue);
|
|
3584
|
+
}
|
|
3585
|
+
return originalPropValue;
|
|
3586
|
+
};
|
|
3587
|
+
function getOverridableValue(overridableProp) {
|
|
3588
|
+
const overridableValue = componentOverridablePropTypeUtil.extract(overridableProp);
|
|
3589
|
+
if (!overridableValue) {
|
|
3590
|
+
return null;
|
|
3591
|
+
}
|
|
3592
|
+
const isOverride = componentInstanceOverridePropTypeUtil.isValid(overridableValue.origin_value);
|
|
3593
|
+
if (isOverride) {
|
|
3594
|
+
return getOverrideValue(overridableValue.origin_value);
|
|
3595
|
+
}
|
|
3596
|
+
return overridableValue.origin_value;
|
|
3597
|
+
}
|
|
3598
|
+
function getOverrideValue(overrideProp) {
|
|
3599
|
+
const overrideValue = componentInstanceOverridePropTypeUtil.extract(overrideProp);
|
|
3600
|
+
if (!overrideValue) {
|
|
3601
|
+
return null;
|
|
3602
|
+
}
|
|
3603
|
+
return overrideValue.override_value;
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
// src/store/actions/update-overridable-prop.ts
|
|
3562
3607
|
function updateOverridableProp(componentId, propValue, originPropFields) {
|
|
3563
3608
|
const overridableProps = selectOverridableProps((0, import_store53.__getState)(), componentId);
|
|
3564
3609
|
if (!overridableProps) {
|
|
@@ -3568,11 +3613,12 @@ function updateOverridableProp(componentId, propValue, originPropFields) {
|
|
|
3568
3613
|
if (!existingOverridableProp) {
|
|
3569
3614
|
return;
|
|
3570
3615
|
}
|
|
3616
|
+
const originValue = resolveOverridePropValue(propValue.origin_value);
|
|
3571
3617
|
const newOverridableProp = originPropFields ? {
|
|
3572
|
-
originValue
|
|
3618
|
+
originValue,
|
|
3573
3619
|
originPropFields
|
|
3574
3620
|
} : {
|
|
3575
|
-
originValue
|
|
3621
|
+
originValue
|
|
3576
3622
|
};
|
|
3577
3623
|
const newOverridableProps = {
|
|
3578
3624
|
...overridableProps,
|
|
@@ -3598,11 +3644,12 @@ var getPropTypeForComponentOverride = (overridableProp) => {
|
|
|
3598
3644
|
if (overridableProp.originPropFields) {
|
|
3599
3645
|
return getPropType(overridableProp.originPropFields);
|
|
3600
3646
|
}
|
|
3601
|
-
const { elType, widgetType, propKey } = overridableProp;
|
|
3647
|
+
const { elType, widgetType, propKey, elementId } = overridableProp;
|
|
3602
3648
|
return getPropType({
|
|
3603
3649
|
elType,
|
|
3604
3650
|
widgetType,
|
|
3605
|
-
propKey
|
|
3651
|
+
propKey,
|
|
3652
|
+
elementId
|
|
3606
3653
|
});
|
|
3607
3654
|
};
|
|
3608
3655
|
function getPropType({ widgetType, propKey }) {
|
|
@@ -3611,23 +3658,25 @@ function getPropType({ widgetType, propKey }) {
|
|
|
3611
3658
|
}
|
|
3612
3659
|
|
|
3613
3660
|
// src/components/control-label.tsx
|
|
3614
|
-
var
|
|
3661
|
+
var React25 = __toESM(require("react"));
|
|
3615
3662
|
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
3616
3663
|
var import_ui19 = require("@elementor/ui");
|
|
3617
3664
|
var ControlLabel = ({ children, ...props }) => {
|
|
3618
|
-
return /* @__PURE__ */
|
|
3665
|
+
return /* @__PURE__ */ React25.createElement(import_ui19.Stack, { direction: "row", alignItems: "center", justifyItems: "start", gap: 0.25 }, /* @__PURE__ */ React25.createElement(import_editor_controls2.ControlFormLabel, { ...props }, children), /* @__PURE__ */ React25.createElement(import_editor_controls2.ControlAdornments, null));
|
|
3619
3666
|
};
|
|
3620
3667
|
|
|
3621
3668
|
// src/components/instance-editing-panel/override-prop-control.tsx
|
|
3622
3669
|
function OverridePropControl({ overridableProp, overrides }) {
|
|
3623
|
-
return /* @__PURE__ */
|
|
3670
|
+
return /* @__PURE__ */ React26.createElement(import_editor_editing_panel3.SettingsField, { bind: "component_instance", propDisplayName: overridableProp.label }, /* @__PURE__ */ React26.createElement(OverrideControl, { overridableProp, overrides }));
|
|
3624
3671
|
}
|
|
3625
3672
|
function OverrideControl({ overridableProp, overrides }) {
|
|
3673
|
+
const componentInstanceElement = (0, import_editor_editing_panel3.useElement)();
|
|
3626
3674
|
const componentId = useCurrentComponentId();
|
|
3627
3675
|
const { value: instanceValue, setValue: setInstanceValue } = (0, import_editor_controls3.useBoundProp)(componentInstancePropTypeUtil);
|
|
3628
3676
|
const controls = useControlsByWidgetType(
|
|
3629
3677
|
overridableProp?.originPropFields?.widgetType ?? overridableProp.widgetType
|
|
3630
3678
|
);
|
|
3679
|
+
const controlReplacements = (0, import_editor_editing_panel3.getControlReplacements)();
|
|
3631
3680
|
const propType = getPropTypeForComponentOverride(overridableProp);
|
|
3632
3681
|
if (!propType) {
|
|
3633
3682
|
return null;
|
|
@@ -3642,13 +3691,18 @@ function OverrideControl({ overridableProp, overrides }) {
|
|
|
3642
3691
|
throw new Error("Component ID is required");
|
|
3643
3692
|
}
|
|
3644
3693
|
const matchingOverride = getMatchingOverride(overrides, overridableProp.overrideKey);
|
|
3645
|
-
const propValue = matchingOverride ?
|
|
3694
|
+
const propValue = matchingOverride ? resolveOverridePropValue(matchingOverride) : overridableProp.originValue;
|
|
3646
3695
|
const value = {
|
|
3647
3696
|
[overridableProp.overrideKey]: propValue
|
|
3648
3697
|
};
|
|
3649
3698
|
const setValue = (newValue) => {
|
|
3650
3699
|
const newPropValue = newValue[overridableProp.overrideKey];
|
|
3651
|
-
const newOverrideValue = createOverrideValue(
|
|
3700
|
+
const newOverrideValue = createOverrideValue({
|
|
3701
|
+
matchingOverride,
|
|
3702
|
+
overrideKey: overridableProp.overrideKey,
|
|
3703
|
+
overrideValue: newPropValue,
|
|
3704
|
+
componentId: componentInstanceId
|
|
3705
|
+
});
|
|
3652
3706
|
let newOverrides = overrides?.map((override) => override === matchingOverride ? newOverrideValue : override) ?? [];
|
|
3653
3707
|
if (!matchingOverride) {
|
|
3654
3708
|
newOverrides = [...newOverrides, newOverrideValue];
|
|
@@ -3663,33 +3717,41 @@ function OverrideControl({ overridableProp, overrides }) {
|
|
|
3663
3717
|
updateOverridableProp(componentId, overridableValue, overridableProp.originPropFields);
|
|
3664
3718
|
return;
|
|
3665
3719
|
}
|
|
3666
|
-
const { elType, widgetType, propKey } = overridableProp;
|
|
3667
|
-
updateOverridableProp(componentId, overridableValue, { elType, widgetType, propKey });
|
|
3720
|
+
const { elType: elType2, widgetType: widgetType2, propKey: propKey2, elementId: elementId2 } = overridableProp;
|
|
3721
|
+
updateOverridableProp(componentId, overridableValue, { elType: elType2, widgetType: widgetType2, propKey: propKey2, elementId: elementId2 });
|
|
3668
3722
|
}
|
|
3669
3723
|
};
|
|
3670
|
-
|
|
3671
|
-
|
|
3724
|
+
const { control, controlProps, layout } = getControlParams(
|
|
3725
|
+
controls,
|
|
3726
|
+
overridableProp?.originPropFields ?? overridableProp,
|
|
3727
|
+
overridableProp.label
|
|
3728
|
+
);
|
|
3729
|
+
const { elementId, widgetType, elType, propKey } = overridableProp.originPropFields ?? overridableProp;
|
|
3730
|
+
const type = elType === "widget" ? widgetType : elType;
|
|
3731
|
+
const elementType = (0, import_editor_elements14.getElementType)(type);
|
|
3732
|
+
if (!elementType) {
|
|
3733
|
+
return null;
|
|
3734
|
+
}
|
|
3735
|
+
return /* @__PURE__ */ React26.createElement(
|
|
3736
|
+
OverridablePropProvider,
|
|
3672
3737
|
{
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
setValue,
|
|
3676
|
-
isDisabled: () => {
|
|
3677
|
-
return false;
|
|
3678
|
-
}
|
|
3738
|
+
value: componentOverridablePropTypeUtil.extract(matchingOverride) ?? void 0,
|
|
3739
|
+
componentInstanceElement
|
|
3679
3740
|
},
|
|
3680
|
-
/* @__PURE__ */
|
|
3741
|
+
/* @__PURE__ */ React26.createElement(import_editor_editing_panel3.ElementProvider, { element: { id: elementId, type }, elementType }, /* @__PURE__ */ React26.createElement(import_editor_editing_panel3.SettingsField, { bind: propKey, propDisplayName: overridableProp.label }, /* @__PURE__ */ React26.createElement(
|
|
3742
|
+
import_editor_controls3.PropProvider,
|
|
3743
|
+
{
|
|
3744
|
+
propType: propTypeSchema,
|
|
3745
|
+
value,
|
|
3746
|
+
setValue,
|
|
3747
|
+
isDisabled: () => {
|
|
3748
|
+
return false;
|
|
3749
|
+
}
|
|
3750
|
+
},
|
|
3751
|
+
/* @__PURE__ */ React26.createElement(import_editor_controls3.PropKeyProvider, { bind: overridableProp.overrideKey }, /* @__PURE__ */ React26.createElement(import_editor_controls3.ControlReplacementsProvider, { replacements: controlReplacements }, /* @__PURE__ */ React26.createElement(import_ui20.Stack, { direction: "column", gap: 1, mb: 1.5 }, layout !== "custom" && /* @__PURE__ */ React26.createElement(ControlLabel, null, overridableProp.label), /* @__PURE__ */ React26.createElement(OriginalControl, { control, controlProps }))))
|
|
3752
|
+
)))
|
|
3681
3753
|
);
|
|
3682
3754
|
}
|
|
3683
|
-
function getPropValue(value) {
|
|
3684
|
-
const overridableValue = componentOverridablePropTypeUtil.extract(value);
|
|
3685
|
-
if (overridableValue) {
|
|
3686
|
-
return value;
|
|
3687
|
-
}
|
|
3688
|
-
if (componentInstanceOverridePropTypeUtil.isValid(value)) {
|
|
3689
|
-
return value.value.override_value;
|
|
3690
|
-
}
|
|
3691
|
-
return null;
|
|
3692
|
-
}
|
|
3693
3755
|
function getMatchingOverride(overrides, overrideKey) {
|
|
3694
3756
|
return overrides?.find((override) => {
|
|
3695
3757
|
const overridableValue = componentOverridablePropTypeUtil.extract(override);
|
|
@@ -3702,19 +3764,26 @@ function getMatchingOverride(overrides, overrideKey) {
|
|
|
3702
3764
|
return comparedOverrideKey === overrideKey;
|
|
3703
3765
|
}) ?? null;
|
|
3704
3766
|
}
|
|
3705
|
-
function createOverrideValue(
|
|
3706
|
-
|
|
3707
|
-
|
|
3767
|
+
function createOverrideValue({
|
|
3768
|
+
matchingOverride,
|
|
3769
|
+
overrideKey,
|
|
3770
|
+
overrideValue,
|
|
3771
|
+
componentId
|
|
3772
|
+
}) {
|
|
3773
|
+
const overridableValue = componentOverridablePropTypeUtil.extract(matchingOverride);
|
|
3774
|
+
const newOverridableValue = componentOverridablePropTypeUtil.extract(overrideValue);
|
|
3775
|
+
const anyOverridable = newOverridableValue ?? overridableValue;
|
|
3776
|
+
if (anyOverridable) {
|
|
3708
3777
|
const innerOverride = componentInstanceOverridePropTypeUtil.create({
|
|
3709
3778
|
override_key: overrideKey,
|
|
3710
|
-
override_value:
|
|
3779
|
+
override_value: resolveOverridePropValue(overrideValue),
|
|
3711
3780
|
schema_source: {
|
|
3712
3781
|
type: "component",
|
|
3713
3782
|
id: componentId
|
|
3714
3783
|
}
|
|
3715
3784
|
});
|
|
3716
3785
|
return componentOverridablePropTypeUtil.create({
|
|
3717
|
-
override_key:
|
|
3786
|
+
override_key: anyOverridable.override_key,
|
|
3718
3787
|
origin_value: innerOverride
|
|
3719
3788
|
});
|
|
3720
3789
|
}
|
|
@@ -3727,10 +3796,41 @@ function createOverrideValue(overrideKey, overrideValue, componentId) {
|
|
|
3727
3796
|
}
|
|
3728
3797
|
});
|
|
3729
3798
|
}
|
|
3730
|
-
function
|
|
3731
|
-
const
|
|
3732
|
-
const
|
|
3733
|
-
|
|
3799
|
+
function getControlParams(controls, originPropFields, label) {
|
|
3800
|
+
const control = controls[originPropFields.propKey];
|
|
3801
|
+
const { value } = control;
|
|
3802
|
+
const layout = getControlLayout(control);
|
|
3803
|
+
const controlProps = populateChildControlProps(value.props);
|
|
3804
|
+
if (layout === "custom") {
|
|
3805
|
+
controlProps.label = label ?? value.label;
|
|
3806
|
+
}
|
|
3807
|
+
return {
|
|
3808
|
+
control,
|
|
3809
|
+
controlProps,
|
|
3810
|
+
layout
|
|
3811
|
+
};
|
|
3812
|
+
}
|
|
3813
|
+
function OriginalControl({ control, controlProps }) {
|
|
3814
|
+
const { value } = control;
|
|
3815
|
+
return /* @__PURE__ */ React26.createElement(import_editor_editing_panel3.BaseControl, { type: value.type, props: controlProps });
|
|
3816
|
+
}
|
|
3817
|
+
function getControlLayout(control) {
|
|
3818
|
+
return control.value.meta?.layout || import_editor_editing_panel3.controlsRegistry.getLayout(control.value.type);
|
|
3819
|
+
}
|
|
3820
|
+
function populateChildControlProps(props) {
|
|
3821
|
+
if (props.childControlType) {
|
|
3822
|
+
const childComponent = import_editor_editing_panel3.controlsRegistry.get(props.childControlType);
|
|
3823
|
+
const childPropType = import_editor_editing_panel3.controlsRegistry.getPropTypeUtil(props.childControlType);
|
|
3824
|
+
props = {
|
|
3825
|
+
...props,
|
|
3826
|
+
childControlConfig: {
|
|
3827
|
+
component: childComponent,
|
|
3828
|
+
props: props.childControlProps || {},
|
|
3829
|
+
propTypeUtil: childPropType
|
|
3830
|
+
}
|
|
3831
|
+
};
|
|
3832
|
+
}
|
|
3833
|
+
return props;
|
|
3734
3834
|
}
|
|
3735
3835
|
|
|
3736
3836
|
// src/components/instance-editing-panel/override-props-group.tsx
|
|
@@ -3739,11 +3839,11 @@ function OverridePropsGroup({ group, props, overrides }) {
|
|
|
3739
3839
|
const handleClick = () => {
|
|
3740
3840
|
setIsOpen(!isOpen);
|
|
3741
3841
|
};
|
|
3742
|
-
const id2 = (0,
|
|
3842
|
+
const id2 = (0, import_react16.useId)();
|
|
3743
3843
|
const labelId = `label-${id2}`;
|
|
3744
3844
|
const contentId = `content-${id2}`;
|
|
3745
3845
|
const title = group.label;
|
|
3746
|
-
return /* @__PURE__ */
|
|
3846
|
+
return /* @__PURE__ */ React27.createElement(import_ui21.Box, { "aria-label": `${title} section` }, /* @__PURE__ */ React27.createElement(
|
|
3747
3847
|
import_ui21.ListItemButton,
|
|
3748
3848
|
{
|
|
3749
3849
|
id: labelId,
|
|
@@ -3753,7 +3853,7 @@ function OverridePropsGroup({ group, props, overrides }) {
|
|
|
3753
3853
|
p: 0,
|
|
3754
3854
|
sx: { "&:hover": { backgroundColor: "transparent" } }
|
|
3755
3855
|
},
|
|
3756
|
-
/* @__PURE__ */
|
|
3856
|
+
/* @__PURE__ */ React27.createElement(import_ui21.Stack, { direction: "row", alignItems: "center", justifyItems: "start", flexGrow: 1, gap: 0.5 }, /* @__PURE__ */ React27.createElement(
|
|
3757
3857
|
import_ui21.ListItemText,
|
|
3758
3858
|
{
|
|
3759
3859
|
secondary: title,
|
|
@@ -3761,8 +3861,8 @@ function OverridePropsGroup({ group, props, overrides }) {
|
|
|
3761
3861
|
sx: { flexGrow: 0, flexShrink: 1, marginInlineEnd: 1 }
|
|
3762
3862
|
}
|
|
3763
3863
|
)),
|
|
3764
|
-
/* @__PURE__ */
|
|
3765
|
-
), /* @__PURE__ */
|
|
3864
|
+
/* @__PURE__ */ React27.createElement(import_editor_ui11.CollapseIcon, { open: isOpen, color: "secondary", fontSize: "tiny" })
|
|
3865
|
+
), /* @__PURE__ */ React27.createElement(import_ui21.Collapse, { id: contentId, "aria-labelledby": labelId, in: isOpen, timeout: "auto" }, /* @__PURE__ */ React27.createElement(import_ui21.Stack, { direction: "column", gap: 1, p: 2 }, group.props.map((overrideKey) => /* @__PURE__ */ React27.createElement(
|
|
3766
3866
|
OverridePropControl,
|
|
3767
3867
|
{
|
|
3768
3868
|
key: overrideKey,
|
|
@@ -3779,7 +3879,7 @@ function InstanceEditingPanel() {
|
|
|
3779
3879
|
const overrides = settings?.overrides?.value;
|
|
3780
3880
|
const component = useComponent(componentId ?? null);
|
|
3781
3881
|
const overridableProps = useOverridableProps(componentId ?? null);
|
|
3782
|
-
const componentInstanceId = (0,
|
|
3882
|
+
const componentInstanceId = (0, import_editor_elements15.useSelectedElement)()?.element?.id ?? null;
|
|
3783
3883
|
if (!componentId || !overridableProps || !component) {
|
|
3784
3884
|
return null;
|
|
3785
3885
|
}
|
|
@@ -3788,7 +3888,7 @@ function InstanceEditingPanel() {
|
|
|
3788
3888
|
const isNonEmptyGroup = (group) => group !== null && group.props.length > 0;
|
|
3789
3889
|
const groups = overridableProps.groups.order.map((groupId) => overridableProps.groups.items[groupId] ?? null).filter(isNonEmptyGroup);
|
|
3790
3890
|
const isEmpty = groups.length === 0 || Object.keys(overridableProps.props).length === 0;
|
|
3791
|
-
return /* @__PURE__ */
|
|
3891
|
+
return /* @__PURE__ */ React28.createElement(React28.Fragment, null, /* @__PURE__ */ React28.createElement(import_editor_panels3.PanelHeader, { sx: { justifyContent: "start", px: 2 } }, /* @__PURE__ */ React28.createElement(import_ui22.Stack, { direction: "row", alignContent: "space-between", flexGrow: 1 }, /* @__PURE__ */ React28.createElement(import_ui22.Stack, { direction: "row", alignItems: "center", justifyContent: "start", gap: 1, flexGrow: 1 }, /* @__PURE__ */ React28.createElement(import_icons14.ComponentsIcon, { fontSize: "small", sx: { color: "text.tertiary" } }), /* @__PURE__ */ React28.createElement(import_editor_panels3.PanelHeaderTitle, null, component.name)), /* @__PURE__ */ React28.createElement(import_ui22.Tooltip, { title: panelTitle }, /* @__PURE__ */ React28.createElement(import_ui22.IconButton, { size: "tiny", onClick: handleEditComponent, "aria-label": panelTitle }, /* @__PURE__ */ React28.createElement(import_icons14.PencilIcon, { fontSize: "tiny" }))))), /* @__PURE__ */ React28.createElement(import_editor_panels3.PanelBody, null, /* @__PURE__ */ React28.createElement(import_editor_controls4.ControlAdornmentsProvider, { items: (0, import_editor_editing_panel5.getFieldIndicators)("settings") }, isEmpty ? /* @__PURE__ */ React28.createElement(EmptyState2, { onEditComponent: handleEditComponent }) : /* @__PURE__ */ React28.createElement(import_ui22.Stack, { direction: "column", alignItems: "stretch" }, groups.map((group) => /* @__PURE__ */ React28.createElement(
|
|
3792
3892
|
OverridePropsGroup,
|
|
3793
3893
|
{
|
|
3794
3894
|
key: group.id,
|
|
@@ -3803,25 +3903,17 @@ function InstanceEditingPanel() {
|
|
|
3803
3903
|
var React29 = __toESM(require("react"));
|
|
3804
3904
|
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
3805
3905
|
var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
|
|
3806
|
-
|
|
3807
|
-
// src/provider/overridable-prop-context.tsx
|
|
3808
|
-
var React28 = __toESM(require("react"));
|
|
3809
|
-
var import_react16 = require("react");
|
|
3810
|
-
var OverridablePropContext = (0, import_react16.createContext)(null);
|
|
3811
|
-
function OverridablePropProvider({ children, ...props }) {
|
|
3812
|
-
return /* @__PURE__ */ React28.createElement(OverridablePropContext.Provider, { value: props }, children);
|
|
3813
|
-
}
|
|
3814
|
-
var useOverridablePropValue = () => (0, import_react16.useContext)(OverridablePropContext)?.value;
|
|
3815
|
-
|
|
3816
|
-
// src/components/overridable-props/overridable-prop-control.tsx
|
|
3817
3906
|
function OverridablePropControl({
|
|
3818
|
-
OriginalControl,
|
|
3907
|
+
OriginalControl: OriginalControl2,
|
|
3819
3908
|
...props
|
|
3820
3909
|
}) {
|
|
3821
3910
|
const { elementType } = (0, import_editor_editing_panel6.useElement)();
|
|
3822
3911
|
const { value, bind, setValue, placeholder, ...propContext } = (0, import_editor_controls5.useBoundProp)(componentOverridablePropTypeUtil);
|
|
3823
3912
|
const componentId = useCurrentComponentId();
|
|
3824
3913
|
const overridableProps = useOverridableProps(componentId);
|
|
3914
|
+
const filteredReplacements = (0, import_editor_editing_panel6.getControlReplacements)().filter(
|
|
3915
|
+
(r) => !r.id || r.id !== OVERRIDABLE_PROP_REPLACEMENT_ID
|
|
3916
|
+
);
|
|
3825
3917
|
if (!componentId) {
|
|
3826
3918
|
return null;
|
|
3827
3919
|
}
|
|
@@ -3829,6 +3921,7 @@ function OverridablePropControl({
|
|
|
3829
3921
|
throw new Error("Override key is required");
|
|
3830
3922
|
}
|
|
3831
3923
|
const isComponentInstance2 = elementType.key === "e-component";
|
|
3924
|
+
const overridablePropData = overridableProps?.props?.[value.override_key];
|
|
3832
3925
|
const setOverridableValue = (newValue) => {
|
|
3833
3926
|
const propValue2 = {
|
|
3834
3927
|
...value,
|
|
@@ -3836,14 +3929,18 @@ function OverridablePropControl({
|
|
|
3836
3929
|
};
|
|
3837
3930
|
setValue(propValue2);
|
|
3838
3931
|
if (!isComponentInstance2) {
|
|
3839
|
-
|
|
3840
|
-
updateOverridableProp(componentId, propValue2, existingProp?.originPropFields);
|
|
3932
|
+
updateOverridableProp(componentId, propValue2, overridablePropData?.originPropFields);
|
|
3841
3933
|
}
|
|
3842
3934
|
};
|
|
3843
3935
|
const defaultPropType = elementType.propsSchema[bind];
|
|
3936
|
+
const overridePropType = overridablePropData ? getPropTypeForComponentOverride(overridablePropData) : void 0;
|
|
3937
|
+
const resolvedPropType = overridePropType ?? defaultPropType;
|
|
3938
|
+
if (!resolvedPropType) {
|
|
3939
|
+
return null;
|
|
3940
|
+
}
|
|
3844
3941
|
const propType = (0, import_editor_editing_panel6.createTopLevelObjectType)({
|
|
3845
3942
|
schema: {
|
|
3846
|
-
[bind]:
|
|
3943
|
+
[bind]: resolvedPropType
|
|
3847
3944
|
}
|
|
3848
3945
|
});
|
|
3849
3946
|
const propValue = isComponentInstance2 ? (value.origin_value?.value).override_value : value.origin_value;
|
|
@@ -3859,7 +3956,7 @@ function OverridablePropControl({
|
|
|
3859
3956
|
},
|
|
3860
3957
|
placeholder: objectPlaceholder
|
|
3861
3958
|
},
|
|
3862
|
-
/* @__PURE__ */ React29.createElement(import_editor_controls5.PropKeyProvider, { bind }, /* @__PURE__ */ React29.createElement(import_editor_controls5.ControlReplacementsProvider, { replacements:
|
|
3959
|
+
/* @__PURE__ */ React29.createElement(import_editor_controls5.PropKeyProvider, { bind }, /* @__PURE__ */ React29.createElement(import_editor_controls5.ControlReplacementsProvider, { replacements: filteredReplacements }, /* @__PURE__ */ React29.createElement(OriginalControl2, { ...props })))
|
|
3863
3960
|
));
|
|
3864
3961
|
}
|
|
3865
3962
|
|
|
@@ -3867,7 +3964,7 @@ function OverridablePropControl({
|
|
|
3867
3964
|
var React31 = __toESM(require("react"));
|
|
3868
3965
|
var import_editor_controls6 = require("@elementor/editor-controls");
|
|
3869
3966
|
var import_editor_editing_panel7 = require("@elementor/editor-editing-panel");
|
|
3870
|
-
var
|
|
3967
|
+
var import_editor_elements16 = require("@elementor/editor-elements");
|
|
3871
3968
|
var import_ui24 = require("@elementor/ui");
|
|
3872
3969
|
var import_i18n28 = require("@wordpress/i18n");
|
|
3873
3970
|
|
|
@@ -4036,6 +4133,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
4036
4133
|
} = (0, import_editor_editing_panel7.useElement)();
|
|
4037
4134
|
const { value, bind, propType } = (0, import_editor_controls6.useBoundProp)();
|
|
4038
4135
|
const contextOverridableValue = useOverridablePropValue();
|
|
4136
|
+
const componentInstanceElement = useComponentInstanceElement();
|
|
4039
4137
|
const { value: boundPropOverridableValue, setValue: setOverridableValue } = (0, import_editor_controls6.useBoundProp)(
|
|
4040
4138
|
componentOverridablePropTypeUtil
|
|
4041
4139
|
);
|
|
@@ -4045,20 +4143,20 @@ function Content2({ componentId, overridableProps }) {
|
|
|
4045
4143
|
});
|
|
4046
4144
|
const triggerProps = (0, import_ui24.bindTrigger)(popupState);
|
|
4047
4145
|
const popoverProps = (0, import_ui24.bindPopover)(popupState);
|
|
4048
|
-
const { elType } = (0,
|
|
4146
|
+
const { elType } = (0, import_editor_elements16.getWidgetsCache)()?.[elementType.key] ?? { elType: "widget" };
|
|
4049
4147
|
const handleSubmit = ({ label, group }) => {
|
|
4050
4148
|
const propTypeDefault = propType.default ?? {};
|
|
4051
|
-
const originValue = (
|
|
4149
|
+
const originValue = resolveOverridePropValue(overridableValue?.origin_value) ?? value ?? propTypeDefault;
|
|
4052
4150
|
const matchingOverridableProp = overridableValue ? overridableProps?.props?.[overridableValue.override_key] : void 0;
|
|
4053
4151
|
const overridablePropConfig = setOverridableProp({
|
|
4054
4152
|
componentId,
|
|
4055
4153
|
overrideKey: overridableValue?.override_key ?? null,
|
|
4056
|
-
elementId,
|
|
4154
|
+
elementId: componentInstanceElement?.element.id ?? elementId,
|
|
4057
4155
|
label,
|
|
4058
4156
|
groupId: group,
|
|
4059
4157
|
propKey: bind,
|
|
4060
4158
|
elType: elType ?? "widget",
|
|
4061
|
-
widgetType: elementType.key,
|
|
4159
|
+
widgetType: componentInstanceElement?.elementType.key ?? elementType.key,
|
|
4062
4160
|
originValue,
|
|
4063
4161
|
originPropFields: matchingOverridableProp?.originPropFields
|
|
4064
4162
|
});
|
|
@@ -4107,7 +4205,7 @@ function isPropAllowed(bind) {
|
|
|
4107
4205
|
}
|
|
4108
4206
|
|
|
4109
4207
|
// src/hooks/regenerate-override-keys.ts
|
|
4110
|
-
var
|
|
4208
|
+
var import_editor_elements17 = require("@elementor/editor-elements");
|
|
4111
4209
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
4112
4210
|
var import_utils8 = require("@elementor/utils");
|
|
4113
4211
|
function initRegenerateOverrideKeys() {
|
|
@@ -4128,11 +4226,11 @@ function regenerateOverrideKeysForContainers(result) {
|
|
|
4128
4226
|
});
|
|
4129
4227
|
}
|
|
4130
4228
|
function regenerateOverrideKeysRecursive(elementId) {
|
|
4131
|
-
const container = (0,
|
|
4229
|
+
const container = (0, import_editor_elements17.getContainer)(elementId);
|
|
4132
4230
|
if (!container) {
|
|
4133
4231
|
return;
|
|
4134
4232
|
}
|
|
4135
|
-
(0,
|
|
4233
|
+
(0, import_editor_elements17.getAllDescendants)(container).forEach(regenerateOverrideKeys);
|
|
4136
4234
|
}
|
|
4137
4235
|
function regenerateOverrideKeys(element) {
|
|
4138
4236
|
if (!isComponentInstance(element.model.toJSON())) {
|
|
@@ -4166,7 +4264,7 @@ function regenerateOverrideKeys(element) {
|
|
|
4166
4264
|
}
|
|
4167
4265
|
}
|
|
4168
4266
|
};
|
|
4169
|
-
(0,
|
|
4267
|
+
(0, import_editor_elements17.updateElementSettings)({
|
|
4170
4268
|
id: element.id,
|
|
4171
4269
|
props: { component_instance: newComponentInstance },
|
|
4172
4270
|
withHistory: false
|
|
@@ -4190,7 +4288,7 @@ var import_editor_mcp3 = require("@elementor/editor-mcp");
|
|
|
4190
4288
|
|
|
4191
4289
|
// src/mcp/save-as-component-tool.ts
|
|
4192
4290
|
var import_editor_canvas8 = require("@elementor/editor-canvas");
|
|
4193
|
-
var
|
|
4291
|
+
var import_editor_elements18 = require("@elementor/editor-elements");
|
|
4194
4292
|
var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
4195
4293
|
var import_http_client2 = require("@elementor/http-client");
|
|
4196
4294
|
var import_schema6 = require("@elementor/schema");
|
|
@@ -4228,7 +4326,7 @@ var ERROR_MESSAGES3 = {
|
|
|
4228
4326
|
var handleSaveAsComponent = async (params) => {
|
|
4229
4327
|
const { element_id: elementId, component_name: componentName, overridable_props: overridablePropsInput } = params;
|
|
4230
4328
|
const validElementTypes = getValidElementTypes();
|
|
4231
|
-
const container = (0,
|
|
4329
|
+
const container = (0, import_editor_elements18.getContainer)(elementId);
|
|
4232
4330
|
if (!container) {
|
|
4233
4331
|
throw new Error(ERROR_MESSAGES3.ELEMENT_NOT_FOUND);
|
|
4234
4332
|
}
|
|
@@ -4275,7 +4373,7 @@ function enrichOverridableProps(input, rootElement) {
|
|
|
4275
4373
|
}
|
|
4276
4374
|
const elType = element.elType;
|
|
4277
4375
|
const widgetType = element.widgetType || element.elType;
|
|
4278
|
-
const elementType = (0,
|
|
4376
|
+
const elementType = (0, import_editor_elements18.getElementType)(widgetType);
|
|
4279
4377
|
if (!elementType) {
|
|
4280
4378
|
throw new Error(
|
|
4281
4379
|
`Element type "${widgetType}" is not atomic or does not have a settings schema. Cannot expose property "${propKey}" for element "${elementId}".`
|
|
@@ -4344,7 +4442,7 @@ function findElementById(root, targetId) {
|
|
|
4344
4442
|
return null;
|
|
4345
4443
|
}
|
|
4346
4444
|
function getValidElementTypes() {
|
|
4347
|
-
const types = (0,
|
|
4445
|
+
const types = (0, import_editor_elements18.getWidgetsCache)();
|
|
4348
4446
|
if (!types) {
|
|
4349
4447
|
return [];
|
|
4350
4448
|
}
|
|
@@ -4531,7 +4629,7 @@ function PopulateStore() {
|
|
|
4531
4629
|
}
|
|
4532
4630
|
|
|
4533
4631
|
// src/prevent-circular-nesting.ts
|
|
4534
|
-
var
|
|
4632
|
+
var import_editor_elements19 = require("@elementor/editor-elements");
|
|
4535
4633
|
var import_editor_notifications4 = require("@elementor/editor-notifications");
|
|
4536
4634
|
var import_editor_v1_adapters9 = require("@elementor/editor-v1-adapters");
|
|
4537
4635
|
var import_store64 = require("@elementor/store");
|
|
@@ -4626,7 +4724,7 @@ function blockCircularMove(args) {
|
|
|
4626
4724
|
if (!container) {
|
|
4627
4725
|
return false;
|
|
4628
4726
|
}
|
|
4629
|
-
const allElements = (0,
|
|
4727
|
+
const allElements = (0, import_editor_elements19.getAllDescendants)(container);
|
|
4630
4728
|
return allElements.some((element) => {
|
|
4631
4729
|
const componentId = extractComponentIdFromContainer(element);
|
|
4632
4730
|
if (componentId === null) {
|
|
@@ -4687,7 +4785,7 @@ var componentsStylesProvider = (0, import_editor_styles_repository.createStylesP
|
|
|
4687
4785
|
});
|
|
4688
4786
|
|
|
4689
4787
|
// src/sync/create-components-before-save.ts
|
|
4690
|
-
var
|
|
4788
|
+
var import_editor_elements20 = require("@elementor/editor-elements");
|
|
4691
4789
|
var import_store70 = require("@elementor/store");
|
|
4692
4790
|
async function createComponentsBeforeSave({
|
|
4693
4791
|
elements,
|
|
@@ -4755,7 +4853,7 @@ function shouldUpdateElement(element, uidToComponentId) {
|
|
|
4755
4853
|
return { shouldUpdate: false, newComponentId: null };
|
|
4756
4854
|
}
|
|
4757
4855
|
function updateElementComponentId(elementId, componentId) {
|
|
4758
|
-
(0,
|
|
4856
|
+
(0, import_editor_elements20.updateElementSettings)({
|
|
4759
4857
|
id: elementId,
|
|
4760
4858
|
props: {
|
|
4761
4859
|
component_instance: {
|
|
@@ -4905,6 +5003,7 @@ function init() {
|
|
|
4905
5003
|
indicator: OverridablePropIndicator
|
|
4906
5004
|
});
|
|
4907
5005
|
(0, import_editor_editing_panel8.registerControlReplacement)({
|
|
5006
|
+
id: OVERRIDABLE_PROP_REPLACEMENT_ID,
|
|
4908
5007
|
component: OverridablePropControl,
|
|
4909
5008
|
condition: ({ value }) => componentOverridablePropTypeUtil.isValid(value)
|
|
4910
5009
|
});
|