@elementor/editor-editing-panel 3.33.0-149 → 3.33.0-151

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1035,6 +1035,41 @@ declare const controlTypes: {
1035
1035
  key: "key-value";
1036
1036
  };
1037
1037
  };
1038
+ readonly 'html-tag': {
1039
+ readonly component: ControlComponent<({ options, onChange, fallbackLabels }: {
1040
+ options: {
1041
+ label: string;
1042
+ value: _elementor_editor_props.StringPropValue["value"];
1043
+ disabled?: boolean;
1044
+ }[];
1045
+ onChange?: (newValue: string | null, previousValue: string | null | undefined) => void;
1046
+ fallbackLabels?: Record<string, string>;
1047
+ }) => react.JSX.Element>;
1048
+ readonly layout: "two-columns";
1049
+ readonly propTypeUtil: {
1050
+ extract: (prop: unknown) => string | null;
1051
+ isValid: (prop: unknown) => prop is _elementor_editor_props.TransformablePropValue<"string", string | null>;
1052
+ create: {
1053
+ (value: string | null): _elementor_editor_props.TransformablePropValue<"string", string | null>;
1054
+ (value: string | null, createOptions?: _elementor_editor_props.CreateOptions): _elementor_editor_props.TransformablePropValue<"string", string | null>;
1055
+ (value: (prev?: string | null | undefined) => string | null, createOptions: _elementor_editor_props.CreateOptions): _elementor_editor_props.TransformablePropValue<"string", string | null>;
1056
+ };
1057
+ schema: zod.ZodObject<{
1058
+ $$type: zod.ZodLiteral<"string">;
1059
+ value: zod.ZodType<string | null, zod.ZodTypeDef, string | null>;
1060
+ disabled: zod.ZodOptional<zod.ZodBoolean>;
1061
+ }, "strict", zod.ZodTypeAny, {
1062
+ $$type: "string";
1063
+ value: string | null;
1064
+ disabled?: boolean | undefined;
1065
+ }, {
1066
+ $$type: "string";
1067
+ value: string | null;
1068
+ disabled?: boolean | undefined;
1069
+ }>;
1070
+ key: "string";
1071
+ };
1072
+ };
1038
1073
  };
1039
1074
  type ControlType = keyof typeof controlTypes;
1040
1075
  declare class ControlsRegistry {
package/dist/index.d.ts CHANGED
@@ -1035,6 +1035,41 @@ declare const controlTypes: {
1035
1035
  key: "key-value";
1036
1036
  };
1037
1037
  };
1038
+ readonly 'html-tag': {
1039
+ readonly component: ControlComponent<({ options, onChange, fallbackLabels }: {
1040
+ options: {
1041
+ label: string;
1042
+ value: _elementor_editor_props.StringPropValue["value"];
1043
+ disabled?: boolean;
1044
+ }[];
1045
+ onChange?: (newValue: string | null, previousValue: string | null | undefined) => void;
1046
+ fallbackLabels?: Record<string, string>;
1047
+ }) => react.JSX.Element>;
1048
+ readonly layout: "two-columns";
1049
+ readonly propTypeUtil: {
1050
+ extract: (prop: unknown) => string | null;
1051
+ isValid: (prop: unknown) => prop is _elementor_editor_props.TransformablePropValue<"string", string | null>;
1052
+ create: {
1053
+ (value: string | null): _elementor_editor_props.TransformablePropValue<"string", string | null>;
1054
+ (value: string | null, createOptions?: _elementor_editor_props.CreateOptions): _elementor_editor_props.TransformablePropValue<"string", string | null>;
1055
+ (value: (prev?: string | null | undefined) => string | null, createOptions: _elementor_editor_props.CreateOptions): _elementor_editor_props.TransformablePropValue<"string", string | null>;
1056
+ };
1057
+ schema: zod.ZodObject<{
1058
+ $$type: zod.ZodLiteral<"string">;
1059
+ value: zod.ZodType<string | null, zod.ZodTypeDef, string | null>;
1060
+ disabled: zod.ZodOptional<zod.ZodBoolean>;
1061
+ }, "strict", zod.ZodTypeAny, {
1062
+ $$type: "string";
1063
+ value: string | null;
1064
+ disabled?: boolean | undefined;
1065
+ }, {
1066
+ $$type: "string";
1067
+ value: string | null;
1068
+ disabled?: boolean | undefined;
1069
+ }>;
1070
+ key: "string";
1071
+ };
1072
+ };
1038
1073
  };
1039
1074
  type ControlType = keyof typeof controlTypes;
1040
1075
  declare class ControlsRegistry {
package/dist/index.js CHANGED
@@ -1716,7 +1716,7 @@ var import_editor_elements12 = require("@elementor/editor-elements");
1716
1716
  var import_editor_panels = require("@elementor/editor-panels");
1717
1717
  var import_editor_ui6 = require("@elementor/editor-ui");
1718
1718
  var import_icons24 = require("@elementor/icons");
1719
- var import_session7 = require("@elementor/session");
1719
+ var import_session8 = require("@elementor/session");
1720
1720
  var import_ui45 = require("@elementor/ui");
1721
1721
  var import_i18n62 = require("@wordpress/i18n");
1722
1722
 
@@ -1819,7 +1819,7 @@ var useStateByElement = (key, initialValue) => {
1819
1819
  // src/components/settings-tab.tsx
1820
1820
  var React23 = __toESM(require("react"));
1821
1821
  var import_editor_controls5 = require("@elementor/editor-controls");
1822
- var import_session4 = require("@elementor/session");
1822
+ var import_session5 = require("@elementor/session");
1823
1823
  var import_ui18 = require("@elementor/ui");
1824
1824
 
1825
1825
  // src/controls-registry/control.tsx
@@ -1841,7 +1841,8 @@ var controlTypes = {
1841
1841
  switch: { component: import_editor_controls3.SwitchControl, layout: "two-columns", propTypeUtil: import_editor_props4.booleanPropTypeUtil },
1842
1842
  number: { component: import_editor_controls3.NumberControl, layout: "two-columns", propTypeUtil: import_editor_props4.numberPropTypeUtil },
1843
1843
  repeatable: { component: import_editor_controls3.RepeatableControl, layout: "full", propTypeUtil: void 0 },
1844
- "key-value": { component: import_editor_controls3.KeyValueControl, layout: "full", propTypeUtil: import_editor_props4.keyValuePropTypeUtil }
1844
+ "key-value": { component: import_editor_controls3.KeyValueControl, layout: "full", propTypeUtil: import_editor_props4.keyValuePropTypeUtil },
1845
+ "html-tag": { component: import_editor_controls3.HtmlTagControl, layout: "two-columns", propTypeUtil: import_editor_props4.stringPropTypeUtil }
1845
1846
  };
1846
1847
  var ControlsRegistry = class {
1847
1848
  constructor(controlsRegistry2 = controlTypes) {
@@ -1923,6 +1924,7 @@ var import_i18n8 = require("@wordpress/i18n");
1923
1924
 
1924
1925
  // src/utils/prop-dependency-utils.ts
1925
1926
  var import_editor_props5 = require("@elementor/editor-props");
1927
+ var import_session4 = require("@elementor/session");
1926
1928
  function extractOrderedDependencies(bind, propsSchema, elementValues, dependenciesPerTargetMapping) {
1927
1929
  const prop = getPropType(propsSchema, elementValues, bind.split("."));
1928
1930
  if (!prop) {
@@ -1957,7 +1959,7 @@ function extractPropOrderedDependencies(bind, dependenciesPerTargetMapping) {
1957
1959
  []
1958
1960
  );
1959
1961
  }
1960
- function updateValues(values, dependencies, propsSchema, elementValues) {
1962
+ function getUpdatedValues(values, dependencies, propsSchema, elementValues, elementId) {
1961
1963
  if (!dependencies.length) {
1962
1964
  return values;
1963
1965
  }
@@ -1969,10 +1971,29 @@ function updateValues(values, dependencies, propsSchema, elementValues) {
1969
1971
  if (!propType) {
1970
1972
  return newValues;
1971
1973
  }
1972
- if (!(0, import_editor_props5.isDependencyMet)(propType?.dependencies, combinedValues)) {
1974
+ const testDependencies = {
1975
+ previousValues: (0, import_editor_props5.isDependencyMet)(propType.dependencies, elementValues),
1976
+ newValues: (0, import_editor_props5.isDependencyMet)(propType.dependencies, combinedValues)
1977
+ };
1978
+ if (!testDependencies.newValues.isMet) {
1979
+ const newValue = handleUnmetCondition({
1980
+ failingDependencies: testDependencies.newValues.failingDependencies,
1981
+ dependency,
1982
+ elementValues: combinedValues,
1983
+ defaultValue: propType.default,
1984
+ elementId
1985
+ });
1973
1986
  return {
1974
1987
  ...newValues,
1975
- ...updateValue(path, null, combinedValues)
1988
+ ...updateValue(path, newValue, combinedValues)
1989
+ };
1990
+ }
1991
+ if (!testDependencies.previousValues.isMet) {
1992
+ const savedValue = retrievePreviousValueFromStorage({ path: dependency, elementId });
1993
+ removePreviousValueFromStorage({ path: dependency, elementId });
1994
+ return {
1995
+ ...newValues,
1996
+ ...updateValue(path, savedValue ?? propType.default, combinedValues)
1976
1997
  };
1977
1998
  }
1978
1999
  return newValues;
@@ -1989,11 +2010,19 @@ function getPropType(schema, elementValues, path) {
1989
2010
  if (!baseProp) {
1990
2011
  return null;
1991
2012
  }
1992
- return keys.reduce((prop, key, index) => {
1993
- if (!prop?.kind) {
1994
- return null;
1995
- }
1996
- if ("union" === prop.kind) {
2013
+ return keys.reduce(
2014
+ (prop, key, index) => evaluatePropType({ prop, key, index, path, elementValues, basePropKey }),
2015
+ baseProp
2016
+ );
2017
+ }
2018
+ function evaluatePropType(props) {
2019
+ const { prop } = props;
2020
+ if (!prop?.kind) {
2021
+ return null;
2022
+ }
2023
+ const { key, index, path, elementValues, basePropKey } = props;
2024
+ switch (prop.kind) {
2025
+ case "union":
1997
2026
  const value = (0, import_editor_props5.extractValue)(path.slice(0, index + 1), elementValues);
1998
2027
  const type = value?.$$type ?? null;
1999
2028
  return getPropType(
@@ -2001,15 +2030,12 @@ function getPropType(schema, elementValues, path) {
2001
2030
  elementValues,
2002
2031
  path.slice(0, index + 2)
2003
2032
  );
2004
- }
2005
- if ("array" === prop.kind) {
2033
+ case "array":
2006
2034
  return prop.item_prop_type;
2007
- }
2008
- if ("object" === prop.kind) {
2035
+ case "object":
2009
2036
  return prop.shape[key];
2010
- }
2011
- return prop[key];
2012
- }, baseProp);
2037
+ }
2038
+ return prop[key];
2013
2039
  }
2014
2040
  function updateValue(path, value, values) {
2015
2041
  const topPropKey = path[0];
@@ -2019,13 +2045,43 @@ function updateValue(path, value, values) {
2019
2045
  return null;
2020
2046
  }
2021
2047
  if (index === path.length - 1) {
2022
- carry[key] = value !== null ? { ...carry[key] ?? {}, value } : null;
2048
+ carry[key] = value ?? null;
2023
2049
  return carry[key]?.value ?? carry.value;
2024
2050
  }
2025
2051
  return carry[key]?.value ?? carry.value;
2026
2052
  }, newValue);
2027
2053
  return { [topPropKey]: newValue[topPropKey] ?? null };
2028
2054
  }
2055
+ function handleUnmetCondition(props) {
2056
+ const { failingDependencies, dependency, elementValues, defaultValue, elementId } = props;
2057
+ const newValue = failingDependencies.find((term) => term.newValue)?.newValue ?? null;
2058
+ const currentValue = (0, import_editor_props5.extractValue)(dependency.split("."), elementValues) ?? defaultValue;
2059
+ savePreviousValueToStorage({
2060
+ path: dependency,
2061
+ elementId,
2062
+ value: currentValue
2063
+ });
2064
+ return newValue;
2065
+ }
2066
+ function savePreviousValueToStorage({ path, elementId, value }) {
2067
+ const prefix = `elementor/${elementId}`;
2068
+ const savedValue = retrievePreviousValueFromStorage({ path, elementId });
2069
+ if (savedValue) {
2070
+ return;
2071
+ }
2072
+ const key = `${prefix}:${path}`;
2073
+ (0, import_session4.setSessionStorageItem)(key, value);
2074
+ }
2075
+ function retrievePreviousValueFromStorage({ path, elementId }) {
2076
+ const prefix = `elementor/${elementId}`;
2077
+ const key = `${prefix}:${path}`;
2078
+ return (0, import_session4.getSessionStorageItem)(key) ?? null;
2079
+ }
2080
+ function removePreviousValueFromStorage({ path, elementId }) {
2081
+ const prefix = `elementor/${elementId}`;
2082
+ const key = `${prefix}:${path}`;
2083
+ (0, import_session4.removeSessionStorageItem)(key);
2084
+ }
2029
2085
 
2030
2086
  // src/controls-registry/create-top-level-object-type.ts
2031
2087
  var createTopLevelObjectType = ({ schema }) => {
@@ -2061,10 +2117,10 @@ var SettingsField = ({ bind, children, propDisplayName }) => {
2061
2117
  elementSettingValues,
2062
2118
  dependenciesPerTargetMapping
2063
2119
  );
2064
- const settings = updateValues(newValue, dependents, propsSchema, elementSettingValues);
2120
+ const settings = getUpdatedValues(newValue, dependents, propsSchema, elementSettingValues, elementId);
2065
2121
  undoableUpdateElementProp(settings);
2066
2122
  };
2067
- const isDisabled = (prop) => !(0, import_editor_props6.isDependencyMet)(prop?.dependencies, elementSettingValues);
2123
+ const isDisabled = (prop) => !(0, import_editor_props6.isDependencyMet)(prop?.dependencies, elementSettingValues).isMet;
2068
2124
  return /* @__PURE__ */ React19.createElement(import_editor_controls4.PropProvider, { propType, value, setValue, isDisabled }, /* @__PURE__ */ React19.createElement(import_editor_controls4.PropKeyProvider, { bind }, children));
2069
2125
  };
2070
2126
  function useUndoableUpdateElementProp({
@@ -2204,7 +2260,7 @@ var SettingsTab = () => {
2204
2260
  const { elementType, element } = useElement();
2205
2261
  const settingsDefault = useDefaultPanelSettings();
2206
2262
  const isDefaultExpanded = (sectionId) => settingsDefault.defaultSectionsExpanded.settings?.includes(sectionId);
2207
- return /* @__PURE__ */ React23.createElement(import_session4.SessionStorageProvider, { prefix: element.id }, /* @__PURE__ */ React23.createElement(SectionsList, null, elementType.controls.map(({ type, value }, index) => {
2263
+ return /* @__PURE__ */ React23.createElement(import_session5.SessionStorageProvider, { prefix: element.id }, /* @__PURE__ */ React23.createElement(SectionsList, null, elementType.controls.map(({ type, value }, index) => {
2208
2264
  if (type === "control") {
2209
2265
  return /* @__PURE__ */ React23.createElement(Control2, { key: value.bind, control: value });
2210
2266
  }
@@ -2260,7 +2316,7 @@ var import_react37 = require("react");
2260
2316
  var import_editor_props15 = require("@elementor/editor-props");
2261
2317
  var import_editor_responsive3 = require("@elementor/editor-responsive");
2262
2318
  var import_locations3 = require("@elementor/locations");
2263
- var import_session6 = require("@elementor/session");
2319
+ var import_session7 = require("@elementor/session");
2264
2320
  var import_ui43 = require("@elementor/ui");
2265
2321
  var import_i18n60 = require("@wordpress/i18n");
2266
2322
 
@@ -2986,7 +3042,7 @@ var ConditionalField = ({ children }) => {
2986
3042
  const { propType } = (0, import_editor_controls7.useBoundProp)();
2987
3043
  const depList = getDependencies(propType);
2988
3044
  const { values: depValues } = useStylesFields(depList);
2989
- const isHidden = !(0, import_editor_props11.isDependencyMet)(propType?.dependencies, depValues);
3045
+ const isHidden = !(0, import_editor_props11.isDependencyMet)(propType?.dependencies, depValues).isMet;
2990
3046
  return isHidden ? null : children;
2991
3047
  };
2992
3048
  function getDependencies(propType) {
@@ -4110,7 +4166,7 @@ var shouldDisplayFlexFields = (display, local) => {
4110
4166
 
4111
4167
  // src/components/style-sections/position-section/position-section.tsx
4112
4168
  var React63 = __toESM(require("react"));
4113
- var import_session5 = require("@elementor/session");
4169
+ var import_session6 = require("@elementor/session");
4114
4170
  var import_i18n39 = require("@wordpress/i18n");
4115
4171
 
4116
4172
  // src/components/style-sections/position-section/dimensions-field.tsx
@@ -4243,7 +4299,7 @@ var usePersistDimensions = () => {
4243
4299
  const { id: styleDefID, meta } = useStyle();
4244
4300
  const styleVariantPath = `styles/${styleDefID}/${meta.breakpoint || "desktop"}/${meta.state || "null"}`;
4245
4301
  const dimensionsPath = `${styleVariantPath}/dimensions`;
4246
- return (0, import_session5.useSessionStorage)(dimensionsPath);
4302
+ return (0, import_session6.useSessionStorage)(dimensionsPath);
4247
4303
  };
4248
4304
 
4249
4305
  // src/components/style-sections/size-section/size-section.tsx
@@ -4830,7 +4886,7 @@ var StyleTab = () => {
4830
4886
  },
4831
4887
  setMetaState: setActiveStyleState
4832
4888
  },
4833
- /* @__PURE__ */ React88.createElement(import_session6.SessionStorageProvider, { prefix: activeStyleDefId ?? "" }, /* @__PURE__ */ React88.createElement(StyleInheritanceProvider, null, /* @__PURE__ */ React88.createElement(ClassesHeader, null, /* @__PURE__ */ React88.createElement(CssClassSelector, null), /* @__PURE__ */ React88.createElement(import_ui43.Divider, null)), /* @__PURE__ */ React88.createElement(SectionsList, null, /* @__PURE__ */ React88.createElement(
4889
+ /* @__PURE__ */ React88.createElement(import_session7.SessionStorageProvider, { prefix: activeStyleDefId ?? "" }, /* @__PURE__ */ React88.createElement(StyleInheritanceProvider, null, /* @__PURE__ */ React88.createElement(ClassesHeader, null, /* @__PURE__ */ React88.createElement(CssClassSelector, null), /* @__PURE__ */ React88.createElement(import_ui43.Divider, null)), /* @__PURE__ */ React88.createElement(SectionsList, null, /* @__PURE__ */ React88.createElement(
4834
4890
  StyleTabSection,
4835
4891
  {
4836
4892
  section: {
@@ -5012,7 +5068,7 @@ var EditingPanel = () => {
5012
5068
  return null;
5013
5069
  }
5014
5070
  const panelTitle = (0, import_i18n62.__)("Edit %s", "elementor").replace("%s", elementType.title);
5015
- return /* @__PURE__ */ React90.createElement(import_ui45.ErrorBoundary, { fallback: /* @__PURE__ */ React90.createElement(EditorPanelErrorFallback, null) }, /* @__PURE__ */ React90.createElement(import_session7.SessionStorageProvider, { prefix: "elementor" }, /* @__PURE__ */ React90.createElement(import_editor_ui6.ThemeProvider, null, /* @__PURE__ */ React90.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React90.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React90.createElement(import_editor_panels.PanelHeaderTitle, null, panelTitle), /* @__PURE__ */ React90.createElement(import_icons24.AtomIcon, { fontSize: "small", sx: { color: "text.tertiary" } })), /* @__PURE__ */ React90.createElement(import_editor_panels.PanelBody, null, /* @__PURE__ */ React90.createElement(import_editor_controls53.ControlActionsProvider, { items: menuItems }, /* @__PURE__ */ React90.createElement(import_editor_controls53.ControlReplacementsProvider, { replacements: controlReplacements }, /* @__PURE__ */ React90.createElement(ElementProvider, { element, elementType }, /* @__PURE__ */ React90.createElement(EditingPanelTabs, null)))))))));
5071
+ return /* @__PURE__ */ React90.createElement(import_ui45.ErrorBoundary, { fallback: /* @__PURE__ */ React90.createElement(EditorPanelErrorFallback, null) }, /* @__PURE__ */ React90.createElement(import_session8.SessionStorageProvider, { prefix: "elementor" }, /* @__PURE__ */ React90.createElement(import_editor_ui6.ThemeProvider, null, /* @__PURE__ */ React90.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React90.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React90.createElement(import_editor_panels.PanelHeaderTitle, null, panelTitle), /* @__PURE__ */ React90.createElement(import_icons24.AtomIcon, { fontSize: "small", sx: { color: "text.tertiary" } })), /* @__PURE__ */ React90.createElement(import_editor_panels.PanelBody, null, /* @__PURE__ */ React90.createElement(import_editor_controls53.ControlActionsProvider, { items: menuItems }, /* @__PURE__ */ React90.createElement(import_editor_controls53.ControlReplacementsProvider, { replacements: controlReplacements }, /* @__PURE__ */ React90.createElement(ElementProvider, { element, elementType }, /* @__PURE__ */ React90.createElement(EditingPanelTabs, null)))))))));
5016
5072
  };
5017
5073
 
5018
5074
  // src/panel.ts
@@ -5161,11 +5217,11 @@ var import_ui47 = require("@elementor/ui");
5161
5217
  var import_i18n64 = require("@wordpress/i18n");
5162
5218
 
5163
5219
  // src/hooks/use-persist-dynamic-value.ts
5164
- var import_session8 = require("@elementor/session");
5220
+ var import_session9 = require("@elementor/session");
5165
5221
  var usePersistDynamicValue = (propKey) => {
5166
5222
  const { element } = useElement();
5167
5223
  const prefixedKey = `dynamic/non-dynamic-values-history/${element.id}/${propKey}`;
5168
- return (0, import_session8.useSessionStorage)(prefixedKey);
5224
+ return (0, import_session9.useSessionStorage)(prefixedKey);
5169
5225
  };
5170
5226
 
5171
5227
  // src/dynamics/dynamic-control.tsx