@elementor/editor-editing-panel 1.4.0 → 1.4.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - a0ca1d8: fixed an issue where persisting dimensions values behaved unpredictably when switching breakpoints
8
+ - Updated dependencies [a0ca1d8]
9
+ - @elementor/editor-controls@0.3.1
10
+
3
11
  ## 1.4.0
4
12
 
5
13
  ### Minor Changes
@@ -315,7 +323,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
315
323
 
316
324
  ### Features
317
325
 
318
- - **edito-editing-panel:** add control internal state hook [EDS-359] ([#232](https://github.com/elementor/elementor-packages/issues/232)) ([c9cbced](https://github.com/elementor/elementor-packages/commit/c9cbced3d8136f8bb157a0ab3878076b08e521f5))
326
+ - **editor-editing-panel:** add control internal state hook [EDS-359] ([#232](https://github.com/elementor/elementor-packages/issues/232)) ([c9cbced](https://github.com/elementor/elementor-packages/commit/c9cbced3d8136f8bb157a0ab3878076b08e521f5))
319
327
 
320
328
  # [0.10.0](https://github.com/elementor/elementor-packages/compare/@elementor/editor-editing-panel@0.9.1...@elementor/editor-editing-panel@0.10.0) (2024-08-14)
321
329
 
package/dist/index.js CHANGED
@@ -46,8 +46,8 @@ var import_editor_panels3 = require("@elementor/editor-panels");
46
46
  var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
47
47
 
48
48
  // src/hooks/use-close-editor-panel.ts
49
- var import_react16 = require("react");
50
- var import_editor_elements8 = require("@elementor/editor-elements");
49
+ var import_react13 = require("react");
50
+ var import_editor_elements7 = require("@elementor/editor-elements");
51
51
  var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
52
52
 
53
53
  // src/panel.ts
@@ -56,7 +56,7 @@ var import_editor_panels2 = require("@elementor/editor-panels");
56
56
  // src/components/editing-panel.tsx
57
57
  var React60 = __toESM(require("react"));
58
58
  var import_editor_controls42 = require("@elementor/editor-controls");
59
- var import_editor_elements6 = require("@elementor/editor-elements");
59
+ var import_editor_elements5 = require("@elementor/editor-elements");
60
60
  var import_editor_panels = require("@elementor/editor-panels");
61
61
  var import_ui52 = require("@elementor/ui");
62
62
  var import_i18n40 = require("@wordpress/i18n");
@@ -131,7 +131,7 @@ function EditorPanelErrorFallback() {
131
131
 
132
132
  // src/components/editing-panel-tabs.tsx
133
133
  var React59 = __toESM(require("react"));
134
- var import_react15 = require("react");
134
+ var import_react12 = require("react");
135
135
  var import_ui51 = require("@elementor/ui");
136
136
  var import_i18n39 = require("@wordpress/i18n");
137
137
 
@@ -286,8 +286,8 @@ var Control2 = ({ control }) => {
286
286
 
287
287
  // src/components/style-tab.tsx
288
288
  var React58 = __toESM(require("react"));
289
- var import_react14 = require("react");
290
- var import_editor_elements5 = require("@elementor/editor-elements");
289
+ var import_react11 = require("react");
290
+ var import_editor_elements4 = require("@elementor/editor-elements");
291
291
  var import_editor_responsive = require("@elementor/editor-responsive");
292
292
  var import_ui50 = require("@elementor/ui");
293
293
  var import_i18n38 = require("@wordpress/i18n");
@@ -616,43 +616,43 @@ var import_ui12 = require("@elementor/ui");
616
616
  var React15 = __toESM(require("react"));
617
617
  var import_editor_controls5 = require("@elementor/editor-controls");
618
618
 
619
- // src/hooks/use-styles-field.ts
620
- var import_react7 = require("react");
619
+ // src/hooks/use-styles-fields.ts
621
620
  var import_editor_elements3 = require("@elementor/editor-elements");
622
621
  var import_i18n2 = require("@wordpress/i18n");
623
- var useStylesField = (propName) => {
622
+ function useStylesFields(propNames) {
624
623
  const { element } = useElement();
625
624
  const { id, meta } = useStyle();
626
625
  const classesProp = useClassesProp();
627
- const previousValue = (0, import_react7.useRef)(null);
628
- const onChangeCallbacks = (0, import_react7.useRef)(/* @__PURE__ */ new Set());
629
- const value = (0, import_editor_elements3.useElementStyleProp)({
626
+ const value = (0, import_editor_elements3.useElementStyleProps)({
630
627
  elementID: element.id,
631
628
  styleDefID: id,
632
629
  meta,
633
- propName
630
+ propNames
634
631
  });
635
- const setValue = (newValue) => {
632
+ const setValue = (newValues) => {
636
633
  (0, import_editor_elements3.updateStyle)({
637
634
  elementID: element.id,
638
635
  styleDefID: id,
639
- props: { [propName]: newValue },
636
+ props: newValues,
640
637
  meta,
641
638
  bind: classesProp,
642
639
  label: (0, import_i18n2.__)("local", "elementor")
643
640
  });
644
641
  };
645
- const registerChangeListener = (callback) => {
646
- onChangeCallbacks.current.add(callback);
647
- };
648
- (0, import_react7.useEffect)(() => {
649
- onChangeCallbacks.current.forEach((cb) => {
650
- cb(value, previousValue.current);
642
+ return [value, setValue];
643
+ }
644
+
645
+ // src/hooks/use-styles-field.ts
646
+ function useStylesField(propName) {
647
+ const [values, setValues] = useStylesFields([propName]);
648
+ const value = values?.[propName] ?? null;
649
+ const setValue = (newValue) => {
650
+ setValues({
651
+ [propName]: newValue
651
652
  });
652
- previousValue.current = value;
653
- }, [value]);
654
- return [value, setValue, registerChangeListener];
655
- };
653
+ };
654
+ return [value, setValue];
655
+ }
656
656
 
657
657
  // src/controls-registry/styles-field.tsx
658
658
  var StylesField = ({ bind, children }) => {
@@ -883,7 +883,7 @@ function useDirection() {
883
883
 
884
884
  // src/components/style-sections/layout-section/utils/rotated-icon.tsx
885
885
  var React26 = __toESM(require("react"));
886
- var import_react8 = require("react");
886
+ var import_react7 = require("react");
887
887
  var import_ui19 = require("@elementor/ui");
888
888
  var CLOCKWISE_ANGLES = {
889
889
  row: 0,
@@ -898,7 +898,7 @@ var COUNTER_CLOCKWISE_ANGLES = {
898
898
  "column-reverse": -270
899
899
  };
900
900
  var RotatedIcon = ({ icon: Icon, size, isClockwise = true, offset = 0 }) => {
901
- const rotate = (0, import_react8.useRef)(useGetTargetAngle(isClockwise, offset));
901
+ const rotate = (0, import_react7.useRef)(useGetTargetAngle(isClockwise, offset));
902
902
  rotate.current = useGetTargetAngle(isClockwise, offset, rotate);
903
903
  return /* @__PURE__ */ React26.createElement(Icon, { fontSize: size, sx: { transition: ".3s", rotate: `${rotate.current}deg` } });
904
904
  };
@@ -1061,7 +1061,7 @@ var FlexDirectionField = () => {
1061
1061
 
1062
1062
  // src/components/style-sections/layout-section/flex-order-field.tsx
1063
1063
  var React31 = __toESM(require("react"));
1064
- var import_react9 = require("react");
1064
+ var import_react8 = require("react");
1065
1065
  var import_editor_controls18 = require("@elementor/editor-controls");
1066
1066
  var import_icons9 = require("@elementor/icons");
1067
1067
  var import_ui24 = require("@elementor/ui");
@@ -1097,7 +1097,7 @@ var items = [
1097
1097
  ];
1098
1098
  var FlexOrderField = () => {
1099
1099
  const { isSiteRtl } = useDirection(), [order, setOrder] = useStylesField("order");
1100
- const [groupControlValue, setGroupControlValue] = (0, import_react9.useState)(getGroupControlValue(order?.value || null));
1100
+ const [groupControlValue, setGroupControlValue] = (0, import_react8.useState)(getGroupControlValue(order?.value || null));
1101
1101
  const handleToggleButtonChange = (group) => {
1102
1102
  setGroupControlValue(group);
1103
1103
  if (!group || group === CUSTOM) {
@@ -1315,108 +1315,43 @@ var FlexFields = () => /* @__PURE__ */ React36.createElement(React36.Fragment, n
1315
1315
 
1316
1316
  // src/components/style-sections/position-section/position-section.tsx
1317
1317
  var React40 = __toESM(require("react"));
1318
- var import_react12 = require("react");
1319
1318
  var import_ui33 = require("@elementor/ui");
1320
1319
 
1321
- // src/hooks/use-style-prop-history.ts
1322
- var import_react11 = require("react");
1323
- var import_editor_elements4 = require("@elementor/editor-elements");
1324
-
1325
- // src/hooks/use-prop-value-history.ts
1326
- var import_react10 = require("react");
1320
+ // src/hooks/use-session-storage.ts
1321
+ var import_react9 = require("react");
1327
1322
  var import_utils2 = require("@elementor/utils");
1328
- var PROPS_VALUES_HISTORY_PREFIX = "elementor/editor-editing-panel/prop-value-history";
1329
- var usePropValueHistory = () => {
1330
- const { element } = useElement();
1331
- const elementKey = `${PROPS_VALUES_HISTORY_PREFIX}/${element.id}`;
1332
- const getElementPropsHistory = (0, import_react10.useCallback)(() => {
1333
- return (0, import_utils2.getSessionStorageItem)(elementKey);
1334
- }, [elementKey]);
1335
- const getPropValue = (0, import_react10.useCallback)(
1336
- (propKey) => {
1337
- const elementPropValues = getElementPropsHistory();
1338
- return elementPropValues?.[propKey] ?? null;
1339
- },
1340
- [getElementPropsHistory]
1341
- );
1342
- const setPropValue = (0, import_react10.useCallback)(
1343
- (propKey, propValue) => {
1344
- const elementPropValues = getElementPropsHistory();
1345
- const updatedElementPropValues = { ...elementPropValues, [propKey]: propValue };
1346
- (0, import_utils2.setSessionStorageItem)(elementKey, updatedElementPropValues);
1347
- },
1348
- [getElementPropsHistory, elementKey]
1349
- );
1350
- const removeProp = (0, import_react10.useCallback)(
1351
- (propKey) => {
1352
- const elementPropValues = getElementPropsHistory();
1353
- const updatedElementPropValues = Object.fromEntries(
1354
- Object.entries(elementPropValues || {}).filter(([key]) => key !== propKey)
1355
- );
1356
- (0, import_utils2.setSessionStorageItem)(elementKey, updatedElementPropValues);
1357
- },
1358
- [getElementPropsHistory, elementKey]
1359
- );
1360
- return (0, import_react10.useMemo)(() => ({ getPropValue, setPropValue, removeProp }), [getPropValue, removeProp, setPropValue]);
1361
- };
1362
-
1363
- // src/hooks/use-style-prop-history.ts
1364
- var useStylePropsHistory = (props) => {
1365
- const { element } = useElement();
1366
- const { id: styleDefID, meta } = useStyle();
1367
- const { getPropValue, setPropValue, removeProp } = usePropValueHistory();
1368
- const styleDef = styleDefID ? (0, import_editor_elements4.getElementStyles)(element.id)?.[styleDefID] : null;
1369
- const styleVariant = styleDef ? (0, import_editor_elements4.getVariantByMeta)(styleDef, meta) : null;
1370
- const styleVariantPath = `${styleDefID}-${styleVariant?.meta.breakpoint}-${styleVariant?.meta.state}`;
1371
- const saveStylePropsHistory = (0, import_react11.useCallback)(() => {
1372
- props.forEach((propKey) => {
1373
- const propValue = styleVariant?.props[propKey];
1374
- if (propValue) {
1375
- const propPath = `${styleVariantPath}-${propKey}`;
1376
- setPropValue(propPath, propValue);
1377
- }
1323
+ var useSessionStorage = (key) => {
1324
+ const prefixedKey = `elementor/${key}`;
1325
+ const [value, setValue] = (0, import_react9.useState)();
1326
+ (0, import_react9.useEffect)(() => {
1327
+ return subscribeToSessionStorage(prefixedKey, (newValue) => {
1328
+ setValue(newValue ?? null);
1378
1329
  });
1379
- }, [props, setPropValue, styleVariant?.props, styleVariantPath]);
1380
- const updateStylePropsFromHistory = (0, import_react11.useCallback)(() => {
1381
- const propValuesFromHistory = props.reduce((allProps, currentPropKey) => {
1382
- const propPath = `${styleVariantPath}-${currentPropKey}`;
1383
- const propHistory = getPropValue(propPath);
1384
- if (propHistory) {
1385
- removeProp(propPath);
1386
- return { ...allProps, [currentPropKey]: propHistory };
1330
+ }, [prefixedKey]);
1331
+ const saveValue = (newValue) => {
1332
+ (0, import_utils2.setSessionStorageItem)(prefixedKey, newValue);
1333
+ };
1334
+ const removeValue = () => {
1335
+ (0, import_utils2.removeSessionStorageItem)(prefixedKey);
1336
+ };
1337
+ return [value, saveValue, removeValue];
1338
+ };
1339
+ var subscribeToSessionStorage = (key, subscriber) => {
1340
+ subscriber((0, import_utils2.getSessionStorageItem)(key));
1341
+ const abortController = new AbortController();
1342
+ window.addEventListener(
1343
+ "storage",
1344
+ (e) => {
1345
+ if (e.key !== key || e.storageArea !== sessionStorage) {
1346
+ return;
1387
1347
  }
1388
- return allProps;
1389
- }, {});
1390
- if (Object.keys(propValuesFromHistory).length) {
1391
- (0, import_editor_elements4.updateStyle)({
1392
- elementID: element.id,
1393
- styleDefID,
1394
- meta,
1395
- props: propValuesFromHistory,
1396
- bind: "classes"
1397
- });
1398
- }
1399
- }, [element.id, getPropValue, meta, props, removeProp, styleDefID, styleVariantPath]);
1400
- const clearCurrentStyleProps = (0, import_react11.useCallback)(() => {
1401
- const resetValues = props.reduce(
1402
- (allProps, currentPropKey) => ({
1403
- ...allProps,
1404
- [currentPropKey]: void 0
1405
- }),
1406
- {}
1407
- );
1408
- (0, import_editor_elements4.updateStyle)({
1409
- elementID: element.id,
1410
- styleDefID,
1411
- meta,
1412
- props: resetValues,
1413
- bind: "classes"
1414
- });
1415
- }, [element.id, meta, props, styleDefID]);
1416
- return (0, import_react11.useMemo)(
1417
- () => ({ saveStylePropsHistory, updateStylePropsFromHistory, clearCurrentStyleProps }),
1418
- [saveStylePropsHistory, updateStylePropsFromHistory, clearCurrentStyleProps]
1348
+ subscriber((0, import_utils2.getSessionStorageItem)(key));
1349
+ },
1350
+ { signal: abortController.signal }
1419
1351
  );
1352
+ return () => {
1353
+ abortController.abort();
1354
+ };
1420
1355
  };
1421
1356
 
1422
1357
  // src/components/style-sections/position-section/dimensions-field.tsx
@@ -1449,8 +1384,8 @@ var positionOptions = [
1449
1384
  { label: (0, import_i18n20.__)("Absolute", "elementor"), value: "absolute" },
1450
1385
  { label: (0, import_i18n20.__)("Fixed", "elementor"), value: "fixed" }
1451
1386
  ];
1452
- var PositionField = () => {
1453
- return /* @__PURE__ */ React38.createElement(StylesField, { bind: "position" }, /* @__PURE__ */ React38.createElement(import_ui31.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React38.createElement(import_ui31.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React38.createElement(import_editor_controls25.ControlLabel, null, (0, import_i18n20.__)("Position", "elementor"))), /* @__PURE__ */ React38.createElement(import_ui31.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React38.createElement(import_editor_controls25.SelectControl, { options: positionOptions }))));
1387
+ var PositionField = ({ onChange }) => {
1388
+ return /* @__PURE__ */ React38.createElement(StylesField, { bind: "position" }, /* @__PURE__ */ React38.createElement(import_ui31.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React38.createElement(import_ui31.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React38.createElement(import_editor_controls25.ControlLabel, null, (0, import_i18n20.__)("Position", "elementor"))), /* @__PURE__ */ React38.createElement(import_ui31.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React38.createElement(import_editor_controls25.SelectControl, { options: positionOptions, onChange }))));
1454
1389
  };
1455
1390
 
1456
1391
  // src/components/style-sections/position-section/z-index-field.tsx
@@ -1463,33 +1398,41 @@ var ZIndexField = () => {
1463
1398
  };
1464
1399
 
1465
1400
  // src/components/style-sections/position-section/position-section.tsx
1466
- var dimensionsPropKeys = ["top", "bottom", "left", "right"];
1467
1401
  var PositionSection = () => {
1468
1402
  const [positionValue] = useStylesField("position");
1469
- usePositionChangeHandler();
1470
- const isNotStatic = positionValue && positionValue?.value !== "static";
1471
- return /* @__PURE__ */ React40.createElement(import_ui33.Stack, { gap: 1.5 }, /* @__PURE__ */ React40.createElement(PositionField, null), isNotStatic ? /* @__PURE__ */ React40.createElement(React40.Fragment, null, /* @__PURE__ */ React40.createElement(DimensionsField, null), /* @__PURE__ */ React40.createElement(ZIndexField, null)) : null);
1472
- };
1473
- var usePositionChangeHandler = () => {
1474
- const dimensionsHistory = useStylePropsHistory(dimensionsPropKeys);
1475
- const onPositionChange = (0, import_react12.useCallback)(
1476
- (newPositionValue, previousPosition) => {
1477
- if (!dimensionsHistory) {
1478
- return;
1403
+ const [dimensionsValues, setDimensionsValues] = useStylesFields([
1404
+ "top",
1405
+ "bottom",
1406
+ "left",
1407
+ "right"
1408
+ ]);
1409
+ const [dimensionsValuesFromHistory, updateDimensionsHistory, clearDimensionsHistory] = usePersistDimensions();
1410
+ const onPositionChange = (newPosition, previousPosition) => {
1411
+ if (newPosition === "static") {
1412
+ if (dimensionsValues) {
1413
+ updateDimensionsHistory(dimensionsValues);
1414
+ setDimensionsValues({
1415
+ top: void 0,
1416
+ bottom: void 0,
1417
+ left: void 0,
1418
+ right: void 0
1419
+ });
1479
1420
  }
1480
- const { saveStylePropsHistory, updateStylePropsFromHistory, clearCurrentStyleProps } = dimensionsHistory;
1481
- if (newPositionValue === "static") {
1482
- saveStylePropsHistory();
1483
- clearCurrentStyleProps();
1484
- } else if (previousPosition === "static") {
1485
- updateStylePropsFromHistory();
1421
+ } else if (previousPosition === "static") {
1422
+ if (dimensionsValuesFromHistory) {
1423
+ setDimensionsValues(dimensionsValuesFromHistory);
1424
+ clearDimensionsHistory();
1486
1425
  }
1487
- previousPosition = newPositionValue;
1488
- },
1489
- [dimensionsHistory]
1490
- );
1491
- const [, , registerChangeListener] = useStylesField("position");
1492
- registerChangeListener?.(onPositionChange);
1426
+ }
1427
+ };
1428
+ const isNotStatic = positionValue && positionValue?.value !== "static";
1429
+ return /* @__PURE__ */ React40.createElement(import_ui33.Stack, { gap: 1.5 }, /* @__PURE__ */ React40.createElement(PositionField, { onChange: onPositionChange }), isNotStatic ? /* @__PURE__ */ React40.createElement(React40.Fragment, null, /* @__PURE__ */ React40.createElement(DimensionsField, null), /* @__PURE__ */ React40.createElement(ZIndexField, null)) : null);
1430
+ };
1431
+ var usePersistDimensions = () => {
1432
+ const { id: styleDefID, meta } = useStyle();
1433
+ const styleVariantPath = `styles/${styleDefID}/${meta.breakpoint || "desktop"}/${meta.state || "null"}`;
1434
+ const dimensionsPath = `${styleVariantPath}/dimensions`;
1435
+ return useSessionStorage(dimensionsPath);
1493
1436
  };
1494
1437
 
1495
1438
  // src/components/style-sections/size-section/size-section.tsx
@@ -1551,11 +1494,11 @@ var import_ui49 = require("@elementor/ui");
1551
1494
 
1552
1495
  // src/components/collapsible-content.tsx
1553
1496
  var React44 = __toESM(require("react"));
1554
- var import_react13 = require("react");
1497
+ var import_react10 = require("react");
1555
1498
  var import_ui37 = require("@elementor/ui");
1556
1499
  var import_i18n25 = require("@wordpress/i18n");
1557
1500
  var CollapsibleContent = ({ children, defaultOpen = false }) => {
1558
- const [open, setOpen] = (0, import_react13.useState)(defaultOpen);
1501
+ const [open, setOpen] = (0, import_react10.useState)(defaultOpen);
1559
1502
  const handleToggle = () => {
1560
1503
  setOpen((prevOpen) => !prevOpen);
1561
1504
  };
@@ -1880,14 +1823,14 @@ var StyleTab = () => {
1880
1823
  return /* @__PURE__ */ React58.createElement(ClassesPropProvider, { prop: currentClassesProp }, /* @__PURE__ */ React58.createElement(StyleProvider, { meta: { breakpoint, state: null }, id: activeStyleDefId, setId: setActiveStyleDefId }, /* @__PURE__ */ React58.createElement(CssClassSelector, null), /* @__PURE__ */ React58.createElement(import_ui50.Divider, null), /* @__PURE__ */ React58.createElement(SectionsList, null, /* @__PURE__ */ React58.createElement(Section, { title: (0, import_i18n38.__)("Layout", "elementor") }, /* @__PURE__ */ React58.createElement(LayoutSection, null)), /* @__PURE__ */ React58.createElement(Section, { title: (0, import_i18n38.__)("Spacing", "elementor") }, /* @__PURE__ */ React58.createElement(SpacingSection, null)), /* @__PURE__ */ React58.createElement(Section, { title: (0, import_i18n38.__)("Size", "elementor") }, /* @__PURE__ */ React58.createElement(SizeSection, null)), /* @__PURE__ */ React58.createElement(Section, { title: (0, import_i18n38.__)("Position", "elementor") }, /* @__PURE__ */ React58.createElement(PositionSection, null)), /* @__PURE__ */ React58.createElement(Section, { title: (0, import_i18n38.__)("Typography", "elementor") }, /* @__PURE__ */ React58.createElement(TypographySection, null)), /* @__PURE__ */ React58.createElement(Section, { title: (0, import_i18n38.__)("Background", "elementor") }, /* @__PURE__ */ React58.createElement(BackgroundSection, null)), /* @__PURE__ */ React58.createElement(Section, { title: (0, import_i18n38.__)("Border", "elementor") }, /* @__PURE__ */ React58.createElement(BorderSection, null)), /* @__PURE__ */ React58.createElement(Section, { title: (0, import_i18n38.__)("Effects", "elementor") }, /* @__PURE__ */ React58.createElement(EffectsSection, null)))));
1881
1824
  };
1882
1825
  function useActiveStyleDefId(currentClassesProp) {
1883
- const [activeStyledDefId, setActiveStyledDefId] = (0, import_react14.useState)(null);
1826
+ const [activeStyledDefId, setActiveStyledDefId] = (0, import_react11.useState)(null);
1884
1827
  const fallback = useFirstElementStyleDef(currentClassesProp);
1885
1828
  return [activeStyledDefId || fallback?.id || null, setActiveStyledDefId];
1886
1829
  }
1887
1830
  function useFirstElementStyleDef(currentClassesProp) {
1888
1831
  const { element } = useElement();
1889
- const classesIds = (0, import_editor_elements5.useElementSetting)(element.id, currentClassesProp)?.value || [];
1890
- const stylesDefs = (0, import_editor_elements5.useElementStyles)(element.id);
1832
+ const classesIds = (0, import_editor_elements4.useElementSetting)(element.id, currentClassesProp)?.value || [];
1833
+ const stylesDefs = (0, import_editor_elements4.useElementStyles)(element.id);
1891
1834
  return Object.values(stylesDefs).find((styleDef) => classesIds.includes(styleDef.id));
1892
1835
  }
1893
1836
  function useCurrentClassesProp() {
@@ -1908,14 +1851,14 @@ var EditingPanelTabs = () => {
1908
1851
  return (
1909
1852
  // When switching between elements, the local states should be reset. We are using key to rerender the tabs.
1910
1853
  // Reference: https://react.dev/learn/preserving-and-resetting-state#resetting-a-form-with-a-key
1911
- /* @__PURE__ */ React59.createElement(import_react15.Fragment, { key: element.id }, /* @__PURE__ */ React59.createElement(import_ui51.Stack, { direction: "column", sx: { width: "100%" } }, /* @__PURE__ */ React59.createElement(import_ui51.Tabs, { variant: "fullWidth", indicatorColor: "secondary", textColor: "inherit", ...getTabsProps() }, /* @__PURE__ */ React59.createElement(import_ui51.Tab, { label: (0, import_i18n39.__)("General", "elementor"), ...getTabProps("settings") }), /* @__PURE__ */ React59.createElement(import_ui51.Tab, { label: (0, import_i18n39.__)("Style", "elementor"), ...getTabProps("style") })), /* @__PURE__ */ React59.createElement(import_ui51.Divider, null), /* @__PURE__ */ React59.createElement(import_ui51.TabPanel, { ...getTabPanelProps("settings"), disablePadding: true }, /* @__PURE__ */ React59.createElement(SettingsTab, null)), /* @__PURE__ */ React59.createElement(import_ui51.TabPanel, { ...getTabPanelProps("style"), disablePadding: true }, /* @__PURE__ */ React59.createElement(StyleTab, null))))
1854
+ /* @__PURE__ */ React59.createElement(import_react12.Fragment, { key: element.id }, /* @__PURE__ */ React59.createElement(import_ui51.Stack, { direction: "column", sx: { width: "100%" } }, /* @__PURE__ */ React59.createElement(import_ui51.Tabs, { variant: "fullWidth", indicatorColor: "secondary", textColor: "inherit", ...getTabsProps() }, /* @__PURE__ */ React59.createElement(import_ui51.Tab, { label: (0, import_i18n39.__)("General", "elementor"), ...getTabProps("settings") }), /* @__PURE__ */ React59.createElement(import_ui51.Tab, { label: (0, import_i18n39.__)("Style", "elementor"), ...getTabProps("style") })), /* @__PURE__ */ React59.createElement(import_ui51.Divider, null), /* @__PURE__ */ React59.createElement(import_ui51.TabPanel, { ...getTabPanelProps("settings"), disablePadding: true }, /* @__PURE__ */ React59.createElement(SettingsTab, null)), /* @__PURE__ */ React59.createElement(import_ui51.TabPanel, { ...getTabPanelProps("style"), disablePadding: true }, /* @__PURE__ */ React59.createElement(StyleTab, null))))
1912
1855
  );
1913
1856
  };
1914
1857
 
1915
1858
  // src/components/editing-panel.tsx
1916
1859
  var { useMenuItems } = controlActionsMenu;
1917
1860
  var EditingPanel = () => {
1918
- const { element, elementType } = (0, import_editor_elements6.useSelectedElement)();
1861
+ const { element, elementType } = (0, import_editor_elements5.useSelectedElement)();
1919
1862
  const controlReplacement = getControlReplacement();
1920
1863
  const menuItems = useMenuItems().default;
1921
1864
  if (!element || !elementType) {
@@ -1932,10 +1875,10 @@ var { panel, usePanelActions, usePanelStatus } = (0, import_editor_panels2.__cre
1932
1875
  });
1933
1876
 
1934
1877
  // src/sync/is-atomic-widget-selected.ts
1935
- var import_editor_elements7 = require("@elementor/editor-elements");
1878
+ var import_editor_elements6 = require("@elementor/editor-elements");
1936
1879
  var isAtomicWidgetSelected = () => {
1937
- const selectedElements = (0, import_editor_elements7.getSelectedElements)();
1938
- const widgetCache = (0, import_editor_elements7.getWidgetsCache)();
1880
+ const selectedElements = (0, import_editor_elements6.getSelectedElements)();
1881
+ const widgetCache = (0, import_editor_elements6.getWidgetsCache)();
1939
1882
  if (selectedElements.length !== 1) {
1940
1883
  return false;
1941
1884
  }
@@ -1945,11 +1888,11 @@ var isAtomicWidgetSelected = () => {
1945
1888
  // src/hooks/use-close-editor-panel.ts
1946
1889
  var useCloseEditorPanel = () => {
1947
1890
  const { close } = usePanelActions();
1948
- return (0, import_react16.useEffect)(() => {
1891
+ return (0, import_react13.useEffect)(() => {
1949
1892
  return (0, import_editor_v1_adapters.__privateListenTo)((0, import_editor_v1_adapters.commandStartEvent)("document/elements/delete"), (e) => {
1950
- const selectedElement = (0, import_editor_elements8.getSelectedElements)()[0];
1893
+ const selectedElement = (0, import_editor_elements7.getSelectedElements)()[0];
1951
1894
  const { container: deletedContainer } = e?.args;
1952
- const isSelectedElementInDeletedContainer = deletedContainer && selectedElement && (0, import_editor_elements8.isElementInContainer)(selectedElement, deletedContainer);
1895
+ const isSelectedElementInDeletedContainer = deletedContainer && selectedElement && (0, import_editor_elements7.isElementInContainer)(selectedElement, deletedContainer);
1953
1896
  if (isSelectedElementInDeletedContainer && isAtomicWidgetSelected()) {
1954
1897
  close();
1955
1898
  }
@@ -1958,11 +1901,11 @@ var useCloseEditorPanel = () => {
1958
1901
  };
1959
1902
 
1960
1903
  // src/hooks/use-open-editor-panel.ts
1961
- var import_react17 = require("react");
1904
+ var import_react14 = require("react");
1962
1905
  var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
1963
1906
  var useOpenEditorPanel = () => {
1964
1907
  const { open } = usePanelActions();
1965
- (0, import_react17.useEffect)(() => {
1908
+ (0, import_react14.useEffect)(() => {
1966
1909
  return (0, import_editor_v1_adapters2.__privateListenTo)((0, import_editor_v1_adapters2.commandStartEvent)("panel/editor/open"), () => {
1967
1910
  if (isAtomicWidgetSelected()) {
1968
1911
  open();
@@ -1980,22 +1923,29 @@ var EditingPanelHooks = () => {
1980
1923
 
1981
1924
  // src/dynamics/components/dynamic-selection-control.tsx
1982
1925
  var React63 = __toESM(require("react"));
1983
- var import_react21 = require("react");
1926
+ var import_react18 = require("react");
1984
1927
  var import_editor_controls45 = require("@elementor/editor-controls");
1985
1928
  var import_icons20 = require("@elementor/icons");
1986
1929
  var import_ui54 = require("@elementor/ui");
1987
1930
  var import_i18n42 = require("@wordpress/i18n");
1988
1931
 
1932
+ // src/hooks/use-persist-dynamic-value.ts
1933
+ var usePersistDynamicValue = (propKey) => {
1934
+ const { element } = useElement();
1935
+ const prefixedKey = `dynamic/non-dynamic-values-history/${element.id}/${propKey}`;
1936
+ return useSessionStorage(prefixedKey);
1937
+ };
1938
+
1989
1939
  // src/dynamics/dynamic-control.tsx
1990
1940
  var React61 = __toESM(require("react"));
1991
1941
  var import_editor_controls43 = require("@elementor/editor-controls");
1992
1942
  var import_editor_props5 = require("@elementor/editor-props");
1993
1943
 
1994
1944
  // src/dynamics/hooks/use-dynamic-tag.ts
1995
- var import_react19 = require("react");
1945
+ var import_react16 = require("react");
1996
1946
 
1997
1947
  // src/dynamics/hooks/use-prop-dynamic-tags.ts
1998
- var import_react18 = require("react");
1948
+ var import_react15 = require("react");
1999
1949
 
2000
1950
  // src/dynamics/sync/get-elementor-config.ts
2001
1951
  var getElementorConfig2 = () => {
@@ -2047,7 +1997,7 @@ var usePropDynamicTags = (propName) => {
2047
1997
  const propDynamicType = getDynamicPropType(propType);
2048
1998
  categories = propDynamicType?.settings.categories || [];
2049
1999
  }
2050
- return (0, import_react18.useMemo)(() => getDynamicTagsByCategories(categories), [categories.join()]);
2000
+ return (0, import_react15.useMemo)(() => getDynamicTagsByCategories(categories), [categories.join()]);
2051
2001
  };
2052
2002
  var getDynamicTagsByCategories = (categories) => {
2053
2003
  const dynamicTags = getAtomicDynamicTags();
@@ -2063,7 +2013,7 @@ var getDynamicTagsByCategories = (categories) => {
2063
2013
  // src/dynamics/hooks/use-dynamic-tag.ts
2064
2014
  var useDynamicTag = (propName, tagName) => {
2065
2015
  const dynamicTags = usePropDynamicTags(propName);
2066
- return (0, import_react19.useMemo)(() => dynamicTags.find((tag) => tag.name === tagName) ?? null, [dynamicTags, tagName]);
2016
+ return (0, import_react16.useMemo)(() => dynamicTags.find((tag) => tag.name === tagName) ?? null, [dynamicTags, tagName]);
2067
2017
  };
2068
2018
 
2069
2019
  // src/dynamics/dynamic-control.tsx
@@ -2091,26 +2041,26 @@ var DynamicControl = ({ bind, children }) => {
2091
2041
 
2092
2042
  // src/dynamics/components/dynamic-selection.tsx
2093
2043
  var React62 = __toESM(require("react"));
2094
- var import_react20 = require("react");
2044
+ var import_react17 = require("react");
2095
2045
  var import_editor_controls44 = require("@elementor/editor-controls");
2096
2046
  var import_icons19 = require("@elementor/icons");
2097
2047
  var import_ui53 = require("@elementor/ui");
2098
2048
  var import_i18n41 = require("@wordpress/i18n");
2099
2049
  var SIZE3 = "tiny";
2100
2050
  var DynamicSelection = ({ onSelect }) => {
2101
- const [searchValue, setSearchValue] = (0, import_react20.useState)("");
2051
+ const [searchValue, setSearchValue] = (0, import_react17.useState)("");
2102
2052
  const { groups: dynamicGroups } = getAtomicDynamicTags() || {};
2103
2053
  const { value: anyValue } = (0, import_editor_controls44.useBoundProp)();
2104
- const { bind, value: dynamicvalue, setValue } = (0, import_editor_controls44.useBoundProp)(dynamicPropTypeUtil);
2105
- const { setPropValue: updatePropValueHistory } = usePropValueHistory();
2106
- const isCurrentValueDynamic = !!dynamicvalue;
2054
+ const { bind, value: dynamicValue, setValue } = (0, import_editor_controls44.useBoundProp)(dynamicPropTypeUtil);
2055
+ const [, updatePropValueHistory] = usePersistDynamicValue(bind);
2056
+ const isCurrentValueDynamic = !!dynamicValue;
2107
2057
  const options10 = useFilteredOptions(bind, searchValue);
2108
2058
  const handleSearch = (event) => {
2109
2059
  setSearchValue(event.target.value);
2110
2060
  };
2111
2061
  const handleSetDynamicTag = (value) => {
2112
2062
  if (!isCurrentValueDynamic) {
2113
- updatePropValueHistory(bind, anyValue);
2063
+ updatePropValueHistory(anyValue);
2114
2064
  }
2115
2065
  setValue({ name: value, settings: {} });
2116
2066
  onSelect?.();
@@ -2127,8 +2077,8 @@ var DynamicSelection = ({ onSelect }) => {
2127
2077
  startAdornment: /* @__PURE__ */ React62.createElement(import_ui53.InputAdornment, { position: "start" }, /* @__PURE__ */ React62.createElement(import_icons19.SearchIcon, { fontSize: SIZE3 }))
2128
2078
  }
2129
2079
  }
2130
- )), /* @__PURE__ */ React62.createElement(import_ui53.Divider, null), /* @__PURE__ */ React62.createElement(import_ui53.Box, { sx: { overflowY: "auto", height: 260, width: 220 } }, options10.length > 0 ? /* @__PURE__ */ React62.createElement(import_ui53.MenuList, { role: "listbox", tabIndex: 0 }, options10.map(([category, items3], index) => /* @__PURE__ */ React62.createElement(import_react20.Fragment, { key: index }, /* @__PURE__ */ React62.createElement(import_ui53.ListSubheader, { sx: { typography: "caption", color: "text.tertiary" } }, dynamicGroups?.[category]?.title || category), items3.map(({ value, label: tagLabel }) => {
2131
- const isSelected = isCurrentValueDynamic && value === dynamicvalue?.name;
2080
+ )), /* @__PURE__ */ React62.createElement(import_ui53.Divider, null), /* @__PURE__ */ React62.createElement(import_ui53.Box, { sx: { overflowY: "auto", height: 260, width: 220 } }, options10.length > 0 ? /* @__PURE__ */ React62.createElement(import_ui53.MenuList, { role: "listbox", tabIndex: 0 }, options10.map(([category, items3], index) => /* @__PURE__ */ React62.createElement(import_react17.Fragment, { key: index }, /* @__PURE__ */ React62.createElement(import_ui53.ListSubheader, { sx: { typography: "caption", color: "text.tertiary" } }, dynamicGroups?.[category]?.title || category), items3.map(({ value, label: tagLabel }) => {
2081
+ const isSelected = isCurrentValueDynamic && value === dynamicValue?.name;
2132
2082
  return /* @__PURE__ */ React62.createElement(
2133
2083
  import_ui53.MenuItem,
2134
2084
  {
@@ -2172,14 +2122,13 @@ var SIZE4 = "tiny";
2172
2122
  var DynamicSelectionControl = () => {
2173
2123
  const { setValue: setAnyValue } = (0, import_editor_controls45.useBoundProp)();
2174
2124
  const { bind, value } = (0, import_editor_controls45.useBoundProp)(dynamicPropTypeUtil);
2175
- const { getPropValue: getPropValueFromHistory } = usePropValueHistory();
2125
+ const [propValueFromHistory] = usePersistDynamicValue(bind);
2176
2126
  const { name: tagName = "" } = value;
2177
- const selectionPopoverId = (0, import_react21.useId)();
2127
+ const selectionPopoverId = (0, import_react18.useId)();
2178
2128
  const selectionPopoverState = (0, import_ui54.usePopupState)({ variant: "popover", popupId: selectionPopoverId });
2179
2129
  const dynamicTag = useDynamicTag(bind, tagName);
2180
2130
  const removeDynamicTag = () => {
2181
- const propValue = getPropValueFromHistory(bind);
2182
- setAnyValue(propValue ?? null);
2131
+ setAnyValue(propValueFromHistory ?? null);
2183
2132
  };
2184
2133
  if (!dynamicTag) {
2185
2134
  throw new Error(`Dynamic tag ${tagName} not found`);
@@ -2214,7 +2163,7 @@ var DynamicSelectionControl = () => {
2214
2163
  ));
2215
2164
  };
2216
2165
  var DynamicSettingsPopover = ({ dynamicTag }) => {
2217
- const popupId = (0, import_react21.useId)();
2166
+ const popupId = (0, import_react18.useId)();
2218
2167
  const settingsPopupState = (0, import_ui54.usePopupState)({ variant: "popover", popupId });
2219
2168
  const hasDynamicSettings = !!dynamicTag.atomic_controls.length;
2220
2169
  if (!hasDynamicSettings) {