@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 +9 -1
- package/dist/index.js +132 -183
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -162
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/style-sections/position-section/position-field.tsx +6 -2
- package/src/components/style-sections/position-section/position-section.tsx +51 -30
- package/src/dynamics/components/dynamic-selection-control.tsx +3 -5
- package/src/dynamics/components/dynamic-selection.tsx +6 -6
- package/src/hooks/use-persist-dynamic-value.ts +11 -0
- package/src/hooks/use-session-storage.ts +46 -0
- package/src/hooks/use-styles-field.ts +8 -44
- package/src/hooks/use-styles-fields.ts +32 -0
- package/src/hooks/use-prop-value-history.ts +0 -45
- package/src/hooks/use-style-prop-history.ts +0 -75
package/dist/index.mjs
CHANGED
|
@@ -259,7 +259,7 @@ var Control2 = ({ control }) => {
|
|
|
259
259
|
|
|
260
260
|
// src/components/style-tab.tsx
|
|
261
261
|
import * as React58 from "react";
|
|
262
|
-
import { useState as
|
|
262
|
+
import { useState as useState7 } from "react";
|
|
263
263
|
import { useElementSetting as useElementSetting3, useElementStyles } from "@elementor/editor-elements";
|
|
264
264
|
import { useActiveBreakpoint } from "@elementor/editor-responsive";
|
|
265
265
|
import { Divider as Divider7 } from "@elementor/ui";
|
|
@@ -595,43 +595,43 @@ import { Stack as Stack4 } from "@elementor/ui";
|
|
|
595
595
|
import * as React15 from "react";
|
|
596
596
|
import { BoundPropProvider as BoundPropProvider2 } from "@elementor/editor-controls";
|
|
597
597
|
|
|
598
|
-
// src/hooks/use-styles-
|
|
599
|
-
import {
|
|
600
|
-
import { updateStyle, useElementStyleProp } from "@elementor/editor-elements";
|
|
598
|
+
// src/hooks/use-styles-fields.ts
|
|
599
|
+
import { updateStyle, useElementStyleProps } from "@elementor/editor-elements";
|
|
601
600
|
import { __ as __2 } from "@wordpress/i18n";
|
|
602
|
-
|
|
601
|
+
function useStylesFields(propNames) {
|
|
603
602
|
const { element } = useElement();
|
|
604
603
|
const { id, meta } = useStyle();
|
|
605
604
|
const classesProp = useClassesProp();
|
|
606
|
-
const
|
|
607
|
-
const onChangeCallbacks = useRef2(/* @__PURE__ */ new Set());
|
|
608
|
-
const value = useElementStyleProp({
|
|
605
|
+
const value = useElementStyleProps({
|
|
609
606
|
elementID: element.id,
|
|
610
607
|
styleDefID: id,
|
|
611
608
|
meta,
|
|
612
|
-
|
|
609
|
+
propNames
|
|
613
610
|
});
|
|
614
|
-
const setValue = (
|
|
611
|
+
const setValue = (newValues) => {
|
|
615
612
|
updateStyle({
|
|
616
613
|
elementID: element.id,
|
|
617
614
|
styleDefID: id,
|
|
618
|
-
props:
|
|
615
|
+
props: newValues,
|
|
619
616
|
meta,
|
|
620
617
|
bind: classesProp,
|
|
621
618
|
label: __2("local", "elementor")
|
|
622
619
|
});
|
|
623
620
|
};
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
621
|
+
return [value, setValue];
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// src/hooks/use-styles-field.ts
|
|
625
|
+
function useStylesField(propName) {
|
|
626
|
+
const [values, setValues] = useStylesFields([propName]);
|
|
627
|
+
const value = values?.[propName] ?? null;
|
|
628
|
+
const setValue = (newValue) => {
|
|
629
|
+
setValues({
|
|
630
|
+
[propName]: newValue
|
|
630
631
|
});
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
};
|
|
632
|
+
};
|
|
633
|
+
return [value, setValue];
|
|
634
|
+
}
|
|
635
635
|
|
|
636
636
|
// src/controls-registry/styles-field.tsx
|
|
637
637
|
var StylesField = ({ bind, children }) => {
|
|
@@ -873,7 +873,7 @@ function useDirection() {
|
|
|
873
873
|
|
|
874
874
|
// src/components/style-sections/layout-section/utils/rotated-icon.tsx
|
|
875
875
|
import * as React26 from "react";
|
|
876
|
-
import { useRef as
|
|
876
|
+
import { useRef as useRef2 } from "react";
|
|
877
877
|
import { useTheme as useTheme2 } from "@elementor/ui";
|
|
878
878
|
var CLOCKWISE_ANGLES = {
|
|
879
879
|
row: 0,
|
|
@@ -888,7 +888,7 @@ var COUNTER_CLOCKWISE_ANGLES = {
|
|
|
888
888
|
"column-reverse": -270
|
|
889
889
|
};
|
|
890
890
|
var RotatedIcon = ({ icon: Icon, size, isClockwise = true, offset = 0 }) => {
|
|
891
|
-
const rotate =
|
|
891
|
+
const rotate = useRef2(useGetTargetAngle(isClockwise, offset));
|
|
892
892
|
rotate.current = useGetTargetAngle(isClockwise, offset, rotate);
|
|
893
893
|
return /* @__PURE__ */ React26.createElement(Icon, { fontSize: size, sx: { transition: ".3s", rotate: `${rotate.current}deg` } });
|
|
894
894
|
};
|
|
@@ -1326,108 +1326,43 @@ var FlexFields = () => /* @__PURE__ */ React36.createElement(React36.Fragment, n
|
|
|
1326
1326
|
|
|
1327
1327
|
// src/components/style-sections/position-section/position-section.tsx
|
|
1328
1328
|
import * as React40 from "react";
|
|
1329
|
-
import { useCallback as useCallback3 } from "react";
|
|
1330
1329
|
import { Stack as Stack15 } from "@elementor/ui";
|
|
1331
1330
|
|
|
1332
|
-
// src/hooks/use-
|
|
1333
|
-
import {
|
|
1334
|
-
import {
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
const { element } = useElement();
|
|
1342
|
-
const elementKey = `${PROPS_VALUES_HISTORY_PREFIX}/${element.id}`;
|
|
1343
|
-
const getElementPropsHistory = useCallback(() => {
|
|
1344
|
-
return getSessionStorageItem(elementKey);
|
|
1345
|
-
}, [elementKey]);
|
|
1346
|
-
const getPropValue = useCallback(
|
|
1347
|
-
(propKey) => {
|
|
1348
|
-
const elementPropValues = getElementPropsHistory();
|
|
1349
|
-
return elementPropValues?.[propKey] ?? null;
|
|
1350
|
-
},
|
|
1351
|
-
[getElementPropsHistory]
|
|
1352
|
-
);
|
|
1353
|
-
const setPropValue = useCallback(
|
|
1354
|
-
(propKey, propValue) => {
|
|
1355
|
-
const elementPropValues = getElementPropsHistory();
|
|
1356
|
-
const updatedElementPropValues = { ...elementPropValues, [propKey]: propValue };
|
|
1357
|
-
setSessionStorageItem(elementKey, updatedElementPropValues);
|
|
1358
|
-
},
|
|
1359
|
-
[getElementPropsHistory, elementKey]
|
|
1360
|
-
);
|
|
1361
|
-
const removeProp = useCallback(
|
|
1362
|
-
(propKey) => {
|
|
1363
|
-
const elementPropValues = getElementPropsHistory();
|
|
1364
|
-
const updatedElementPropValues = Object.fromEntries(
|
|
1365
|
-
Object.entries(elementPropValues || {}).filter(([key]) => key !== propKey)
|
|
1366
|
-
);
|
|
1367
|
-
setSessionStorageItem(elementKey, updatedElementPropValues);
|
|
1368
|
-
},
|
|
1369
|
-
[getElementPropsHistory, elementKey]
|
|
1370
|
-
);
|
|
1371
|
-
return useMemo2(() => ({ getPropValue, setPropValue, removeProp }), [getPropValue, removeProp, setPropValue]);
|
|
1372
|
-
};
|
|
1373
|
-
|
|
1374
|
-
// src/hooks/use-style-prop-history.ts
|
|
1375
|
-
var useStylePropsHistory = (props) => {
|
|
1376
|
-
const { element } = useElement();
|
|
1377
|
-
const { id: styleDefID, meta } = useStyle();
|
|
1378
|
-
const { getPropValue, setPropValue, removeProp } = usePropValueHistory();
|
|
1379
|
-
const styleDef = styleDefID ? getElementStyles(element.id)?.[styleDefID] : null;
|
|
1380
|
-
const styleVariant = styleDef ? getVariantByMeta(styleDef, meta) : null;
|
|
1381
|
-
const styleVariantPath = `${styleDefID}-${styleVariant?.meta.breakpoint}-${styleVariant?.meta.state}`;
|
|
1382
|
-
const saveStylePropsHistory = useCallback2(() => {
|
|
1383
|
-
props.forEach((propKey) => {
|
|
1384
|
-
const propValue = styleVariant?.props[propKey];
|
|
1385
|
-
if (propValue) {
|
|
1386
|
-
const propPath = `${styleVariantPath}-${propKey}`;
|
|
1387
|
-
setPropValue(propPath, propValue);
|
|
1388
|
-
}
|
|
1331
|
+
// src/hooks/use-session-storage.ts
|
|
1332
|
+
import { useEffect as useEffect2, useState as useState5 } from "react";
|
|
1333
|
+
import { getSessionStorageItem, removeSessionStorageItem, setSessionStorageItem } from "@elementor/utils";
|
|
1334
|
+
var useSessionStorage = (key) => {
|
|
1335
|
+
const prefixedKey = `elementor/${key}`;
|
|
1336
|
+
const [value, setValue] = useState5();
|
|
1337
|
+
useEffect2(() => {
|
|
1338
|
+
return subscribeToSessionStorage(prefixedKey, (newValue) => {
|
|
1339
|
+
setValue(newValue ?? null);
|
|
1389
1340
|
});
|
|
1390
|
-
}, [
|
|
1391
|
-
const
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1341
|
+
}, [prefixedKey]);
|
|
1342
|
+
const saveValue = (newValue) => {
|
|
1343
|
+
setSessionStorageItem(prefixedKey, newValue);
|
|
1344
|
+
};
|
|
1345
|
+
const removeValue = () => {
|
|
1346
|
+
removeSessionStorageItem(prefixedKey);
|
|
1347
|
+
};
|
|
1348
|
+
return [value, saveValue, removeValue];
|
|
1349
|
+
};
|
|
1350
|
+
var subscribeToSessionStorage = (key, subscriber) => {
|
|
1351
|
+
subscriber(getSessionStorageItem(key));
|
|
1352
|
+
const abortController = new AbortController();
|
|
1353
|
+
window.addEventListener(
|
|
1354
|
+
"storage",
|
|
1355
|
+
(e) => {
|
|
1356
|
+
if (e.key !== key || e.storageArea !== sessionStorage) {
|
|
1357
|
+
return;
|
|
1398
1358
|
}
|
|
1399
|
-
|
|
1400
|
-
},
|
|
1401
|
-
|
|
1402
|
-
updateStyle2({
|
|
1403
|
-
elementID: element.id,
|
|
1404
|
-
styleDefID,
|
|
1405
|
-
meta,
|
|
1406
|
-
props: propValuesFromHistory,
|
|
1407
|
-
bind: "classes"
|
|
1408
|
-
});
|
|
1409
|
-
}
|
|
1410
|
-
}, [element.id, getPropValue, meta, props, removeProp, styleDefID, styleVariantPath]);
|
|
1411
|
-
const clearCurrentStyleProps = useCallback2(() => {
|
|
1412
|
-
const resetValues = props.reduce(
|
|
1413
|
-
(allProps, currentPropKey) => ({
|
|
1414
|
-
...allProps,
|
|
1415
|
-
[currentPropKey]: void 0
|
|
1416
|
-
}),
|
|
1417
|
-
{}
|
|
1418
|
-
);
|
|
1419
|
-
updateStyle2({
|
|
1420
|
-
elementID: element.id,
|
|
1421
|
-
styleDefID,
|
|
1422
|
-
meta,
|
|
1423
|
-
props: resetValues,
|
|
1424
|
-
bind: "classes"
|
|
1425
|
-
});
|
|
1426
|
-
}, [element.id, meta, props, styleDefID]);
|
|
1427
|
-
return useMemo3(
|
|
1428
|
-
() => ({ saveStylePropsHistory, updateStylePropsFromHistory, clearCurrentStyleProps }),
|
|
1429
|
-
[saveStylePropsHistory, updateStylePropsFromHistory, clearCurrentStyleProps]
|
|
1359
|
+
subscriber(getSessionStorageItem(key));
|
|
1360
|
+
},
|
|
1361
|
+
{ signal: abortController.signal }
|
|
1430
1362
|
);
|
|
1363
|
+
return () => {
|
|
1364
|
+
abortController.abort();
|
|
1365
|
+
};
|
|
1431
1366
|
};
|
|
1432
1367
|
|
|
1433
1368
|
// src/components/style-sections/position-section/dimensions-field.tsx
|
|
@@ -1460,8 +1395,8 @@ var positionOptions = [
|
|
|
1460
1395
|
{ label: __20("Absolute", "elementor"), value: "absolute" },
|
|
1461
1396
|
{ label: __20("Fixed", "elementor"), value: "fixed" }
|
|
1462
1397
|
];
|
|
1463
|
-
var PositionField = () => {
|
|
1464
|
-
return /* @__PURE__ */ React38.createElement(StylesField, { bind: "position" }, /* @__PURE__ */ React38.createElement(Grid11, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React38.createElement(Grid11, { item: true, xs: 6 }, /* @__PURE__ */ React38.createElement(ControlLabel16, null, __20("Position", "elementor"))), /* @__PURE__ */ React38.createElement(Grid11, { item: true, xs: 6 }, /* @__PURE__ */ React38.createElement(SelectControl3, { options: positionOptions }))));
|
|
1398
|
+
var PositionField = ({ onChange }) => {
|
|
1399
|
+
return /* @__PURE__ */ React38.createElement(StylesField, { bind: "position" }, /* @__PURE__ */ React38.createElement(Grid11, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React38.createElement(Grid11, { item: true, xs: 6 }, /* @__PURE__ */ React38.createElement(ControlLabel16, null, __20("Position", "elementor"))), /* @__PURE__ */ React38.createElement(Grid11, { item: true, xs: 6 }, /* @__PURE__ */ React38.createElement(SelectControl3, { options: positionOptions, onChange }))));
|
|
1465
1400
|
};
|
|
1466
1401
|
|
|
1467
1402
|
// src/components/style-sections/position-section/z-index-field.tsx
|
|
@@ -1474,33 +1409,41 @@ var ZIndexField = () => {
|
|
|
1474
1409
|
};
|
|
1475
1410
|
|
|
1476
1411
|
// src/components/style-sections/position-section/position-section.tsx
|
|
1477
|
-
var dimensionsPropKeys = ["top", "bottom", "left", "right"];
|
|
1478
1412
|
var PositionSection = () => {
|
|
1479
1413
|
const [positionValue] = useStylesField("position");
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
const
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1414
|
+
const [dimensionsValues, setDimensionsValues] = useStylesFields([
|
|
1415
|
+
"top",
|
|
1416
|
+
"bottom",
|
|
1417
|
+
"left",
|
|
1418
|
+
"right"
|
|
1419
|
+
]);
|
|
1420
|
+
const [dimensionsValuesFromHistory, updateDimensionsHistory, clearDimensionsHistory] = usePersistDimensions();
|
|
1421
|
+
const onPositionChange = (newPosition, previousPosition) => {
|
|
1422
|
+
if (newPosition === "static") {
|
|
1423
|
+
if (dimensionsValues) {
|
|
1424
|
+
updateDimensionsHistory(dimensionsValues);
|
|
1425
|
+
setDimensionsValues({
|
|
1426
|
+
top: void 0,
|
|
1427
|
+
bottom: void 0,
|
|
1428
|
+
left: void 0,
|
|
1429
|
+
right: void 0
|
|
1430
|
+
});
|
|
1490
1431
|
}
|
|
1491
|
-
|
|
1492
|
-
if (
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
} else if (previousPosition === "static") {
|
|
1496
|
-
updateStylePropsFromHistory();
|
|
1432
|
+
} else if (previousPosition === "static") {
|
|
1433
|
+
if (dimensionsValuesFromHistory) {
|
|
1434
|
+
setDimensionsValues(dimensionsValuesFromHistory);
|
|
1435
|
+
clearDimensionsHistory();
|
|
1497
1436
|
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
);
|
|
1502
|
-
|
|
1503
|
-
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
const isNotStatic = positionValue && positionValue?.value !== "static";
|
|
1440
|
+
return /* @__PURE__ */ React40.createElement(Stack15, { 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);
|
|
1441
|
+
};
|
|
1442
|
+
var usePersistDimensions = () => {
|
|
1443
|
+
const { id: styleDefID, meta } = useStyle();
|
|
1444
|
+
const styleVariantPath = `styles/${styleDefID}/${meta.breakpoint || "desktop"}/${meta.state || "null"}`;
|
|
1445
|
+
const dimensionsPath = `${styleVariantPath}/dimensions`;
|
|
1446
|
+
return useSessionStorage(dimensionsPath);
|
|
1504
1447
|
};
|
|
1505
1448
|
|
|
1506
1449
|
// src/components/style-sections/size-section/size-section.tsx
|
|
@@ -1562,11 +1505,11 @@ import { Divider as Divider6, Stack as Stack19 } from "@elementor/ui";
|
|
|
1562
1505
|
|
|
1563
1506
|
// src/components/collapsible-content.tsx
|
|
1564
1507
|
import * as React44 from "react";
|
|
1565
|
-
import { useState as
|
|
1508
|
+
import { useState as useState6 } from "react";
|
|
1566
1509
|
import { Button, Collapse as Collapse3, Stack as Stack18 } from "@elementor/ui";
|
|
1567
1510
|
import { __ as __25 } from "@wordpress/i18n";
|
|
1568
1511
|
var CollapsibleContent = ({ children, defaultOpen = false }) => {
|
|
1569
|
-
const [open, setOpen] =
|
|
1512
|
+
const [open, setOpen] = useState6(defaultOpen);
|
|
1570
1513
|
const handleToggle = () => {
|
|
1571
1514
|
setOpen((prevOpen) => !prevOpen);
|
|
1572
1515
|
};
|
|
@@ -1891,7 +1834,7 @@ var StyleTab = () => {
|
|
|
1891
1834
|
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(Divider7, null), /* @__PURE__ */ React58.createElement(SectionsList, null, /* @__PURE__ */ React58.createElement(Section, { title: __38("Layout", "elementor") }, /* @__PURE__ */ React58.createElement(LayoutSection, null)), /* @__PURE__ */ React58.createElement(Section, { title: __38("Spacing", "elementor") }, /* @__PURE__ */ React58.createElement(SpacingSection, null)), /* @__PURE__ */ React58.createElement(Section, { title: __38("Size", "elementor") }, /* @__PURE__ */ React58.createElement(SizeSection, null)), /* @__PURE__ */ React58.createElement(Section, { title: __38("Position", "elementor") }, /* @__PURE__ */ React58.createElement(PositionSection, null)), /* @__PURE__ */ React58.createElement(Section, { title: __38("Typography", "elementor") }, /* @__PURE__ */ React58.createElement(TypographySection, null)), /* @__PURE__ */ React58.createElement(Section, { title: __38("Background", "elementor") }, /* @__PURE__ */ React58.createElement(BackgroundSection, null)), /* @__PURE__ */ React58.createElement(Section, { title: __38("Border", "elementor") }, /* @__PURE__ */ React58.createElement(BorderSection, null)), /* @__PURE__ */ React58.createElement(Section, { title: __38("Effects", "elementor") }, /* @__PURE__ */ React58.createElement(EffectsSection, null)))));
|
|
1892
1835
|
};
|
|
1893
1836
|
function useActiveStyleDefId(currentClassesProp) {
|
|
1894
|
-
const [activeStyledDefId, setActiveStyledDefId] =
|
|
1837
|
+
const [activeStyledDefId, setActiveStyledDefId] = useState7(null);
|
|
1895
1838
|
const fallback = useFirstElementStyleDef(currentClassesProp);
|
|
1896
1839
|
return [activeStyledDefId || fallback?.id || null, setActiveStyledDefId];
|
|
1897
1840
|
}
|
|
@@ -2013,16 +1956,23 @@ import {
|
|
|
2013
1956
|
} from "@elementor/ui";
|
|
2014
1957
|
import { __ as __42 } from "@wordpress/i18n";
|
|
2015
1958
|
|
|
1959
|
+
// src/hooks/use-persist-dynamic-value.ts
|
|
1960
|
+
var usePersistDynamicValue = (propKey) => {
|
|
1961
|
+
const { element } = useElement();
|
|
1962
|
+
const prefixedKey = `dynamic/non-dynamic-values-history/${element.id}/${propKey}`;
|
|
1963
|
+
return useSessionStorage(prefixedKey);
|
|
1964
|
+
};
|
|
1965
|
+
|
|
2016
1966
|
// src/dynamics/dynamic-control.tsx
|
|
2017
1967
|
import * as React61 from "react";
|
|
2018
1968
|
import { BoundPropProvider as BoundPropProvider3, useBoundProp } from "@elementor/editor-controls";
|
|
2019
1969
|
import { isTransformable as isTransformable2 } from "@elementor/editor-props";
|
|
2020
1970
|
|
|
2021
1971
|
// src/dynamics/hooks/use-dynamic-tag.ts
|
|
2022
|
-
import { useMemo as
|
|
1972
|
+
import { useMemo as useMemo3 } from "react";
|
|
2023
1973
|
|
|
2024
1974
|
// src/dynamics/hooks/use-prop-dynamic-tags.ts
|
|
2025
|
-
import { useMemo as
|
|
1975
|
+
import { useMemo as useMemo2 } from "react";
|
|
2026
1976
|
|
|
2027
1977
|
// src/dynamics/sync/get-elementor-config.ts
|
|
2028
1978
|
var getElementorConfig2 = () => {
|
|
@@ -2077,7 +2027,7 @@ var usePropDynamicTags = (propName) => {
|
|
|
2077
2027
|
const propDynamicType = getDynamicPropType(propType);
|
|
2078
2028
|
categories = propDynamicType?.settings.categories || [];
|
|
2079
2029
|
}
|
|
2080
|
-
return
|
|
2030
|
+
return useMemo2(() => getDynamicTagsByCategories(categories), [categories.join()]);
|
|
2081
2031
|
};
|
|
2082
2032
|
var getDynamicTagsByCategories = (categories) => {
|
|
2083
2033
|
const dynamicTags = getAtomicDynamicTags();
|
|
@@ -2093,7 +2043,7 @@ var getDynamicTagsByCategories = (categories) => {
|
|
|
2093
2043
|
// src/dynamics/hooks/use-dynamic-tag.ts
|
|
2094
2044
|
var useDynamicTag = (propName, tagName) => {
|
|
2095
2045
|
const dynamicTags = usePropDynamicTags(propName);
|
|
2096
|
-
return
|
|
2046
|
+
return useMemo3(() => dynamicTags.find((tag) => tag.name === tagName) ?? null, [dynamicTags, tagName]);
|
|
2097
2047
|
};
|
|
2098
2048
|
|
|
2099
2049
|
// src/dynamics/dynamic-control.tsx
|
|
@@ -2121,7 +2071,7 @@ var DynamicControl = ({ bind, children }) => {
|
|
|
2121
2071
|
|
|
2122
2072
|
// src/dynamics/components/dynamic-selection.tsx
|
|
2123
2073
|
import * as React62 from "react";
|
|
2124
|
-
import { Fragment as Fragment8, useState as
|
|
2074
|
+
import { Fragment as Fragment8, useState as useState8 } from "react";
|
|
2125
2075
|
import { useBoundProp as useBoundProp2 } from "@elementor/editor-controls";
|
|
2126
2076
|
import { PhotoIcon, SearchIcon } from "@elementor/icons";
|
|
2127
2077
|
import {
|
|
@@ -2139,19 +2089,19 @@ import {
|
|
|
2139
2089
|
import { __ as __41 } from "@wordpress/i18n";
|
|
2140
2090
|
var SIZE3 = "tiny";
|
|
2141
2091
|
var DynamicSelection = ({ onSelect }) => {
|
|
2142
|
-
const [searchValue, setSearchValue] =
|
|
2092
|
+
const [searchValue, setSearchValue] = useState8("");
|
|
2143
2093
|
const { groups: dynamicGroups } = getAtomicDynamicTags() || {};
|
|
2144
2094
|
const { value: anyValue } = useBoundProp2();
|
|
2145
|
-
const { bind, value:
|
|
2146
|
-
const
|
|
2147
|
-
const isCurrentValueDynamic = !!
|
|
2095
|
+
const { bind, value: dynamicValue, setValue } = useBoundProp2(dynamicPropTypeUtil);
|
|
2096
|
+
const [, updatePropValueHistory] = usePersistDynamicValue(bind);
|
|
2097
|
+
const isCurrentValueDynamic = !!dynamicValue;
|
|
2148
2098
|
const options10 = useFilteredOptions(bind, searchValue);
|
|
2149
2099
|
const handleSearch = (event) => {
|
|
2150
2100
|
setSearchValue(event.target.value);
|
|
2151
2101
|
};
|
|
2152
2102
|
const handleSetDynamicTag = (value) => {
|
|
2153
2103
|
if (!isCurrentValueDynamic) {
|
|
2154
|
-
updatePropValueHistory(
|
|
2104
|
+
updatePropValueHistory(anyValue);
|
|
2155
2105
|
}
|
|
2156
2106
|
setValue({ name: value, settings: {} });
|
|
2157
2107
|
onSelect?.();
|
|
@@ -2169,7 +2119,7 @@ var DynamicSelection = ({ onSelect }) => {
|
|
|
2169
2119
|
}
|
|
2170
2120
|
}
|
|
2171
2121
|
)), /* @__PURE__ */ React62.createElement(Divider9, null), /* @__PURE__ */ React62.createElement(Box5, { sx: { overflowY: "auto", height: 260, width: 220 } }, options10.length > 0 ? /* @__PURE__ */ React62.createElement(MenuList, { role: "listbox", tabIndex: 0 }, options10.map(([category, items3], index) => /* @__PURE__ */ React62.createElement(Fragment8, { key: index }, /* @__PURE__ */ React62.createElement(ListSubheader, { sx: { typography: "caption", color: "text.tertiary" } }, dynamicGroups?.[category]?.title || category), items3.map(({ value, label: tagLabel }) => {
|
|
2172
|
-
const isSelected = isCurrentValueDynamic && value ===
|
|
2122
|
+
const isSelected = isCurrentValueDynamic && value === dynamicValue?.name;
|
|
2173
2123
|
return /* @__PURE__ */ React62.createElement(
|
|
2174
2124
|
MenuItem,
|
|
2175
2125
|
{
|
|
@@ -2213,14 +2163,13 @@ var SIZE4 = "tiny";
|
|
|
2213
2163
|
var DynamicSelectionControl = () => {
|
|
2214
2164
|
const { setValue: setAnyValue } = useBoundProp3();
|
|
2215
2165
|
const { bind, value } = useBoundProp3(dynamicPropTypeUtil);
|
|
2216
|
-
const
|
|
2166
|
+
const [propValueFromHistory] = usePersistDynamicValue(bind);
|
|
2217
2167
|
const { name: tagName = "" } = value;
|
|
2218
2168
|
const selectionPopoverId = useId3();
|
|
2219
2169
|
const selectionPopoverState = usePopupState2({ variant: "popover", popupId: selectionPopoverId });
|
|
2220
2170
|
const dynamicTag = useDynamicTag(bind, tagName);
|
|
2221
2171
|
const removeDynamicTag = () => {
|
|
2222
|
-
|
|
2223
|
-
setAnyValue(propValue ?? null);
|
|
2172
|
+
setAnyValue(propValueFromHistory ?? null);
|
|
2224
2173
|
};
|
|
2225
2174
|
if (!dynamicTag) {
|
|
2226
2175
|
throw new Error(`Dynamic tag ${tagName} not found`);
|