@elementor/editor-components 3.35.0-389 → 3.35.0-390
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 +407 -173
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +381 -143
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/component-instance-transformer.ts +2 -2
- package/src/component-override-transformer.ts +2 -2
- package/src/components/component-properties-panel/component-properties-panel-content.tsx +4 -4
- package/src/components/control-label.tsx +15 -0
- package/src/components/instance-editing-panel/instance-editing-panel.tsx +27 -20
- package/src/components/instance-editing-panel/override-prop-control.tsx +207 -0
- package/src/components/instance-editing-panel/override-props-group.tsx +13 -7
- package/src/components/overridable-props/overridable-prop-control.tsx +23 -5
- package/src/components/overridable-props/overridable-prop-indicator.tsx +10 -6
- package/src/create-component-type.ts +4 -3
- package/src/hooks/regenerate-override-keys.ts +6 -4
- package/src/hooks/use-controls-by-widget-type.ts +40 -0
- package/src/prop-types/component-instance-override-prop-type.ts +0 -1
- package/src/prop-types/component-instance-overrides-prop-type.ts +5 -1
- package/src/prop-types/component-instance-prop-type.ts +2 -1
- package/src/store/actions/set-overridable-prop.ts +4 -1
- package/src/store/actions/update-overridable-prop-params.ts +58 -0
- package/src/store/actions/update-overridable-prop.ts +30 -38
- package/src/store/store.ts +8 -0
- package/src/sync/create-components-before-save.ts +9 -5
- package/src/types.ts +3 -20
- package/src/utils/get-component-ids.ts +11 -6
- package/src/utils/get-prop-type-for-component-override.ts +23 -0
- package/src/store/actions/update-overridable-prop-origin-value.ts +0 -37
package/dist/index.mjs
CHANGED
|
@@ -172,6 +172,9 @@ var getCreatedThisSession = (state) => state[SLICE_NAME].createdThisSession;
|
|
|
172
172
|
var getPath = (state) => state[SLICE_NAME].path;
|
|
173
173
|
var getCurrentComponentId = (state) => state[SLICE_NAME].currentComponentId;
|
|
174
174
|
var selectComponent = (state, componentId) => state[SLICE_NAME].data.find((component) => component.id === componentId);
|
|
175
|
+
var useComponent = (componentId) => {
|
|
176
|
+
return useSelector((state) => componentId ? selectComponent(state, componentId) : null);
|
|
177
|
+
};
|
|
175
178
|
var selectComponents = createSelector(
|
|
176
179
|
selectData,
|
|
177
180
|
selectUnpublishedData,
|
|
@@ -212,6 +215,11 @@ var selectOverridableProps = createSelector(
|
|
|
212
215
|
return component.overridableProps ?? DEFAULT_OVERRIDABLE_PROPS;
|
|
213
216
|
}
|
|
214
217
|
);
|
|
218
|
+
var useOverridableProps = (componentId) => {
|
|
219
|
+
return useSelector(
|
|
220
|
+
(state) => componentId ? selectOverridableProps(state, componentId) : null
|
|
221
|
+
);
|
|
222
|
+
};
|
|
215
223
|
var selectIsOverridablePropsLoaded = createSelector(
|
|
216
224
|
selectComponent,
|
|
217
225
|
(component) => {
|
|
@@ -669,11 +677,11 @@ function reorderOverridableGroups({ componentId, newOrder }) {
|
|
|
669
677
|
);
|
|
670
678
|
}
|
|
671
679
|
|
|
672
|
-
// src/store/actions/update-overridable-prop.ts
|
|
680
|
+
// src/store/actions/update-overridable-prop-params.ts
|
|
673
681
|
import { __dispatch as dispatch6, __getState as getState7 } from "@elementor/store";
|
|
674
|
-
function
|
|
682
|
+
function updateOverridablePropParams({
|
|
675
683
|
componentId,
|
|
676
|
-
|
|
684
|
+
overrideKey,
|
|
677
685
|
label,
|
|
678
686
|
groupId
|
|
679
687
|
}) {
|
|
@@ -681,7 +689,7 @@ function updateOverridableProp({
|
|
|
681
689
|
if (!overridableProps) {
|
|
682
690
|
return;
|
|
683
691
|
}
|
|
684
|
-
const prop = overridableProps.props[
|
|
692
|
+
const prop = overridableProps.props[overrideKey];
|
|
685
693
|
if (!prop) {
|
|
686
694
|
return;
|
|
687
695
|
}
|
|
@@ -692,7 +700,7 @@ function updateOverridableProp({
|
|
|
692
700
|
label,
|
|
693
701
|
groupId: newGroupId
|
|
694
702
|
};
|
|
695
|
-
const updatedGroups = movePropBetweenGroups(overridableProps.groups,
|
|
703
|
+
const updatedGroups = movePropBetweenGroups(overridableProps.groups, overrideKey, oldGroupId, newGroupId);
|
|
696
704
|
dispatch6(
|
|
697
705
|
slice.actions.setOverridableProps({
|
|
698
706
|
componentId,
|
|
@@ -700,7 +708,7 @@ function updateOverridableProp({
|
|
|
700
708
|
...overridableProps,
|
|
701
709
|
props: {
|
|
702
710
|
...overridableProps.props,
|
|
703
|
-
[
|
|
711
|
+
[overrideKey]: updatedProp
|
|
704
712
|
},
|
|
705
713
|
groups: updatedGroups
|
|
706
714
|
}
|
|
@@ -711,7 +719,7 @@ function updateOverridableProp({
|
|
|
711
719
|
|
|
712
720
|
// src/components/component-panel-header/use-overridable-props.ts
|
|
713
721
|
import { __useSelector as useSelector3 } from "@elementor/store";
|
|
714
|
-
function
|
|
722
|
+
function useOverridableProps2(componentId) {
|
|
715
723
|
return useSelector3((state) => {
|
|
716
724
|
if (!componentId) {
|
|
717
725
|
return void 0;
|
|
@@ -1246,7 +1254,7 @@ function validateGroupLabel(label, existingGroups) {
|
|
|
1246
1254
|
function useCurrentEditableItem() {
|
|
1247
1255
|
const [editingGroupId, setEditingGroupId] = useState3(null);
|
|
1248
1256
|
const currentComponentId = useCurrentComponentId();
|
|
1249
|
-
const overridableProps =
|
|
1257
|
+
const overridableProps = useOverridableProps2(currentComponentId);
|
|
1250
1258
|
const allGroupsRecord = overridableProps?.groups?.items ?? {};
|
|
1251
1259
|
const currentGroup = editingGroupId ? allGroupsRecord[editingGroupId] : null;
|
|
1252
1260
|
const validateLabel = (newLabel) => {
|
|
@@ -1309,7 +1317,7 @@ function generateUniqueLabel(groups) {
|
|
|
1309
1317
|
// src/components/component-properties-panel/component-properties-panel-content.tsx
|
|
1310
1318
|
function ComponentPropertiesPanelContent({ onClose }) {
|
|
1311
1319
|
const currentComponentId = useCurrentComponentId();
|
|
1312
|
-
const overridableProps =
|
|
1320
|
+
const overridableProps = useOverridableProps2(currentComponentId);
|
|
1313
1321
|
const [isAddingGroup, setIsAddingGroup] = useState4(false);
|
|
1314
1322
|
const introductionRef = useRef(null);
|
|
1315
1323
|
const groupLabelEditable = useCurrentEditableItem();
|
|
@@ -1352,10 +1360,10 @@ function ComponentPropertiesPanelContent({ onClose }) {
|
|
|
1352
1360
|
deleteOverridableProp({ componentId: currentComponentId, propKey });
|
|
1353
1361
|
setDocumentModifiedStatus2(true);
|
|
1354
1362
|
};
|
|
1355
|
-
const handlePropertyUpdate = (
|
|
1356
|
-
|
|
1363
|
+
const handlePropertyUpdate = (overrideKey, data) => {
|
|
1364
|
+
updateOverridablePropParams({
|
|
1357
1365
|
componentId: currentComponentId,
|
|
1358
|
-
|
|
1366
|
+
overrideKey,
|
|
1359
1367
|
label: data.label,
|
|
1360
1368
|
groupId: data.group
|
|
1361
1369
|
});
|
|
@@ -1493,7 +1501,7 @@ var slideUp = keyframes`
|
|
|
1493
1501
|
var MESSAGE_KEY = "components-properties-introduction";
|
|
1494
1502
|
var ComponentPanelHeader = () => {
|
|
1495
1503
|
const currentComponentId = useCurrentComponentId();
|
|
1496
|
-
const overridableProps =
|
|
1504
|
+
const overridableProps = useOverridableProps2(currentComponentId);
|
|
1497
1505
|
const onBack = useNavigateBack();
|
|
1498
1506
|
const componentName = getComponentName();
|
|
1499
1507
|
const [isMessageSuppressed, suppressMessage] = useSuppressedMessage(MESSAGE_KEY);
|
|
@@ -1844,6 +1852,9 @@ var getComponentIds = async (elements) => {
|
|
|
1844
1852
|
const isComponent = isComponentInstance({ widgetType, elType });
|
|
1845
1853
|
if (isComponent) {
|
|
1846
1854
|
const componentId = settings?.component_instance?.value?.component_id.value;
|
|
1855
|
+
if (!componentId) {
|
|
1856
|
+
return;
|
|
1857
|
+
}
|
|
1847
1858
|
const document = await getComponentDocumentData(componentId);
|
|
1848
1859
|
childElements = document?.elements;
|
|
1849
1860
|
if (Boolean(componentId)) {
|
|
@@ -1851,12 +1862,13 @@ var getComponentIds = async (elements) => {
|
|
|
1851
1862
|
}
|
|
1852
1863
|
}
|
|
1853
1864
|
if (!!childElements?.length) {
|
|
1854
|
-
|
|
1865
|
+
const newIds = await getComponentIds(childElements);
|
|
1866
|
+
ids.push(...Array.from(new Set(newIds)));
|
|
1855
1867
|
}
|
|
1856
1868
|
return ids;
|
|
1857
1869
|
});
|
|
1858
1870
|
const result = (await Promise.all(components)).flat();
|
|
1859
|
-
return Array.from(new Set(result));
|
|
1871
|
+
return Array.from(new Set(result)).filter((value) => value !== void 0);
|
|
1860
1872
|
};
|
|
1861
1873
|
|
|
1862
1874
|
// src/store/actions/load-components-overridable-props.ts
|
|
@@ -2817,22 +2829,26 @@ var EditModeDialog = ({ lockedBy }) => {
|
|
|
2817
2829
|
};
|
|
2818
2830
|
|
|
2819
2831
|
// src/components/instance-editing-panel/instance-editing-panel.tsx
|
|
2820
|
-
import * as
|
|
2821
|
-
import {
|
|
2822
|
-
import {
|
|
2832
|
+
import * as React25 from "react";
|
|
2833
|
+
import { ControlAdornmentsProvider } from "@elementor/editor-controls";
|
|
2834
|
+
import { getFieldIndicators } from "@elementor/editor-editing-panel";
|
|
2835
|
+
import { useSelectedElement as useSelectedElement2 } from "@elementor/editor-elements";
|
|
2823
2836
|
import { PanelBody as PanelBody2, PanelHeader as PanelHeader2, PanelHeaderTitle as PanelHeaderTitle2 } from "@elementor/editor-panels";
|
|
2824
2837
|
import { ComponentsIcon as ComponentsIcon3, PencilIcon as PencilIcon2 } from "@elementor/icons";
|
|
2825
|
-
import {
|
|
2826
|
-
import { IconButton as IconButton6, Stack as Stack15, Tooltip as Tooltip4 } from "@elementor/ui";
|
|
2838
|
+
import { IconButton as IconButton6, Stack as Stack17, Tooltip as Tooltip4 } from "@elementor/ui";
|
|
2827
2839
|
import { __ as __21 } from "@wordpress/i18n";
|
|
2828
2840
|
|
|
2841
|
+
// src/hooks/use-component-instance-settings.ts
|
|
2842
|
+
import { useElement } from "@elementor/editor-editing-panel";
|
|
2843
|
+
import { useElementSetting } from "@elementor/editor-elements";
|
|
2844
|
+
|
|
2829
2845
|
// src/prop-types/component-instance-prop-type.ts
|
|
2830
|
-
import { createPropUtils as
|
|
2831
|
-
import { z as
|
|
2846
|
+
import { createPropUtils as createPropUtils4, numberPropTypeUtil } from "@elementor/editor-props";
|
|
2847
|
+
import { z as z5 } from "@elementor/schema";
|
|
2832
2848
|
|
|
2833
2849
|
// src/prop-types/component-instance-overrides-prop-type.ts
|
|
2834
|
-
import { createPropUtils as
|
|
2835
|
-
import { z as
|
|
2850
|
+
import { createPropUtils as createPropUtils3 } from "@elementor/editor-props";
|
|
2851
|
+
import { z as z4 } from "@elementor/schema";
|
|
2836
2852
|
|
|
2837
2853
|
// src/prop-types/component-instance-override-prop-type.ts
|
|
2838
2854
|
import { createPropUtils } from "@elementor/editor-props";
|
|
@@ -2849,21 +2865,42 @@ var componentInstanceOverridePropTypeUtil = createPropUtils(
|
|
|
2849
2865
|
})
|
|
2850
2866
|
);
|
|
2851
2867
|
|
|
2868
|
+
// src/prop-types/component-overridable-prop-type.ts
|
|
2869
|
+
import { createPropUtils as createPropUtils2 } from "@elementor/editor-props";
|
|
2870
|
+
import { z as z3 } from "@elementor/schema";
|
|
2871
|
+
var componentOverridablePropTypeUtil = createPropUtils2(
|
|
2872
|
+
"overridable",
|
|
2873
|
+
z3.object({
|
|
2874
|
+
override_key: z3.string(),
|
|
2875
|
+
origin_value: z3.object({
|
|
2876
|
+
$$type: z3.string(),
|
|
2877
|
+
value: z3.unknown()
|
|
2878
|
+
}).nullable()
|
|
2879
|
+
})
|
|
2880
|
+
);
|
|
2881
|
+
|
|
2852
2882
|
// src/prop-types/component-instance-overrides-prop-type.ts
|
|
2853
|
-
var componentInstanceOverridesPropTypeUtil =
|
|
2883
|
+
var componentInstanceOverridesPropTypeUtil = createPropUtils3(
|
|
2854
2884
|
"overrides",
|
|
2855
|
-
|
|
2885
|
+
z4.array(z4.union([componentInstanceOverridePropTypeUtil.schema, componentOverridablePropTypeUtil.schema])).optional().default([])
|
|
2856
2886
|
);
|
|
2857
2887
|
|
|
2858
2888
|
// src/prop-types/component-instance-prop-type.ts
|
|
2859
|
-
var componentInstancePropTypeUtil =
|
|
2889
|
+
var componentInstancePropTypeUtil = createPropUtils4(
|
|
2860
2890
|
"component-instance",
|
|
2861
|
-
|
|
2891
|
+
z5.object({
|
|
2862
2892
|
component_id: numberPropTypeUtil.schema,
|
|
2863
|
-
overrides:
|
|
2893
|
+
overrides: z5.optional(componentInstanceOverridesPropTypeUtil.schema)
|
|
2864
2894
|
})
|
|
2865
2895
|
);
|
|
2866
2896
|
|
|
2897
|
+
// src/hooks/use-component-instance-settings.ts
|
|
2898
|
+
function useComponentInstanceSettings() {
|
|
2899
|
+
const { element } = useElement();
|
|
2900
|
+
const settings = useElementSetting(element.id, "component_instance");
|
|
2901
|
+
return componentInstancePropTypeUtil.extract(settings);
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2867
2904
|
// src/components/instance-editing-panel/empty-state.tsx
|
|
2868
2905
|
import * as React21 from "react";
|
|
2869
2906
|
import { ComponentPropListIcon as ComponentPropListIcon4, PencilIcon } from "@elementor/icons";
|
|
@@ -2891,12 +2928,231 @@ var EmptyState2 = ({ onEditComponent }) => {
|
|
|
2891
2928
|
};
|
|
2892
2929
|
|
|
2893
2930
|
// src/components/instance-editing-panel/override-props-group.tsx
|
|
2894
|
-
import * as
|
|
2931
|
+
import * as React24 from "react";
|
|
2895
2932
|
import { useId } from "react";
|
|
2896
2933
|
import { useStateByElement } from "@elementor/editor-editing-panel";
|
|
2897
2934
|
import { CollapseIcon } from "@elementor/editor-ui";
|
|
2898
|
-
import { Collapse, ListItemButton as ListItemButton3, ListItemText, Stack as
|
|
2899
|
-
|
|
2935
|
+
import { Box as Box13, Collapse, ListItemButton as ListItemButton3, ListItemText, Stack as Stack16 } from "@elementor/ui";
|
|
2936
|
+
|
|
2937
|
+
// src/components/instance-editing-panel/override-prop-control.tsx
|
|
2938
|
+
import * as React23 from "react";
|
|
2939
|
+
import { PropKeyProvider, PropProvider, useBoundProp } from "@elementor/editor-controls";
|
|
2940
|
+
import {
|
|
2941
|
+
controlsRegistry,
|
|
2942
|
+
createTopLevelObjectType,
|
|
2943
|
+
SettingsField
|
|
2944
|
+
} from "@elementor/editor-editing-panel";
|
|
2945
|
+
import { Stack as Stack15 } from "@elementor/ui";
|
|
2946
|
+
|
|
2947
|
+
// src/hooks/use-controls-by-widget-type.ts
|
|
2948
|
+
import { getElementType } from "@elementor/editor-elements";
|
|
2949
|
+
function useControlsByWidgetType(type) {
|
|
2950
|
+
const elementType = getElementType(type);
|
|
2951
|
+
if (!elementType) {
|
|
2952
|
+
return {};
|
|
2953
|
+
}
|
|
2954
|
+
const controls = iterateControls(elementType.controls);
|
|
2955
|
+
return getControlsByBind(controls);
|
|
2956
|
+
}
|
|
2957
|
+
function iterateControls(controls) {
|
|
2958
|
+
return controls.map((control) => {
|
|
2959
|
+
if (control.type === "control" && "bind" in control.value) {
|
|
2960
|
+
return control;
|
|
2961
|
+
}
|
|
2962
|
+
if (control.type === "section") {
|
|
2963
|
+
return iterateControls(control.value.items);
|
|
2964
|
+
}
|
|
2965
|
+
return null;
|
|
2966
|
+
}).filter(Boolean).flat();
|
|
2967
|
+
}
|
|
2968
|
+
function getControlsByBind(controls) {
|
|
2969
|
+
return controls.reduce(
|
|
2970
|
+
(controlsByBind, control) => ({
|
|
2971
|
+
...controlsByBind,
|
|
2972
|
+
[control.value.bind]: control
|
|
2973
|
+
}),
|
|
2974
|
+
{}
|
|
2975
|
+
);
|
|
2976
|
+
}
|
|
2977
|
+
|
|
2978
|
+
// src/store/actions/update-overridable-prop.ts
|
|
2979
|
+
import { __dispatch as dispatch11, __getState as getState12 } from "@elementor/store";
|
|
2980
|
+
function updateOverridableProp(componentId, propValue, originPropFields) {
|
|
2981
|
+
const overridableProps = selectOverridableProps(getState12(), componentId);
|
|
2982
|
+
if (!overridableProps) {
|
|
2983
|
+
return;
|
|
2984
|
+
}
|
|
2985
|
+
const existingOverridableProp = overridableProps.props[propValue.override_key];
|
|
2986
|
+
if (!existingOverridableProp) {
|
|
2987
|
+
return;
|
|
2988
|
+
}
|
|
2989
|
+
const newOverridableProp = originPropFields ? {
|
|
2990
|
+
originValue: propValue.origin_value,
|
|
2991
|
+
originPropFields
|
|
2992
|
+
} : {
|
|
2993
|
+
originValue: propValue.origin_value
|
|
2994
|
+
};
|
|
2995
|
+
const newOverridableProps = {
|
|
2996
|
+
...overridableProps,
|
|
2997
|
+
props: {
|
|
2998
|
+
...overridableProps.props,
|
|
2999
|
+
[existingOverridableProp.overrideKey]: {
|
|
3000
|
+
...existingOverridableProp,
|
|
3001
|
+
...newOverridableProp
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
};
|
|
3005
|
+
dispatch11(
|
|
3006
|
+
slice.actions.setOverridableProps({
|
|
3007
|
+
componentId,
|
|
3008
|
+
overridableProps: newOverridableProps
|
|
3009
|
+
})
|
|
3010
|
+
);
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
// src/utils/get-prop-type-for-component-override.ts
|
|
3014
|
+
import { getWidgetsCache as getWidgetsCache2 } from "@elementor/editor-elements";
|
|
3015
|
+
var getPropTypeForComponentOverride = (overridableProp) => {
|
|
3016
|
+
if (overridableProp.originPropFields) {
|
|
3017
|
+
return getPropType(overridableProp.originPropFields);
|
|
3018
|
+
}
|
|
3019
|
+
const { elType, widgetType, propKey } = overridableProp;
|
|
3020
|
+
return getPropType({
|
|
3021
|
+
elType,
|
|
3022
|
+
widgetType,
|
|
3023
|
+
propKey
|
|
3024
|
+
});
|
|
3025
|
+
};
|
|
3026
|
+
function getPropType({ widgetType, propKey }) {
|
|
3027
|
+
const widgetPropsSchema = getWidgetsCache2()?.[widgetType]?.atomic_props_schema;
|
|
3028
|
+
return widgetPropsSchema?.[propKey];
|
|
3029
|
+
}
|
|
3030
|
+
|
|
3031
|
+
// src/components/control-label.tsx
|
|
3032
|
+
import * as React22 from "react";
|
|
3033
|
+
import { ControlAdornments, ControlFormLabel } from "@elementor/editor-controls";
|
|
3034
|
+
import { Stack as Stack14 } from "@elementor/ui";
|
|
3035
|
+
var ControlLabel = ({ children, ...props }) => {
|
|
3036
|
+
return /* @__PURE__ */ React22.createElement(Stack14, { direction: "row", alignItems: "center", justifyItems: "start", gap: 0.25 }, /* @__PURE__ */ React22.createElement(ControlFormLabel, { ...props }, children), /* @__PURE__ */ React22.createElement(ControlAdornments, null));
|
|
3037
|
+
};
|
|
3038
|
+
|
|
3039
|
+
// src/components/instance-editing-panel/override-prop-control.tsx
|
|
3040
|
+
function OverridePropControl({ overridableProp, overrides }) {
|
|
3041
|
+
return /* @__PURE__ */ React23.createElement(SettingsField, { bind: "component_instance", propDisplayName: overridableProp.label }, /* @__PURE__ */ React23.createElement(OverrideControl, { overridableProp, overrides }));
|
|
3042
|
+
}
|
|
3043
|
+
function OverrideControl({ overridableProp, overrides }) {
|
|
3044
|
+
const componentId = useCurrentComponentId();
|
|
3045
|
+
const { value: instanceValue, setValue: setInstanceValue } = useBoundProp(componentInstancePropTypeUtil);
|
|
3046
|
+
const controls = useControlsByWidgetType(
|
|
3047
|
+
overridableProp?.originPropFields?.widgetType ?? overridableProp.widgetType
|
|
3048
|
+
);
|
|
3049
|
+
const propType = getPropTypeForComponentOverride(overridableProp);
|
|
3050
|
+
if (!propType) {
|
|
3051
|
+
return null;
|
|
3052
|
+
}
|
|
3053
|
+
const propTypeSchema = createTopLevelObjectType({
|
|
3054
|
+
schema: {
|
|
3055
|
+
[overridableProp.overrideKey]: propType
|
|
3056
|
+
}
|
|
3057
|
+
});
|
|
3058
|
+
const componentInstanceId = instanceValue.component_id?.value;
|
|
3059
|
+
if (!componentInstanceId) {
|
|
3060
|
+
throw new Error("Component ID is required");
|
|
3061
|
+
}
|
|
3062
|
+
const matchingOverride = getMatchingOverride(overrides, overridableProp.overrideKey);
|
|
3063
|
+
const propValue = matchingOverride ? getPropValue(matchingOverride) : overridableProp.originValue;
|
|
3064
|
+
const value = {
|
|
3065
|
+
[overridableProp.overrideKey]: propValue
|
|
3066
|
+
};
|
|
3067
|
+
const setValue = (newValue) => {
|
|
3068
|
+
const newPropValue = newValue[overridableProp.overrideKey];
|
|
3069
|
+
const newOverrideValue = createOverrideValue(overridableProp.overrideKey, newPropValue, componentInstanceId);
|
|
3070
|
+
let newOverrides = overrides?.map((override) => override === matchingOverride ? newOverrideValue : override) ?? [];
|
|
3071
|
+
if (!matchingOverride) {
|
|
3072
|
+
newOverrides = [...newOverrides, newOverrideValue];
|
|
3073
|
+
}
|
|
3074
|
+
setInstanceValue({
|
|
3075
|
+
...instanceValue,
|
|
3076
|
+
overrides: componentInstanceOverridesPropTypeUtil.create(newOverrides)
|
|
3077
|
+
});
|
|
3078
|
+
const overridableValue = componentOverridablePropTypeUtil.extract(newOverrideValue);
|
|
3079
|
+
if (overridableValue && componentId) {
|
|
3080
|
+
if (overridableProp.originPropFields) {
|
|
3081
|
+
updateOverridableProp(componentId, overridableValue, overridableProp.originPropFields);
|
|
3082
|
+
return;
|
|
3083
|
+
}
|
|
3084
|
+
const { elType, widgetType, propKey } = overridableProp;
|
|
3085
|
+
updateOverridableProp(componentId, overridableValue, { elType, widgetType, propKey });
|
|
3086
|
+
}
|
|
3087
|
+
};
|
|
3088
|
+
return /* @__PURE__ */ React23.createElement(
|
|
3089
|
+
PropProvider,
|
|
3090
|
+
{
|
|
3091
|
+
propType: propTypeSchema,
|
|
3092
|
+
value,
|
|
3093
|
+
setValue,
|
|
3094
|
+
isDisabled: () => {
|
|
3095
|
+
return false;
|
|
3096
|
+
}
|
|
3097
|
+
},
|
|
3098
|
+
/* @__PURE__ */ React23.createElement(PropKeyProvider, { bind: overridableProp.overrideKey }, /* @__PURE__ */ React23.createElement(Stack15, { direction: "column", gap: 1, mb: 1.5 }, /* @__PURE__ */ React23.createElement(ControlLabel, null, overridableProp.label), getControl(controls, overridableProp?.originPropFields ?? overridableProp)))
|
|
3099
|
+
);
|
|
3100
|
+
}
|
|
3101
|
+
function getPropValue(value) {
|
|
3102
|
+
const overridableValue = componentOverridablePropTypeUtil.extract(value);
|
|
3103
|
+
if (overridableValue) {
|
|
3104
|
+
return value;
|
|
3105
|
+
}
|
|
3106
|
+
if (componentInstanceOverridePropTypeUtil.isValid(value)) {
|
|
3107
|
+
return value.value.override_value;
|
|
3108
|
+
}
|
|
3109
|
+
return null;
|
|
3110
|
+
}
|
|
3111
|
+
function getMatchingOverride(overrides, overrideKey) {
|
|
3112
|
+
return overrides?.find((override) => {
|
|
3113
|
+
const overridableValue = componentOverridablePropTypeUtil.extract(override);
|
|
3114
|
+
let comparedOverrideKey = null;
|
|
3115
|
+
if (overridableValue) {
|
|
3116
|
+
comparedOverrideKey = overridableValue.origin_value?.value?.override_key;
|
|
3117
|
+
} else {
|
|
3118
|
+
comparedOverrideKey = override.value.override_key;
|
|
3119
|
+
}
|
|
3120
|
+
return comparedOverrideKey === overrideKey;
|
|
3121
|
+
}) ?? null;
|
|
3122
|
+
}
|
|
3123
|
+
function createOverrideValue(overrideKey, overrideValue, componentId) {
|
|
3124
|
+
const overridableValue = componentOverridablePropTypeUtil.extract(overrideValue);
|
|
3125
|
+
if (overridableValue) {
|
|
3126
|
+
const innerOverride = componentInstanceOverridePropTypeUtil.create({
|
|
3127
|
+
override_key: overrideKey,
|
|
3128
|
+
override_value: overridableValue.origin_value,
|
|
3129
|
+
schema_source: {
|
|
3130
|
+
type: "component",
|
|
3131
|
+
id: componentId
|
|
3132
|
+
}
|
|
3133
|
+
});
|
|
3134
|
+
return componentOverridablePropTypeUtil.create({
|
|
3135
|
+
override_key: overridableValue.override_key,
|
|
3136
|
+
origin_value: innerOverride
|
|
3137
|
+
});
|
|
3138
|
+
}
|
|
3139
|
+
return componentInstanceOverridePropTypeUtil.create({
|
|
3140
|
+
override_key: overrideKey,
|
|
3141
|
+
override_value: overrideValue,
|
|
3142
|
+
schema_source: {
|
|
3143
|
+
type: "component",
|
|
3144
|
+
id: componentId
|
|
3145
|
+
}
|
|
3146
|
+
});
|
|
3147
|
+
}
|
|
3148
|
+
function getControl(controls, originPropFields) {
|
|
3149
|
+
const ControlComponent = controlsRegistry.get(controls[originPropFields.propKey].value.type);
|
|
3150
|
+
const controlProps = controls[originPropFields.propKey].value.props;
|
|
3151
|
+
return /* @__PURE__ */ React23.createElement(ControlComponent, { ...controlProps });
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
// src/components/instance-editing-panel/override-props-group.tsx
|
|
3155
|
+
function OverridePropsGroup({ group, props, overrides }) {
|
|
2900
3156
|
const [isOpen, setIsOpen] = useStateByElement(group.id, true);
|
|
2901
3157
|
const handleClick = () => {
|
|
2902
3158
|
setIsOpen(!isOpen);
|
|
@@ -2905,7 +3161,7 @@ function OverridePropsGroup({ group, props }) {
|
|
|
2905
3161
|
const labelId = `label-${id2}`;
|
|
2906
3162
|
const contentId = `content-${id2}`;
|
|
2907
3163
|
const title = group.label;
|
|
2908
|
-
return /* @__PURE__ */
|
|
3164
|
+
return /* @__PURE__ */ React24.createElement(Box13, { "aria-label": `${title} section` }, /* @__PURE__ */ React24.createElement(
|
|
2909
3165
|
ListItemButton3,
|
|
2910
3166
|
{
|
|
2911
3167
|
id: labelId,
|
|
@@ -2915,7 +3171,7 @@ function OverridePropsGroup({ group, props }) {
|
|
|
2915
3171
|
p: 0,
|
|
2916
3172
|
sx: { "&:hover": { backgroundColor: "transparent" } }
|
|
2917
3173
|
},
|
|
2918
|
-
/* @__PURE__ */
|
|
3174
|
+
/* @__PURE__ */ React24.createElement(Stack16, { direction: "row", alignItems: "center", justifyItems: "start", flexGrow: 1, gap: 0.5 }, /* @__PURE__ */ React24.createElement(
|
|
2919
3175
|
ListItemText,
|
|
2920
3176
|
{
|
|
2921
3177
|
secondary: title,
|
|
@@ -2923,20 +3179,24 @@ function OverridePropsGroup({ group, props }) {
|
|
|
2923
3179
|
sx: { flexGrow: 0, flexShrink: 1, marginInlineEnd: 1 }
|
|
2924
3180
|
}
|
|
2925
3181
|
)),
|
|
2926
|
-
/* @__PURE__ */
|
|
2927
|
-
), /* @__PURE__ */
|
|
2928
|
-
|
|
2929
|
-
|
|
3182
|
+
/* @__PURE__ */ React24.createElement(CollapseIcon, { open: isOpen, color: "secondary", fontSize: "tiny" })
|
|
3183
|
+
), /* @__PURE__ */ React24.createElement(Collapse, { id: contentId, "aria-labelledby": labelId, in: isOpen, timeout: "auto" }, /* @__PURE__ */ React24.createElement(Stack16, { direction: "column", gap: 1, p: 2 }, group.props.map((overrideKey) => /* @__PURE__ */ React24.createElement(
|
|
3184
|
+
OverridePropControl,
|
|
3185
|
+
{
|
|
3186
|
+
key: overrideKey,
|
|
3187
|
+
overridableProp: props[overrideKey],
|
|
3188
|
+
overrides
|
|
3189
|
+
}
|
|
2930
3190
|
)))));
|
|
2931
3191
|
}
|
|
2932
3192
|
|
|
2933
3193
|
// src/components/instance-editing-panel/instance-editing-panel.tsx
|
|
2934
3194
|
function InstanceEditingPanel() {
|
|
2935
|
-
const
|
|
2936
|
-
const
|
|
2937
|
-
const
|
|
2938
|
-
const component =
|
|
2939
|
-
const overridableProps =
|
|
3195
|
+
const settings = useComponentInstanceSettings();
|
|
3196
|
+
const componentId = settings?.component_id?.value;
|
|
3197
|
+
const overrides = settings?.overrides?.value;
|
|
3198
|
+
const component = useComponent(componentId ?? null);
|
|
3199
|
+
const overridableProps = useOverridableProps(componentId ?? null);
|
|
2940
3200
|
const componentInstanceId = useSelectedElement2()?.element?.id ?? null;
|
|
2941
3201
|
if (!componentId || !overridableProps || !component) {
|
|
2942
3202
|
return null;
|
|
@@ -2947,118 +3207,88 @@ function InstanceEditingPanel() {
|
|
|
2947
3207
|
(groupId) => overridableProps.groups.items[groupId] ? overridableProps.groups.items[groupId] : null
|
|
2948
3208
|
).filter(Boolean);
|
|
2949
3209
|
const isEmpty = groups.length === 0 || Object.keys(overridableProps.props).length === 0;
|
|
2950
|
-
return /* @__PURE__ */
|
|
3210
|
+
return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(PanelHeader2, { sx: { justifyContent: "start", px: 2 } }, /* @__PURE__ */ React25.createElement(Stack17, { direction: "row", alignContent: "space-between", flexGrow: 1 }, /* @__PURE__ */ React25.createElement(Stack17, { direction: "row", alignItems: "center", justifyContent: "start", gap: 1, flexGrow: 1 }, /* @__PURE__ */ React25.createElement(ComponentsIcon3, { fontSize: "small", sx: { color: "text.tertiary" } }), /* @__PURE__ */ React25.createElement(PanelHeaderTitle2, null, component.name)), /* @__PURE__ */ React25.createElement(Tooltip4, { title: panelTitle }, /* @__PURE__ */ React25.createElement(IconButton6, { size: "tiny", onClick: handleEditComponent, "aria-label": panelTitle }, /* @__PURE__ */ React25.createElement(PencilIcon2, { fontSize: "tiny" }))))), /* @__PURE__ */ React25.createElement(PanelBody2, null, /* @__PURE__ */ React25.createElement(ControlAdornmentsProvider, { items: getFieldIndicators("settings") }, isEmpty ? /* @__PURE__ */ React25.createElement(EmptyState2, { onEditComponent: handleEditComponent }) : /* @__PURE__ */ React25.createElement(Stack17, { direction: "column", alignItems: "stretch" }, groups.map((group) => /* @__PURE__ */ React25.createElement(
|
|
3211
|
+
OverridePropsGroup,
|
|
3212
|
+
{
|
|
3213
|
+
key: group.id,
|
|
3214
|
+
group,
|
|
3215
|
+
props: overridableProps.props,
|
|
3216
|
+
overrides
|
|
3217
|
+
}
|
|
3218
|
+
))))));
|
|
2951
3219
|
}
|
|
2952
3220
|
|
|
2953
3221
|
// src/components/overridable-props/overridable-prop-control.tsx
|
|
2954
|
-
import * as
|
|
2955
|
-
import { ControlReplacementsProvider, PropKeyProvider, PropProvider, useBoundProp } from "@elementor/editor-controls";
|
|
2956
|
-
import { createTopLevelObjectType, useElement as useElement2 } from "@elementor/editor-editing-panel";
|
|
2957
|
-
|
|
2958
|
-
// src/prop-types/component-overridable-prop-type.ts
|
|
2959
|
-
import { createPropUtils as createPropUtils4 } from "@elementor/editor-props";
|
|
2960
|
-
import { z as z5 } from "@elementor/schema";
|
|
2961
|
-
var componentOverridablePropTypeUtil = createPropUtils4(
|
|
2962
|
-
"overridable",
|
|
2963
|
-
z5.object({
|
|
2964
|
-
override_key: z5.string(),
|
|
2965
|
-
origin_value: z5.object({
|
|
2966
|
-
$$type: z5.string(),
|
|
2967
|
-
value: z5.unknown()
|
|
2968
|
-
}).nullable()
|
|
2969
|
-
})
|
|
2970
|
-
);
|
|
3222
|
+
import * as React27 from "react";
|
|
3223
|
+
import { ControlReplacementsProvider, PropKeyProvider as PropKeyProvider2, PropProvider as PropProvider2, useBoundProp as useBoundProp2 } from "@elementor/editor-controls";
|
|
3224
|
+
import { createTopLevelObjectType as createTopLevelObjectType2, useElement as useElement2 } from "@elementor/editor-editing-panel";
|
|
2971
3225
|
|
|
2972
3226
|
// src/provider/overridable-prop-context.tsx
|
|
2973
|
-
import * as
|
|
3227
|
+
import * as React26 from "react";
|
|
2974
3228
|
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
2975
3229
|
var OverridablePropContext = createContext2(null);
|
|
2976
3230
|
function OverridablePropProvider({ children, ...props }) {
|
|
2977
|
-
return /* @__PURE__ */
|
|
3231
|
+
return /* @__PURE__ */ React26.createElement(OverridablePropContext.Provider, { value: props }, children);
|
|
2978
3232
|
}
|
|
2979
3233
|
var useOverridablePropValue = () => useContext2(OverridablePropContext)?.value;
|
|
2980
3234
|
|
|
2981
|
-
// src/store/actions/update-overridable-prop-origin-value.ts
|
|
2982
|
-
import { __dispatch as dispatch11, __getState as getState13 } from "@elementor/store";
|
|
2983
|
-
function updateOverridablePropOriginValue(componentId, propValue) {
|
|
2984
|
-
const overridableProps = selectOverridableProps(getState13(), componentId);
|
|
2985
|
-
if (!overridableProps) {
|
|
2986
|
-
return;
|
|
2987
|
-
}
|
|
2988
|
-
const existingOverridableProp = overridableProps.props[propValue.override_key];
|
|
2989
|
-
if (!existingOverridableProp) {
|
|
2990
|
-
return;
|
|
2991
|
-
}
|
|
2992
|
-
const newOverridableProps = {
|
|
2993
|
-
...overridableProps,
|
|
2994
|
-
props: {
|
|
2995
|
-
...overridableProps.props,
|
|
2996
|
-
[existingOverridableProp.overrideKey]: {
|
|
2997
|
-
...existingOverridableProp,
|
|
2998
|
-
originValue: propValue.origin_value
|
|
2999
|
-
}
|
|
3000
|
-
}
|
|
3001
|
-
};
|
|
3002
|
-
dispatch11(
|
|
3003
|
-
slice.actions.setOverridableProps({
|
|
3004
|
-
componentId,
|
|
3005
|
-
overridableProps: newOverridableProps
|
|
3006
|
-
})
|
|
3007
|
-
);
|
|
3008
|
-
}
|
|
3009
|
-
|
|
3010
3235
|
// src/components/overridable-props/overridable-prop-control.tsx
|
|
3011
3236
|
function OverridablePropControl({
|
|
3012
3237
|
OriginalControl,
|
|
3013
3238
|
...props
|
|
3014
3239
|
}) {
|
|
3015
3240
|
const { elementType } = useElement2();
|
|
3016
|
-
const { value, bind, setValue, placeholder, ...propContext } =
|
|
3241
|
+
const { value, bind, setValue, placeholder, ...propContext } = useBoundProp2(componentOverridablePropTypeUtil);
|
|
3017
3242
|
const componentId = useCurrentComponentId();
|
|
3243
|
+
const overridableProps = useOverridableProps(componentId);
|
|
3018
3244
|
if (!componentId) {
|
|
3019
3245
|
return null;
|
|
3020
3246
|
}
|
|
3021
3247
|
if (!value?.override_key) {
|
|
3022
3248
|
throw new Error("Override key is required");
|
|
3023
3249
|
}
|
|
3250
|
+
const isComponentInstance2 = elementType.key === "e-component";
|
|
3024
3251
|
const setOverridableValue = (newValue) => {
|
|
3025
|
-
const
|
|
3252
|
+
const propValue2 = {
|
|
3026
3253
|
...value,
|
|
3027
3254
|
origin_value: newValue[bind]
|
|
3028
3255
|
};
|
|
3029
|
-
setValue(
|
|
3030
|
-
|
|
3256
|
+
setValue(propValue2);
|
|
3257
|
+
updateOverridableProp(componentId, propValue2);
|
|
3031
3258
|
};
|
|
3032
|
-
const
|
|
3259
|
+
const defaultPropType = elementType.propsSchema[bind];
|
|
3260
|
+
const propType = createTopLevelObjectType2({
|
|
3033
3261
|
schema: {
|
|
3034
|
-
[bind]:
|
|
3262
|
+
[bind]: isComponentInstance2 && overridableProps ? getPropTypeForComponentOverride(overridableProps.props[value.override_key]) ?? defaultPropType : defaultPropType
|
|
3035
3263
|
}
|
|
3036
3264
|
});
|
|
3265
|
+
const propValue = isComponentInstance2 ? (value.origin_value?.value).override_value : value.origin_value;
|
|
3037
3266
|
const objectPlaceholder = placeholder ? { [bind]: placeholder } : void 0;
|
|
3038
|
-
return /* @__PURE__ */
|
|
3039
|
-
|
|
3267
|
+
return /* @__PURE__ */ React27.createElement(OverridablePropProvider, { value }, /* @__PURE__ */ React27.createElement(
|
|
3268
|
+
PropProvider2,
|
|
3040
3269
|
{
|
|
3041
3270
|
...propContext,
|
|
3042
3271
|
propType,
|
|
3043
3272
|
setValue: setOverridableValue,
|
|
3044
|
-
value: {
|
|
3273
|
+
value: {
|
|
3274
|
+
[bind]: propValue
|
|
3275
|
+
},
|
|
3045
3276
|
placeholder: objectPlaceholder
|
|
3046
3277
|
},
|
|
3047
|
-
/* @__PURE__ */
|
|
3278
|
+
/* @__PURE__ */ React27.createElement(PropKeyProvider2, { bind }, /* @__PURE__ */ React27.createElement(ControlReplacementsProvider, { replacements: [] }, /* @__PURE__ */ React27.createElement(OriginalControl, { ...props })))
|
|
3048
3279
|
));
|
|
3049
3280
|
}
|
|
3050
3281
|
|
|
3051
3282
|
// src/components/overridable-props/overridable-prop-indicator.tsx
|
|
3052
|
-
import * as
|
|
3053
|
-
import { useBoundProp as
|
|
3283
|
+
import * as React29 from "react";
|
|
3284
|
+
import { useBoundProp as useBoundProp3 } from "@elementor/editor-controls";
|
|
3054
3285
|
import { useElement as useElement3 } from "@elementor/editor-editing-panel";
|
|
3055
|
-
import { getWidgetsCache as
|
|
3056
|
-
import { __getState as getState16 } from "@elementor/store";
|
|
3286
|
+
import { getWidgetsCache as getWidgetsCache3 } from "@elementor/editor-elements";
|
|
3057
3287
|
import { bindPopover as bindPopover2, bindTrigger as bindTrigger4, Popover as Popover4, Tooltip as Tooltip5, usePopupState as usePopupState4 } from "@elementor/ui";
|
|
3058
3288
|
import { __ as __23 } from "@wordpress/i18n";
|
|
3059
3289
|
|
|
3060
3290
|
// src/store/actions/set-overridable-prop.ts
|
|
3061
|
-
import { __dispatch as dispatch12, __getState as
|
|
3291
|
+
import { __dispatch as dispatch12, __getState as getState13 } from "@elementor/store";
|
|
3062
3292
|
import { generateUniqueId as generateUniqueId4 } from "@elementor/utils";
|
|
3063
3293
|
function setOverridableProp({
|
|
3064
3294
|
componentId,
|
|
@@ -3069,9 +3299,10 @@ function setOverridableProp({
|
|
|
3069
3299
|
propKey,
|
|
3070
3300
|
elType,
|
|
3071
3301
|
widgetType,
|
|
3072
|
-
originValue
|
|
3302
|
+
originValue,
|
|
3303
|
+
originPropFields
|
|
3073
3304
|
}) {
|
|
3074
|
-
const overridableProps = selectOverridableProps(
|
|
3305
|
+
const overridableProps = selectOverridableProps(getState13(), componentId);
|
|
3075
3306
|
if (!overridableProps) {
|
|
3076
3307
|
return;
|
|
3077
3308
|
}
|
|
@@ -3091,7 +3322,8 @@ function setOverridableProp({
|
|
|
3091
3322
|
widgetType,
|
|
3092
3323
|
elType,
|
|
3093
3324
|
originValue,
|
|
3094
|
-
groupId: currentGroupId
|
|
3325
|
+
groupId: currentGroupId,
|
|
3326
|
+
originPropFields
|
|
3095
3327
|
};
|
|
3096
3328
|
const stateAfterRemovingDuplicates = removePropsFromState(
|
|
3097
3329
|
{ ...overridableProps, groups: groupsAfterResolve },
|
|
@@ -3120,13 +3352,13 @@ function setOverridableProp({
|
|
|
3120
3352
|
}
|
|
3121
3353
|
|
|
3122
3354
|
// src/components/overridable-props/indicator.tsx
|
|
3123
|
-
import * as
|
|
3355
|
+
import * as React28 from "react";
|
|
3124
3356
|
import { forwardRef as forwardRef2 } from "react";
|
|
3125
3357
|
import { CheckIcon, PlusIcon } from "@elementor/icons";
|
|
3126
|
-
import { Box as
|
|
3358
|
+
import { Box as Box14, styled as styled3 } from "@elementor/ui";
|
|
3127
3359
|
import { __ as __22 } from "@wordpress/i18n";
|
|
3128
3360
|
var SIZE2 = "tiny";
|
|
3129
|
-
var IconContainer = styled3(
|
|
3361
|
+
var IconContainer = styled3(Box14)`
|
|
3130
3362
|
pointer-events: none;
|
|
3131
3363
|
opacity: 0;
|
|
3132
3364
|
transition: opacity 0.2s ease-in-out;
|
|
@@ -3143,7 +3375,7 @@ var IconContainer = styled3(Box13)`
|
|
|
3143
3375
|
stroke-width: 2px;
|
|
3144
3376
|
}
|
|
3145
3377
|
`;
|
|
3146
|
-
var Content = styled3(
|
|
3378
|
+
var Content = styled3(Box14)`
|
|
3147
3379
|
position: relative;
|
|
3148
3380
|
display: flex;
|
|
3149
3381
|
align-items: center;
|
|
@@ -3180,22 +3412,22 @@ var Content = styled3(Box13)`
|
|
|
3180
3412
|
}
|
|
3181
3413
|
}
|
|
3182
3414
|
`;
|
|
3183
|
-
var Indicator = forwardRef2(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */
|
|
3415
|
+
var Indicator = forwardRef2(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */ React28.createElement(Content, { ref, ...props, className: isOpen || isOverridable ? "enlarged" : "" }, /* @__PURE__ */ React28.createElement(
|
|
3184
3416
|
IconContainer,
|
|
3185
3417
|
{
|
|
3186
3418
|
className: "icon",
|
|
3187
3419
|
"aria-label": isOverridable ? __22("Overridable property", "elementor") : __22("Make prop overridable", "elementor")
|
|
3188
3420
|
},
|
|
3189
|
-
isOverridable ? /* @__PURE__ */
|
|
3421
|
+
isOverridable ? /* @__PURE__ */ React28.createElement(CheckIcon, { fontSize: SIZE2 }) : /* @__PURE__ */ React28.createElement(PlusIcon, { fontSize: SIZE2 })
|
|
3190
3422
|
)));
|
|
3191
3423
|
|
|
3192
3424
|
// src/components/overridable-props/utils/get-overridable-prop.ts
|
|
3193
|
-
import { __getState as
|
|
3425
|
+
import { __getState as getState14 } from "@elementor/store";
|
|
3194
3426
|
function getOverridableProp({
|
|
3195
3427
|
componentId,
|
|
3196
3428
|
overrideKey
|
|
3197
3429
|
}) {
|
|
3198
|
-
const overridableProps = selectOverridableProps(
|
|
3430
|
+
const overridableProps = selectOverridableProps(getState14(), componentId);
|
|
3199
3431
|
if (!overridableProps) {
|
|
3200
3432
|
return void 0;
|
|
3201
3433
|
}
|
|
@@ -3205,22 +3437,22 @@ function getOverridableProp({
|
|
|
3205
3437
|
// src/components/overridable-props/overridable-prop-indicator.tsx
|
|
3206
3438
|
var FORBIDDEN_KEYS = ["_cssid", "attributes"];
|
|
3207
3439
|
function OverridablePropIndicator() {
|
|
3208
|
-
const { bind } =
|
|
3440
|
+
const { bind } = useBoundProp3();
|
|
3209
3441
|
const componentId = useCurrentComponentId();
|
|
3210
|
-
|
|
3442
|
+
const overridableProps = useOverridableProps(componentId);
|
|
3443
|
+
if (!isPropAllowed(bind) || !componentId || !overridableProps) {
|
|
3211
3444
|
return null;
|
|
3212
3445
|
}
|
|
3213
|
-
|
|
3214
|
-
return /* @__PURE__ */ React27.createElement(Content2, { componentId, overridableProps });
|
|
3446
|
+
return /* @__PURE__ */ React29.createElement(Content2, { componentId, overridableProps });
|
|
3215
3447
|
}
|
|
3216
3448
|
function Content2({ componentId, overridableProps }) {
|
|
3217
3449
|
const {
|
|
3218
3450
|
element: { id: elementId },
|
|
3219
3451
|
elementType
|
|
3220
3452
|
} = useElement3();
|
|
3221
|
-
const { value, bind, propType } =
|
|
3453
|
+
const { value, bind, propType } = useBoundProp3();
|
|
3222
3454
|
const contextOverridableValue = useOverridablePropValue();
|
|
3223
|
-
const { value: boundPropOverridableValue, setValue: setOverridableValue } =
|
|
3455
|
+
const { value: boundPropOverridableValue, setValue: setOverridableValue } = useBoundProp3(
|
|
3224
3456
|
componentOverridablePropTypeUtil
|
|
3225
3457
|
);
|
|
3226
3458
|
const overridableValue = boundPropOverridableValue ?? contextOverridableValue;
|
|
@@ -3229,9 +3461,11 @@ function Content2({ componentId, overridableProps }) {
|
|
|
3229
3461
|
});
|
|
3230
3462
|
const triggerProps = bindTrigger4(popupState);
|
|
3231
3463
|
const popoverProps = bindPopover2(popupState);
|
|
3232
|
-
const { elType } =
|
|
3464
|
+
const { elType } = getWidgetsCache3()?.[elementType.key] ?? { elType: "widget" };
|
|
3233
3465
|
const handleSubmit = ({ label, group }) => {
|
|
3234
|
-
const
|
|
3466
|
+
const propTypeDefault = propType.default ?? {};
|
|
3467
|
+
const originValue = (!overridableValue ? value : overridableValue?.origin_value) ?? propTypeDefault;
|
|
3468
|
+
const matchingOverridableProp = overridableValue ? overridableProps?.props?.[overridableValue.override_key] : void 0;
|
|
3235
3469
|
const overridablePropConfig = setOverridableProp({
|
|
3236
3470
|
componentId,
|
|
3237
3471
|
overrideKey: overridableValue?.override_key ?? null,
|
|
@@ -3241,7 +3475,8 @@ function Content2({ componentId, overridableProps }) {
|
|
|
3241
3475
|
propKey: bind,
|
|
3242
3476
|
elType: elType ?? "widget",
|
|
3243
3477
|
widgetType: elementType.key,
|
|
3244
|
-
originValue
|
|
3478
|
+
originValue,
|
|
3479
|
+
originPropFields: matchingOverridableProp?.originPropFields
|
|
3245
3480
|
});
|
|
3246
3481
|
if (!overridableValue && overridablePropConfig) {
|
|
3247
3482
|
setOverridableValue({
|
|
@@ -3252,7 +3487,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
3252
3487
|
popupState.close();
|
|
3253
3488
|
};
|
|
3254
3489
|
const overridableConfig = overridableValue ? getOverridableProp({ componentId, overrideKey: overridableValue.override_key }) : void 0;
|
|
3255
|
-
return /* @__PURE__ */
|
|
3490
|
+
return /* @__PURE__ */ React29.createElement(React29.Fragment, null, /* @__PURE__ */ React29.createElement(Tooltip5, { placement: "top", title: __23("Override Property", "elementor") }, /* @__PURE__ */ React29.createElement(Indicator, { ...triggerProps, isOpen: !!popoverProps.open, isOverridable: !!overridableValue })), /* @__PURE__ */ React29.createElement(
|
|
3256
3491
|
Popover4,
|
|
3257
3492
|
{
|
|
3258
3493
|
disableScrollLock: true,
|
|
@@ -3269,7 +3504,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
3269
3504
|
},
|
|
3270
3505
|
...popoverProps
|
|
3271
3506
|
},
|
|
3272
|
-
/* @__PURE__ */
|
|
3507
|
+
/* @__PURE__ */ React29.createElement(
|
|
3273
3508
|
OverridablePropForm,
|
|
3274
3509
|
{
|
|
3275
3510
|
onSubmit: handleSubmit,
|
|
@@ -3374,7 +3609,7 @@ import { getMCPByDomain as getMCPByDomain2 } from "@elementor/editor-mcp";
|
|
|
3374
3609
|
|
|
3375
3610
|
// src/mcp/save-as-component-tool.ts
|
|
3376
3611
|
import { DOCUMENT_STRUCTURE_URI, WIDGET_SCHEMA_URI } from "@elementor/editor-canvas";
|
|
3377
|
-
import { getContainer as getContainer4, getElementType, getWidgetsCache as
|
|
3612
|
+
import { getContainer as getContainer4, getElementType as getElementType2, getWidgetsCache as getWidgetsCache4 } from "@elementor/editor-elements";
|
|
3378
3613
|
import { getMCPByDomain, toolPrompts } from "@elementor/editor-mcp";
|
|
3379
3614
|
import { AxiosError } from "@elementor/http-client";
|
|
3380
3615
|
import { z as z6 } from "@elementor/schema";
|
|
@@ -3456,7 +3691,7 @@ function enrichOverridableProps(input, rootElement) {
|
|
|
3456
3691
|
}
|
|
3457
3692
|
const elType = element.elType;
|
|
3458
3693
|
const widgetType = element.widgetType || element.elType;
|
|
3459
|
-
const elementType =
|
|
3694
|
+
const elementType = getElementType2(widgetType);
|
|
3460
3695
|
if (!elementType) {
|
|
3461
3696
|
throw new Error(
|
|
3462
3697
|
`Element type "${widgetType}" is not atomic or does not have a settings schema. Cannot expose property "${propKey}" for element "${elementId}".`
|
|
@@ -3530,7 +3765,7 @@ function generateLabel(propKey) {
|
|
|
3530
3765
|
return `${uniqueId} - ${propKey}`;
|
|
3531
3766
|
}
|
|
3532
3767
|
function getValidElementTypes() {
|
|
3533
|
-
const types =
|
|
3768
|
+
const types = getWidgetsCache4();
|
|
3534
3769
|
if (!types) {
|
|
3535
3770
|
return [];
|
|
3536
3771
|
}
|
|
@@ -3720,7 +3955,7 @@ function removeComponentStyles(id2) {
|
|
|
3720
3955
|
|
|
3721
3956
|
// src/store/components-styles-provider.ts
|
|
3722
3957
|
import { createStylesProvider } from "@elementor/editor-styles-repository";
|
|
3723
|
-
import { __getState as
|
|
3958
|
+
import { __getState as getState15, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
|
|
3724
3959
|
var componentsStylesProvider = createStylesProvider({
|
|
3725
3960
|
key: "components-styles",
|
|
3726
3961
|
priority: 100,
|
|
@@ -3732,22 +3967,22 @@ var componentsStylesProvider = createStylesProvider({
|
|
|
3732
3967
|
),
|
|
3733
3968
|
actions: {
|
|
3734
3969
|
all: () => {
|
|
3735
|
-
return selectFlatStyles(
|
|
3970
|
+
return selectFlatStyles(getState15());
|
|
3736
3971
|
},
|
|
3737
3972
|
get: (id2) => {
|
|
3738
|
-
return selectFlatStyles(
|
|
3973
|
+
return selectFlatStyles(getState15()).find((style) => style.id === id2) ?? null;
|
|
3739
3974
|
}
|
|
3740
3975
|
}
|
|
3741
3976
|
});
|
|
3742
3977
|
|
|
3743
3978
|
// src/sync/create-components-before-save.ts
|
|
3744
3979
|
import { updateElementSettings as updateElementSettings3 } from "@elementor/editor-elements";
|
|
3745
|
-
import { __dispatch as dispatch15, __getState as
|
|
3980
|
+
import { __dispatch as dispatch15, __getState as getState16 } from "@elementor/store";
|
|
3746
3981
|
async function createComponentsBeforeSave({
|
|
3747
3982
|
elements,
|
|
3748
3983
|
status
|
|
3749
3984
|
}) {
|
|
3750
|
-
const unpublishedComponents = selectUnpublishedComponents(
|
|
3985
|
+
const unpublishedComponents = selectUnpublishedComponents(getState16());
|
|
3751
3986
|
if (!unpublishedComponents.length) {
|
|
3752
3987
|
return;
|
|
3753
3988
|
}
|
|
@@ -3799,8 +4034,11 @@ function updateComponentInstances(elements, uidToComponentId) {
|
|
|
3799
4034
|
function shouldUpdateElement(element, uidToComponentId) {
|
|
3800
4035
|
if (element.widgetType === "e-component") {
|
|
3801
4036
|
const currentComponentId = element.settings?.component_instance?.value?.component_id.value;
|
|
3802
|
-
if (currentComponentId && uidToComponentId.has(currentComponentId)) {
|
|
3803
|
-
return {
|
|
4037
|
+
if (currentComponentId && uidToComponentId.has(currentComponentId.toString())) {
|
|
4038
|
+
return {
|
|
4039
|
+
shouldUpdate: true,
|
|
4040
|
+
newComponentId: uidToComponentId.get(currentComponentId.toString())
|
|
4041
|
+
};
|
|
3804
4042
|
}
|
|
3805
4043
|
}
|
|
3806
4044
|
return { shouldUpdate: false, newComponentId: null };
|
|
@@ -3821,7 +4059,7 @@ function updateElementComponentId(elementId, componentId) {
|
|
|
3821
4059
|
}
|
|
3822
4060
|
|
|
3823
4061
|
// src/sync/set-component-overridable-props-settings-before-save.ts
|
|
3824
|
-
import { __getState as
|
|
4062
|
+
import { __getState as getState17 } from "@elementor/store";
|
|
3825
4063
|
var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
3826
4064
|
container
|
|
3827
4065
|
}) => {
|
|
@@ -3829,7 +4067,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
3829
4067
|
if (!currentDocument || currentDocument.config.type !== COMPONENT_DOCUMENT_TYPE) {
|
|
3830
4068
|
return;
|
|
3831
4069
|
}
|
|
3832
|
-
const overridableProps = selectOverridableProps(
|
|
4070
|
+
const overridableProps = selectOverridableProps(getState17(), currentDocument.id);
|
|
3833
4071
|
if (overridableProps) {
|
|
3834
4072
|
container.settings.set("overridable_props", overridableProps);
|
|
3835
4073
|
}
|
|
@@ -3837,7 +4075,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
3837
4075
|
|
|
3838
4076
|
// src/sync/update-archived-component-before-save.ts
|
|
3839
4077
|
import { notify } from "@elementor/editor-notifications";
|
|
3840
|
-
import { __getState as
|
|
4078
|
+
import { __getState as getState18 } from "@elementor/store";
|
|
3841
4079
|
var failedNotification = (message) => ({
|
|
3842
4080
|
type: "error",
|
|
3843
4081
|
message: `Failed to archive components: ${message}`,
|
|
@@ -3850,7 +4088,7 @@ var successNotification = (message) => ({
|
|
|
3850
4088
|
});
|
|
3851
4089
|
var updateArchivedComponentBeforeSave = async () => {
|
|
3852
4090
|
try {
|
|
3853
|
-
const archivedComponents = selectArchivedComponents(
|
|
4091
|
+
const archivedComponents = selectArchivedComponents(getState18());
|
|
3854
4092
|
if (!archivedComponents.length) {
|
|
3855
4093
|
return;
|
|
3856
4094
|
}
|