@elementor/editor-editing-panel 4.1.0-826 → 4.1.0-828

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
@@ -1817,7 +1817,7 @@ function EditorPanelErrorFallback() {
1817
1817
  }
1818
1818
 
1819
1819
  // src/components/editing-panel-tabs.tsx
1820
- import { Fragment as Fragment10 } from "react";
1820
+ import { Fragment as Fragment9 } from "react";
1821
1821
  import * as React86 from "react";
1822
1822
  import { getWidgetsCache as getWidgetsCache2 } from "@elementor/editor-elements";
1823
1823
  import { isExperimentActive as isExperimentActive3 } from "@elementor/editor-v1-adapters";
@@ -2923,7 +2923,7 @@ function useSyncDepsWithInherited({
2923
2923
  const syncRef = useRef4({ hasSynced: false, prevDepValues: depValues });
2924
2924
  useEffect4(() => {
2925
2925
  const { hasSynced, prevDepValues } = syncRef.current;
2926
- if (hasSynced && value && wasDepsCleared(prevDepValues, depValues)) {
2926
+ if (hasSynced && value && wasDepsCleared(prevDepValues, depValues) || isHidden && depValues && value) {
2927
2927
  resetValue();
2928
2928
  }
2929
2929
  if (isHidden || !value || !depValues) {
@@ -3036,7 +3036,13 @@ var StylesField = ({ bind, propDisplayName, children }) => {
3036
3036
  // src/components/section-content.tsx
3037
3037
  import * as React26 from "react";
3038
3038
  import { Stack as Stack6 } from "@elementor/ui";
3039
- var SectionContent = ({ gap = 2, sx, children, "aria-label": ariaLabel }) => /* @__PURE__ */ React26.createElement(Stack6, { gap, sx: { ...sx }, "aria-label": ariaLabel }, children);
3039
+ var SectionContent = ({
3040
+ gap = 2,
3041
+ sx,
3042
+ children,
3043
+ "aria-label": ariaLabel,
3044
+ className
3045
+ }) => /* @__PURE__ */ React26.createElement(Stack6, { gap, sx: { ...sx }, "aria-label": ariaLabel, className }, children);
3040
3046
 
3041
3047
  // src/components/style-sections/background-section/background-section.tsx
3042
3048
  var BACKGROUND_LABEL = __9("Background", "elementor");
@@ -4399,8 +4405,9 @@ var shouldDisplayFlexFields = (display, local) => {
4399
4405
 
4400
4406
  // src/components/style-sections/position-section/position-section.tsx
4401
4407
  import * as React60 from "react";
4402
- import { useCallback as useCallback2, useEffect as useEffect7, useRef as useRef11 } from "react";
4408
+ import { useEffect as useEffect7, useRef as useRef11 } from "react";
4403
4409
  import { useSessionStorage as useSessionStorage4 } from "@elementor/session";
4410
+ import { styled as styled6 } from "@elementor/ui";
4404
4411
  import { __ as __38 } from "@wordpress/i18n";
4405
4412
 
4406
4413
  // src/components/style-sections/position-section/dimensions-field.tsx
@@ -4477,8 +4484,8 @@ var positionOptions = [
4477
4484
  { label: __36("Fixed", "elementor"), value: "fixed" },
4478
4485
  { label: __36("Sticky", "elementor"), value: "sticky" }
4479
4486
  ];
4480
- var PositionField = ({ onChange }) => {
4481
- return /* @__PURE__ */ React58.createElement(StylesField, { bind: "position", propDisplayName: POSITION_LABEL }, /* @__PURE__ */ React58.createElement(StylesFieldLayout, { label: POSITION_LABEL }, /* @__PURE__ */ React58.createElement(SelectControl3, { options: positionOptions, onChange })));
4487
+ var PositionField = () => {
4488
+ return /* @__PURE__ */ React58.createElement(StylesField, { bind: "position", propDisplayName: POSITION_LABEL }, /* @__PURE__ */ React58.createElement(StylesFieldLayout, { label: POSITION_LABEL }, /* @__PURE__ */ React58.createElement(SelectControl3, { options: positionOptions })));
4482
4489
  };
4483
4490
 
4484
4491
  // src/components/style-sections/position-section/z-index-field.tsx
@@ -4510,63 +4517,32 @@ var ZIndexField = ({ disabled }) => {
4510
4517
  var POSITION_STATIC = "static";
4511
4518
  var POSITION_LABEL2 = __38("Position", "elementor");
4512
4519
  var DIMENSIONS_LABEL = __38("Dimensions", "elementor");
4513
- var POSITION_DEPENDENT_PROP_NAMES = [
4520
+ var DEPENDENT_PROP_NAMES = [
4514
4521
  "inset-block-start",
4515
4522
  "inset-block-end",
4516
4523
  "inset-inline-start",
4517
4524
  "inset-inline-end",
4518
4525
  "z-index"
4519
4526
  ];
4520
- var CLEARED_POSITION_DEPENDENT_VALUES = {
4521
- "inset-block-start": null,
4522
- "inset-block-end": null,
4523
- "inset-inline-start": null,
4524
- "inset-inline-end": null,
4525
- "z-index": null
4526
- };
4527
4527
  var PositionSection = () => {
4528
- const { value: positionValue } = useStylesField("position", {
4529
- history: { propDisplayName: POSITION_LABEL2 }
4530
- });
4531
- const { values: positionDependentValues, setValues: setPositionDependentValues } = useStylesFields([...POSITION_DEPENDENT_PROP_NAMES]);
4532
- const [dimensionsValuesFromHistory, updateDimensionsHistory, clearDimensionsHistory] = usePersistDimensions();
4533
- const clearPositionDependentProps = useCallback2(() => {
4534
- const dimensions = {
4535
- "inset-block-start": positionDependentValues?.["inset-block-start"],
4536
- "inset-block-end": positionDependentValues?.["inset-block-end"],
4537
- "inset-inline-start": positionDependentValues?.["inset-inline-start"],
4538
- "inset-inline-end": positionDependentValues?.["inset-inline-end"]
4539
- };
4540
- const meta = { history: { propDisplayName: DIMENSIONS_LABEL } };
4541
- const hasValuesToClear = Object.values(dimensions).some((v) => v !== null) || positionDependentValues?.["z-index"] !== null;
4542
- if (hasValuesToClear) {
4543
- updateDimensionsHistory(dimensions);
4544
- setPositionDependentValues(CLEARED_POSITION_DEPENDENT_VALUES, meta);
4545
- }
4546
- }, [positionDependentValues, updateDimensionsHistory, setPositionDependentValues]);
4547
- const clearPositionDependentPropsRef = useRef11(clearPositionDependentProps);
4548
- clearPositionDependentPropsRef.current = clearPositionDependentProps;
4528
+ const { value: position } = useStylesField("position", withHistoryLabel(POSITION_LABEL2));
4529
+ const positionPrevRef = useRef11(position);
4530
+ const { values: dependentValues, setValues: setDependentValues } = useStylesFields(DEPENDENT_PROP_NAMES);
4531
+ const [savedDependentValues, saveToHistory, clearHistory] = usePersistDimensions();
4549
4532
  useEffect7(() => {
4550
- if (positionValue?.value === POSITION_STATIC || positionValue === null) {
4551
- clearPositionDependentPropsRef.current();
4552
- }
4553
- }, [positionValue]);
4554
- const onPositionChange = (newPosition, previousPosition) => {
4555
- const meta = { history: { propDisplayName: DIMENSIONS_LABEL } };
4556
- if (newPosition === POSITION_STATIC) {
4557
- clearPositionDependentProps();
4558
- } else if (previousPosition === POSITION_STATIC) {
4559
- if (dimensionsValuesFromHistory) {
4560
- setPositionDependentValues(
4561
- { ...dimensionsValuesFromHistory, "z-index": void 0 },
4562
- meta
4563
- );
4564
- clearDimensionsHistory();
4565
- }
4533
+ if (position && position?.value === POSITION_STATIC && hasDependentValues(dependentValues)) {
4534
+ saveToHistory(extractDimensions(dependentValues));
4566
4535
  }
4567
- };
4568
- const isNotStatic = positionValue && positionValue?.value !== POSITION_STATIC;
4569
- return /* @__PURE__ */ React60.createElement(SectionContent, null, /* @__PURE__ */ React60.createElement(PositionField, { onChange: onPositionChange }), isNotStatic ? /* @__PURE__ */ React60.createElement(React60.Fragment, null, /* @__PURE__ */ React60.createElement(DimensionsField, null)) : null, /* @__PURE__ */ React60.createElement(ZIndexField, { disabled: !isNotStatic }), /* @__PURE__ */ React60.createElement(PanelDivider, null), /* @__PURE__ */ React60.createElement(OffsetField, null));
4536
+ if (positionPrevRef.current?.value === POSITION_STATIC) {
4537
+ setDependentValues({ ...savedDependentValues }, withHistoryLabel(DIMENSIONS_LABEL));
4538
+ clearHistory();
4539
+ }
4540
+ if ((!position || position?.value === POSITION_STATIC) && dependentValues?.["z-index"]) {
4541
+ setDependentValues({ "z-index": null }, withHistoryLabel(DIMENSIONS_LABEL));
4542
+ }
4543
+ positionPrevRef.current = position;
4544
+ }, [position?.value]);
4545
+ return /* @__PURE__ */ React60.createElement(StyledSectionContent, null, /* @__PURE__ */ React60.createElement(PositionField, null), /* @__PURE__ */ React60.createElement(DimensionsField, null), /* @__PURE__ */ React60.createElement(ZIndexField, { disabled: !position || position?.value === POSITION_STATIC }), /* @__PURE__ */ React60.createElement(PanelDivider, null), /* @__PURE__ */ React60.createElement(OffsetField, null));
4570
4546
  };
4571
4547
  var usePersistDimensions = () => {
4572
4548
  const { id: styleDefID, meta } = useStyle();
@@ -4574,6 +4550,46 @@ var usePersistDimensions = () => {
4574
4550
  const dimensionsPath = `${styleVariantPath}/dimensions`;
4575
4551
  return useSessionStorage4(dimensionsPath);
4576
4552
  };
4553
+ var withHistoryLabel = (name) => {
4554
+ return {
4555
+ history: { propDisplayName: name }
4556
+ };
4557
+ };
4558
+ var hasDependentValues = (values) => {
4559
+ if (!values) {
4560
+ return false;
4561
+ }
4562
+ const dimensions = extractDimensions(values);
4563
+ return Object.values(dimensions).some((v) => v !== null);
4564
+ };
4565
+ var extractDimensions = (values) => {
4566
+ return DEPENDENT_PROP_NAMES.reduce((acc, key) => {
4567
+ return {
4568
+ ...acc,
4569
+ [key]: values?.[key] ?? null
4570
+ };
4571
+ }, {});
4572
+ };
4573
+ var StyledSectionContent = styled6(SectionContent, {
4574
+ shouldForwardProp: (prop) => prop !== "gap"
4575
+ })(({ gap = 2, theme }) => ({
4576
+ gap: 0,
4577
+ "& > *": {
4578
+ marginBottom: theme.spacing(gap)
4579
+ },
4580
+ "& > *:last-child": {
4581
+ marginBottom: 0
4582
+ },
4583
+ "& > .MuiStack-root": {
4584
+ marginBottom: 0
4585
+ },
4586
+ "& > .MuiStack-root:has(> *)": {
4587
+ marginBottom: theme.spacing(gap)
4588
+ },
4589
+ "& > .MuiDivider-root": {
4590
+ marginBottom: theme.spacing(gap)
4591
+ }
4592
+ }));
4577
4593
 
4578
4594
  // src/components/style-sections/size-section/size-section.tsx
4579
4595
  import * as React65 from "react";
@@ -5338,7 +5354,7 @@ var EditingPanelTabs = () => {
5338
5354
  return (
5339
5355
  // When switching between elements, the local states should be reset. We are using key to rerender the tabs.
5340
5356
  // Reference: https://react.dev/learn/preserving-and-resetting-state#resetting-a-form-with-a-key
5341
- /* @__PURE__ */ React86.createElement(Fragment10, { key: element.id }, /* @__PURE__ */ React86.createElement(PanelTabContent, null))
5357
+ /* @__PURE__ */ React86.createElement(Fragment9, { key: element.id }, /* @__PURE__ */ React86.createElement(PanelTabContent, null))
5342
5358
  );
5343
5359
  };
5344
5360
  var PanelTabContent = () => {
@@ -6155,7 +6171,7 @@ var DynamicControl = ({ bind, children }) => {
6155
6171
 
6156
6172
  // src/dynamics/components/dynamic-selection.tsx
6157
6173
  import * as React93 from "react";
6158
- import { Fragment as Fragment15, useEffect as useEffect9, useState as useState10 } from "react";
6174
+ import { Fragment as Fragment14, useEffect as useEffect9, useState as useState10 } from "react";
6159
6175
  import { trackUpgradePromotionClick, trackViewPromotion, useBoundProp as useBoundProp9 } from "@elementor/editor-controls";
6160
6176
  import { CtaButton, PopoverHeader, PopoverMenuList, SearchField, SectionPopoverBody } from "@elementor/editor-ui";
6161
6177
  import { DatabaseIcon as DatabaseIcon2 } from "@elementor/icons";
@@ -6212,7 +6228,7 @@ var DynamicSelection = ({ close: closePopover, expired = false }) => {
6212
6228
  if (expired) {
6213
6229
  return /* @__PURE__ */ React93.createElement(ExpiredDynamicTags, null);
6214
6230
  }
6215
- return /* @__PURE__ */ React93.createElement(Fragment15, null, /* @__PURE__ */ React93.createElement(
6231
+ return /* @__PURE__ */ React93.createElement(Fragment14, null, /* @__PURE__ */ React93.createElement(
6216
6232
  SearchField,
6217
6233
  {
6218
6234
  value: searchValue,
@@ -7119,12 +7135,12 @@ var arrayTransformer = createTransformer2((values) => {
7119
7135
  // src/styles-inheritance/transformers/background-color-overlay-transformer.tsx
7120
7136
  import * as React103 from "react";
7121
7137
  import { createTransformer as createTransformer3 } from "@elementor/editor-canvas";
7122
- import { Stack as Stack18, styled as styled6, UnstableColorIndicator } from "@elementor/ui";
7138
+ import { Stack as Stack18, styled as styled7, UnstableColorIndicator } from "@elementor/ui";
7123
7139
  var backgroundColorOverlayTransformer = createTransformer3((value) => /* @__PURE__ */ React103.createElement(Stack18, { direction: "row", gap: 1, alignItems: "center" }, /* @__PURE__ */ React103.createElement(ItemLabelColor, { value })));
7124
7140
  var ItemLabelColor = ({ value: { color } }) => {
7125
7141
  return /* @__PURE__ */ React103.createElement("span", null, color);
7126
7142
  };
7127
- var StyledUnstableColorIndicator = styled6(UnstableColorIndicator)(({ theme }) => ({
7143
+ var StyledUnstableColorIndicator = styled7(UnstableColorIndicator)(({ theme }) => ({
7128
7144
  width: "1em",
7129
7145
  height: "1em",
7130
7146
  borderRadius: `${theme.shape.borderRadius / 2}px`,
@@ -7222,14 +7238,14 @@ var boxShadowTransformer = createTransformer6((value) => {
7222
7238
  // src/styles-inheritance/transformers/color-transformer.tsx
7223
7239
  import * as React107 from "react";
7224
7240
  import { createTransformer as createTransformer7 } from "@elementor/editor-canvas";
7225
- import { Stack as Stack21, styled as styled7, UnstableColorIndicator as UnstableColorIndicator2 } from "@elementor/ui";
7241
+ import { Stack as Stack21, styled as styled8, UnstableColorIndicator as UnstableColorIndicator2 } from "@elementor/ui";
7226
7242
  function isValidCSSColor(value) {
7227
7243
  if (!value.trim()) {
7228
7244
  return false;
7229
7245
  }
7230
7246
  return CSS.supports("color", value.trim());
7231
7247
  }
7232
- var StyledColorIndicator = styled7(UnstableColorIndicator2)(({ theme }) => ({
7248
+ var StyledColorIndicator = styled8(UnstableColorIndicator2)(({ theme }) => ({
7233
7249
  width: "1em",
7234
7250
  height: "1em",
7235
7251
  borderRadius: `${theme.shape.borderRadius / 2}px`,