@elementor/editor-editing-panel 4.0.0-609 → 4.0.0-621

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.mjs CHANGED
@@ -24,8 +24,8 @@ function useClassesProp() {
24
24
  import * as React2 from "react";
25
25
  import { createContext as createContext2, useContext as useContext2 } from "react";
26
26
  var Context2 = createContext2(null);
27
- function ElementProvider({ children, element, elementType }) {
28
- return /* @__PURE__ */ React2.createElement(Context2.Provider, { value: { element, elementType } }, children);
27
+ function ElementProvider({ children, element, elementType, settings }) {
28
+ return /* @__PURE__ */ React2.createElement(Context2.Provider, { value: { element, elementType, settings } }, children);
29
29
  }
30
30
  function useElement() {
31
31
  const context = useContext2(Context2);
@@ -34,6 +34,13 @@ function useElement() {
34
34
  }
35
35
  return context;
36
36
  }
37
+ function usePanelElementSetting(propKey) {
38
+ const context = useContext2(Context2);
39
+ if (!context) {
40
+ throw new Error("usePanelElementSetting must be used within a ElementProvider");
41
+ }
42
+ return context.settings[propKey] ?? null;
43
+ }
37
44
 
38
45
  // src/contexts/style-context.tsx
39
46
  import * as React3 from "react";
@@ -140,7 +147,6 @@ var onConvert = (opts) => {
140
147
  // src/components/css-classes/css-class-selector.tsx
141
148
  import * as React10 from "react";
142
149
  import { useRef, useState as useState4 } from "react";
143
- import { useElementSetting } from "@elementor/editor-elements";
144
150
  import {
145
151
  isElementsStylesProvider as isElementsStylesProvider4,
146
152
  stylesRepository as stylesRepository5,
@@ -1320,9 +1326,8 @@ function hasReachedLimit(provider) {
1320
1326
  return provider.actions.all().length >= provider.limit;
1321
1327
  }
1322
1328
  function useAppliedOptions(options12) {
1323
- const { element } = useElement();
1324
1329
  const currentClassesProp = useClassesProp();
1325
- const appliedIds = useElementSetting(element.id, currentClassesProp)?.value || [];
1330
+ const appliedIds = usePanelElementSetting(currentClassesProp)?.value ?? [];
1326
1331
  const appliedOptions = options12.filter((option) => option.value && appliedIds.includes(option.value));
1327
1332
  const hasElementsProviderStyleApplied = appliedOptions.some(
1328
1333
  (option) => option.provider && isElementsStylesProvider4(option.provider)
@@ -1712,7 +1717,7 @@ import {
1712
1717
  ControlReplacementsProvider,
1713
1718
  getControlReplacements
1714
1719
  } from "@elementor/editor-controls";
1715
- import { useSelectedElement as useSelectedElement2 } from "@elementor/editor-elements";
1720
+ import { useSelectedElementSettings } from "@elementor/editor-elements";
1716
1721
  import { Panel, PanelBody, PanelHeader, PanelHeaderTitle } from "@elementor/editor-panels";
1717
1722
  import { ThemeProvider as ThemeProvider3 } from "@elementor/editor-ui";
1718
1723
  import { AtomIcon } from "@elementor/icons";
@@ -1940,7 +1945,8 @@ import {
1940
1945
  TextAreaControl,
1941
1946
  TextControl,
1942
1947
  ToggleControl,
1943
- UrlControl
1948
+ UrlControl,
1949
+ VideoMediaControl
1944
1950
  } from "@elementor/editor-controls";
1945
1951
  import {
1946
1952
  booleanPropTypeUtil,
@@ -1955,7 +1961,8 @@ import {
1955
1961
  queryPropTypeUtil,
1956
1962
  sizePropTypeUtil,
1957
1963
  stringArrayPropTypeUtil,
1958
- stringPropTypeUtil as stringPropTypeUtil2
1964
+ stringPropTypeUtil as stringPropTypeUtil2,
1965
+ videoSrcPropTypeUtil
1959
1966
  } from "@elementor/editor-props";
1960
1967
  var controlTypes = {
1961
1968
  image: { component: ImageControl, layout: "custom", propTypeUtil: imagePropTypeUtil },
@@ -1975,6 +1982,7 @@ var controlTypes = {
1975
1982
  "html-tag": { component: HtmlTagControl, layout: "two-columns", propTypeUtil: stringPropTypeUtil2 },
1976
1983
  toggle: { component: ToggleControl, layout: "full", propTypeUtil: stringPropTypeUtil2 },
1977
1984
  "date-time": { component: DateTimeControl, layout: "full", propTypeUtil: DateTimePropTypeUtil },
1985
+ video: { component: VideoMediaControl, layout: "full", propTypeUtil: videoSrcPropTypeUtil },
1978
1986
  "inline-editing": { component: InlineEditingControl, layout: "full", propTypeUtil: htmlV3PropTypeUtil },
1979
1987
  email: { component: EmailFormActionControl, layout: "custom", propTypeUtil: emailPropTypeUtil }
1980
1988
  };
@@ -2061,12 +2069,7 @@ import * as React19 from "react";
2061
2069
  import { useMemo as useMemo7 } from "react";
2062
2070
  import { PropKeyProvider, PropProvider } from "@elementor/editor-controls";
2063
2071
  import { setDocumentModifiedStatus as setDocumentModifiedStatus2 } from "@elementor/editor-documents";
2064
- import {
2065
- getElementLabel as getElementLabel3,
2066
- getElementSettings,
2067
- updateElementSettings as updateElementSettings3,
2068
- useElementSettings
2069
- } from "@elementor/editor-elements";
2072
+ import { getElementLabel as getElementLabel3, getElementSettings, updateElementSettings as updateElementSettings3 } from "@elementor/editor-elements";
2070
2073
  import {
2071
2074
  isDependency,
2072
2075
  isDependencyMet as isDependencyMet2
@@ -2225,35 +2228,61 @@ var createTopLevelObjectType = ({ schema }) => {
2225
2228
 
2226
2229
  // src/controls-registry/settings-field.tsx
2227
2230
  var HISTORY_DEBOUNCE_WAIT2 = 800;
2231
+ var getElementSettigsWithDefaults = (propsSchema, elementSettings) => {
2232
+ const elementSettingsWithDefaults = { ...elementSettings };
2233
+ Object.keys(propsSchema).forEach((key) => {
2234
+ if (!(key in elementSettingsWithDefaults)) {
2235
+ if (propsSchema[key].default !== null) {
2236
+ elementSettingsWithDefaults[key] = propsSchema[key].default;
2237
+ }
2238
+ }
2239
+ });
2240
+ return elementSettingsWithDefaults;
2241
+ };
2242
+ var extractDependencyEffect = (bind, propsSchema, currentElementSettings) => {
2243
+ const elementSettingsForDepCheck = getElementSettigsWithDefaults(propsSchema, currentElementSettings);
2244
+ const propType = propsSchema[bind];
2245
+ const depCheck = isDependencyMet2(propType?.dependencies, elementSettingsForDepCheck);
2246
+ const isHidden = !depCheck.isMet && !isDependency(depCheck.failingDependencies[0]) && depCheck.failingDependencies[0]?.effect === "hide";
2247
+ return {
2248
+ isDisabled: (prop) => {
2249
+ const result = !isDependencyMet2(prop?.dependencies, elementSettingsForDepCheck).isMet;
2250
+ return result;
2251
+ },
2252
+ isHidden,
2253
+ settingsWithDefaults: elementSettingsForDepCheck
2254
+ };
2255
+ };
2228
2256
  var SettingsField = ({ bind, children, propDisplayName }) => {
2229
2257
  const {
2230
2258
  element: { id: elementId },
2231
- elementType: { propsSchema, dependenciesPerTargetMapping = {} }
2259
+ elementType: { propsSchema, dependenciesPerTargetMapping = {} },
2260
+ settings: currentElementSettings
2232
2261
  } = useElement();
2233
- const elementSettingValues = useElementSettings(elementId, Object.keys(propsSchema));
2234
- const value = { [bind]: elementSettingValues?.[bind] ?? null };
2262
+ const value = { [bind]: currentElementSettings?.[bind] ?? null };
2235
2263
  const propType = createTopLevelObjectType({ schema: propsSchema });
2236
2264
  const undoableUpdateElementProp = useUndoableUpdateElementProp({
2237
2265
  elementId,
2238
2266
  propDisplayName
2239
2267
  });
2268
+ const { isDisabled, isHidden, settingsWithDefaults } = extractDependencyEffect(
2269
+ bind,
2270
+ propsSchema,
2271
+ currentElementSettings
2272
+ );
2273
+ if (isHidden) {
2274
+ return null;
2275
+ }
2240
2276
  const setValue = (newValue, _ = {}, meta) => {
2241
2277
  const { withHistory = true } = meta ?? {};
2242
2278
  const dependents = extractOrderedDependencies(dependenciesPerTargetMapping);
2243
- const settings = getUpdatedValues(newValue, dependents, propsSchema, elementSettingValues, elementId);
2279
+ const settings = getUpdatedValues(newValue, dependents, propsSchema, settingsWithDefaults, elementId);
2244
2280
  if (withHistory) {
2245
2281
  undoableUpdateElementProp(settings);
2246
2282
  } else {
2247
2283
  updateElementSettings3({ id: elementId, props: settings, withHistory: false });
2248
2284
  }
2249
2285
  };
2250
- const isDisabled = (prop) => !isDependencyMet2(prop?.dependencies, elementSettingValues).isMet;
2251
- const propTypeToBind = propsSchema[bind];
2252
- const dependenciesResult = isDependencyMet2(propTypeToBind?.dependencies, elementSettingValues);
2253
- const shouldHide = !dependenciesResult.isMet && !isDependency(dependenciesResult.failingDependencies[0]) && dependenciesResult.failingDependencies[0]?.effect === "hide";
2254
- if (shouldHide) {
2255
- return null;
2256
- }
2257
2286
  return /* @__PURE__ */ React19.createElement(PropProvider, { propType, value, setValue, isDisabled }, /* @__PURE__ */ React19.createElement(PropKeyProvider, { bind }, children));
2258
2287
  };
2259
2288
  function useUndoableUpdateElementProp({
@@ -2405,7 +2434,7 @@ import { __ as __53 } from "@wordpress/i18n";
2405
2434
  // src/contexts/styles-inheritance-context.tsx
2406
2435
  import * as React23 from "react";
2407
2436
  import { createContext as createContext7, useContext as useContext7 } from "react";
2408
- import { getWidgetsCache, useElementSetting as useElementSetting2 } from "@elementor/editor-elements";
2437
+ import { getWidgetsCache } from "@elementor/editor-elements";
2409
2438
  import { classesPropTypeUtil as classesPropTypeUtil3 } from "@elementor/editor-props";
2410
2439
  import { getBreakpointsTree as getBreakpointsTree2 } from "@elementor/editor-responsive";
2411
2440
  import { getStylesSchema } from "@elementor/editor-styles";
@@ -2671,11 +2700,10 @@ function useStylesInheritanceChain(path) {
2671
2700
  return context.getInheritanceChain(snapshot, path, topLevelPropType);
2672
2701
  }
2673
2702
  var useAppliedStyles = () => {
2674
- const { element } = useElement();
2675
2703
  const currentClassesProp = useClassesProp();
2676
2704
  const baseStyles = useBaseStyles();
2677
2705
  useStylesRerender();
2678
- const classesProp = useElementSetting2(element.id, currentClassesProp);
2706
+ const classesProp = usePanelElementSetting(currentClassesProp);
2679
2707
  const appliedStyles = classesPropTypeUtil3.extract(classesProp) ?? [];
2680
2708
  return stylesRepository6.all().filter((style) => [...baseStyles, ...appliedStyles].includes(style.id));
2681
2709
  };
@@ -2687,13 +2715,13 @@ var useBaseStyles = () => {
2687
2715
  };
2688
2716
 
2689
2717
  // src/hooks/use-active-style-def-id.ts
2690
- import { getElementStyles, useElementSetting as useElementSetting3 } from "@elementor/editor-elements";
2718
+ import { getElementStyles } from "@elementor/editor-elements";
2691
2719
  function useActiveStyleDefId(classProp) {
2692
2720
  const [activeStyledDefId, setActiveStyledDefId] = useStateByElement(
2693
2721
  "active-style-id",
2694
2722
  null
2695
2723
  );
2696
- const appliedClassesIds = useAppliedClassesIds(classProp)?.value || [];
2724
+ const appliedClassesIds = usePanelElementSetting(classProp)?.value || [];
2697
2725
  const fallback = useFirstAppliedClass(appliedClassesIds);
2698
2726
  const activeAndAppliedClassId = useActiveAndAppliedClassId(activeStyledDefId, appliedClassesIds);
2699
2727
  return [activeAndAppliedClassId || fallback?.id || null, setActiveStyledDefId];
@@ -2703,10 +2731,6 @@ function useFirstAppliedClass(appliedClassesIds) {
2703
2731
  const stylesDefs = getElementStyles(element.id) ?? {};
2704
2732
  return Object.values(stylesDefs).find((styleDef) => appliedClassesIds.includes(styleDef.id));
2705
2733
  }
2706
- function useAppliedClassesIds(classProp) {
2707
- const { element } = useElement();
2708
- return useElementSetting3(element.id, classProp);
2709
- }
2710
2734
  function useActiveAndAppliedClassId(id, appliedClassesIds) {
2711
2735
  const isClassApplied = !!id && appliedClassesIds.includes(id);
2712
2736
  return isClassApplied ? id : null;
@@ -3003,9 +3027,18 @@ import {
3003
3027
  TransformRepeaterControl,
3004
3028
  TransitionRepeaterControl
3005
3029
  } from "@elementor/editor-controls";
3006
- import { useSelectedElement } from "@elementor/editor-elements";
3007
3030
  import { __ as __15 } from "@wordpress/i18n";
3008
3031
 
3032
+ // src/utils/can-element-have-children.ts
3033
+ import { getContainer } from "@elementor/editor-elements";
3034
+ var canElementHaveChildren = (elementId) => {
3035
+ const container = getContainer(elementId);
3036
+ if (!container) {
3037
+ return false;
3038
+ }
3039
+ return container.model.get("elType") !== "widget";
3040
+ };
3041
+
3009
3042
  // src/utils/get-recently-used-styles.ts
3010
3043
  import { createPropsResolver, styleTransformersRegistry } from "@elementor/editor-canvas";
3011
3044
  import { getElementStyles as getElementStyles2 } from "@elementor/editor-elements";
@@ -3084,9 +3117,10 @@ var TRANSFORM_LABEL = __15("Transform", "elementor");
3084
3117
  var BACKDROP_FILTER_LABEL = __15("Backdrop filters", "elementor");
3085
3118
  var TRANSITIONS_LABEL = __15("Transitions", "elementor");
3086
3119
  var EffectsSection = () => {
3087
- const { element } = useSelectedElement();
3120
+ const { element } = useElement();
3088
3121
  const { meta } = useStyle();
3089
- return /* @__PURE__ */ React37.createElement(SectionContent, { gap: 1 }, /* @__PURE__ */ React37.createElement(BlendModeField, null), /* @__PURE__ */ React37.createElement(PanelDivider, null), /* @__PURE__ */ React37.createElement(OpacityControlField, null), /* @__PURE__ */ React37.createElement(PanelDivider, null), /* @__PURE__ */ React37.createElement(StylesField, { bind: "box-shadow", propDisplayName: BOX_SHADOW_LABEL }, /* @__PURE__ */ React37.createElement(BoxShadowRepeaterControl, null)), /* @__PURE__ */ React37.createElement(PanelDivider, null), /* @__PURE__ */ React37.createElement(StylesField, { bind: "transform", propDisplayName: TRANSFORM_LABEL }, /* @__PURE__ */ React37.createElement(TransformRepeaterControl, null)), /* @__PURE__ */ React37.createElement(PanelDivider, null), /* @__PURE__ */ React37.createElement(StylesField, { bind: "transition", propDisplayName: TRANSITIONS_LABEL }, /* @__PURE__ */ React37.createElement(
3122
+ const canHaveChildren = canElementHaveChildren(element?.id ?? "");
3123
+ return /* @__PURE__ */ React37.createElement(SectionContent, { gap: 1 }, /* @__PURE__ */ React37.createElement(BlendModeField, null), /* @__PURE__ */ React37.createElement(PanelDivider, null), /* @__PURE__ */ React37.createElement(OpacityControlField, null), /* @__PURE__ */ React37.createElement(PanelDivider, null), /* @__PURE__ */ React37.createElement(StylesField, { bind: "box-shadow", propDisplayName: BOX_SHADOW_LABEL }, /* @__PURE__ */ React37.createElement(BoxShadowRepeaterControl, null)), /* @__PURE__ */ React37.createElement(PanelDivider, null), /* @__PURE__ */ React37.createElement(StylesField, { bind: "transform", propDisplayName: TRANSFORM_LABEL }, /* @__PURE__ */ React37.createElement(TransformRepeaterControl, { showChildrenPerspective: canHaveChildren })), /* @__PURE__ */ React37.createElement(PanelDivider, null), /* @__PURE__ */ React37.createElement(StylesField, { bind: "transition", propDisplayName: TRANSITIONS_LABEL }, /* @__PURE__ */ React37.createElement(
3090
3124
  TransitionRepeaterControl,
3091
3125
  {
3092
3126
  currentStyleState: meta.state,
@@ -4772,7 +4806,7 @@ var PanelTabContent = () => {
4772
4806
  var { Slot: PanelHeaderTopSlot, inject: injectIntoPanelHeaderTop } = createLocation4();
4773
4807
  var { useMenuItems } = controlActionsMenu;
4774
4808
  var EditingPanel = () => {
4775
- const { element, elementType } = useSelectedElement2();
4809
+ const { element, elementType, settings } = useSelectedElementSettings();
4776
4810
  const controlReplacements = getControlReplacements();
4777
4811
  const menuItems = useMenuItems().default;
4778
4812
  if (!element || !elementType) {
@@ -4784,7 +4818,7 @@ var EditingPanel = () => {
4784
4818
  if (ReplacementComponent) {
4785
4819
  panelContent = /* @__PURE__ */ React81.createElement(ReplacementComponent, null);
4786
4820
  }
4787
- return /* @__PURE__ */ React81.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React81.createElement(EditorPanelErrorFallback, null) }, /* @__PURE__ */ React81.createElement(SessionStorageProvider3, { prefix: "elementor" }, /* @__PURE__ */ React81.createElement(ThemeProvider3, null, /* @__PURE__ */ React81.createElement(ControlActionsProvider, { items: menuItems }, /* @__PURE__ */ React81.createElement(ControlReplacementsProvider, { replacements: controlReplacements }, /* @__PURE__ */ React81.createElement(ElementProvider, { element, elementType }, /* @__PURE__ */ React81.createElement(Panel, null, /* @__PURE__ */ React81.createElement(PanelHeaderTopSlot, null), panelContent)))))));
4821
+ return /* @__PURE__ */ React81.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React81.createElement(EditorPanelErrorFallback, null) }, /* @__PURE__ */ React81.createElement(SessionStorageProvider3, { prefix: "elementor" }, /* @__PURE__ */ React81.createElement(ThemeProvider3, null, /* @__PURE__ */ React81.createElement(ControlActionsProvider, { items: menuItems }, /* @__PURE__ */ React81.createElement(ControlReplacementsProvider, { replacements: controlReplacements }, /* @__PURE__ */ React81.createElement(ElementProvider, { element, elementType, settings }, /* @__PURE__ */ React81.createElement(Panel, null, /* @__PURE__ */ React81.createElement(PanelHeaderTopSlot, null), panelContent)))))));
4788
4822
  };
4789
4823
 
4790
4824
  // src/init.ts
@@ -4888,9 +4922,9 @@ import { Alert as Alert2, Chip as Chip4, Infotip, Stack as Stack14, Switch, Text
4888
4922
  import { __ as __58 } from "@wordpress/i18n";
4889
4923
 
4890
4924
  // src/controls-registry/element-controls/get-element-by-type.ts
4891
- import { getContainer } from "@elementor/editor-elements";
4925
+ import { getContainer as getContainer2 } from "@elementor/editor-elements";
4892
4926
  var getElementByType = (elementId, type) => {
4893
- const currentElement = getContainer(elementId);
4927
+ const currentElement = getContainer2(elementId);
4894
4928
  if (!currentElement) {
4895
4929
  return null;
4896
4930
  }
@@ -4905,7 +4939,7 @@ import { useBoundProp as useBoundProp4 } from "@elementor/editor-controls";
4905
4939
  import {
4906
4940
  createElements,
4907
4941
  duplicateElements,
4908
- getContainer as getContainer2,
4942
+ getContainer as getContainer3,
4909
4943
  moveElements,
4910
4944
  removeElements
4911
4945
  } from "@elementor/editor-elements";
@@ -4926,7 +4960,7 @@ var useActions = () => {
4926
4960
  });
4927
4961
  items3.forEach(({ item, index }) => {
4928
4962
  const tabId = item.id;
4929
- const tabContentAreaContainer = getContainer2(tabContentAreaId);
4963
+ const tabContentAreaContainer = getContainer3(tabContentAreaId);
4930
4964
  const tabContentId = tabContentAreaContainer?.children?.[index]?.id;
4931
4965
  if (!tabContentId) {
4932
4966
  throw new Error("Original content ID is required for duplication");
@@ -4954,10 +4988,10 @@ var useActions = () => {
4954
4988
  movedElementId,
4955
4989
  movedElementIndex
4956
4990
  }) => {
4957
- const tabContentContainer = getContainer2(tabContentAreaId);
4991
+ const tabContentContainer = getContainer3(tabContentAreaId);
4958
4992
  const tabContent = tabContentContainer?.children?.[movedElementIndex];
4959
- const movedElement = getContainer2(movedElementId);
4960
- const tabsMenu = getContainer2(tabsMenuId);
4993
+ const movedElement = getContainer3(movedElementId);
4994
+ const tabsMenu = getContainer3(tabsMenuId);
4961
4995
  if (!tabContent) {
4962
4996
  throw new Error("Content element is required");
4963
4997
  }
@@ -5007,7 +5041,7 @@ var useActions = () => {
5007
5041
  title: __57("Tabs", "elementor"),
5008
5042
  elementIds: items3.flatMap(({ item, index }) => {
5009
5043
  const tabId = item.id;
5010
- const tabContentContainer = getContainer2(tabContentAreaId);
5044
+ const tabContentContainer = getContainer3(tabContentAreaId);
5011
5045
  const tabContentId = tabContentContainer?.children?.[index]?.id;
5012
5046
  if (!tabContentId) {
5013
5047
  throw new Error("Content ID is required");
@@ -5031,8 +5065,8 @@ var useActions = () => {
5031
5065
  tabsMenuId,
5032
5066
  items: items3
5033
5067
  }) => {
5034
- const tabContentArea = getContainer2(tabContentAreaId);
5035
- const tabsMenu = getContainer2(tabsMenuId);
5068
+ const tabContentArea = getContainer3(tabContentAreaId);
5069
+ const tabsMenu = getContainer3(tabsMenuId);
5036
5070
  if (!tabContentArea || !tabsMenu) {
5037
5071
  throw new Error("Tab containers not found");
5038
5072
  }