@elementor/editor-editing-panel 1.38.0 → 1.38.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 +18 -0
- package/dist/index.js +80 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/components/style-sections/layout-section/display-field.tsx +2 -2
- package/src/contexts/styles-inheritance-context.tsx +25 -20
- package/src/hooks/use-normalized-inheritance-chain-items.tsx +10 -3
- package/src/styles-inheritance/create-styles-inheritance.ts +49 -3
- package/src/styles-inheritance/styles-inheritance-indicator.tsx +14 -9
- package/src/styles-inheritance/styles-inheritance-infotip.tsx +8 -15
- package/src/styles-inheritance/types.ts +5 -0
package/dist/index.mjs
CHANGED
|
@@ -1253,6 +1253,9 @@ var useStylesRerender = () => {
|
|
|
1253
1253
|
useEffect2(() => provider?.subscribe(reRender), [provider]);
|
|
1254
1254
|
};
|
|
1255
1255
|
|
|
1256
|
+
// src/styles-inheritance/create-styles-inheritance.ts
|
|
1257
|
+
import { isEmpty, isTransformable } from "@elementor/editor-props";
|
|
1258
|
+
|
|
1256
1259
|
// src/styles-inheritance/create-snapshots-manager.ts
|
|
1257
1260
|
import { filterEmptyValues } from "@elementor/editor-props";
|
|
1258
1261
|
|
|
@@ -1382,7 +1385,20 @@ function mergeSnapshots(snapshots) {
|
|
|
1382
1385
|
function createStylesInheritance(styleDefs, breakpointsRoot) {
|
|
1383
1386
|
const styleVariantsByMeta = buildStyleVariantsByMetaMapping(styleDefs);
|
|
1384
1387
|
const getStyles = ({ breakpoint, state }) => styleVariantsByMeta?.[getBreakpointKey(breakpoint)]?.[getStateKey(state)] ?? [];
|
|
1385
|
-
return
|
|
1388
|
+
return {
|
|
1389
|
+
getSnapshot: createSnapshotsManager(getStyles, breakpointsRoot),
|
|
1390
|
+
getInheritanceChain: (snapshot, path) => {
|
|
1391
|
+
const [field, ...nextFields] = path;
|
|
1392
|
+
let inheritanceChain = snapshot[field] ?? [];
|
|
1393
|
+
if (nextFields.length > 0) {
|
|
1394
|
+
inheritanceChain = inheritanceChain.map(({ value: styleValue, ...rest }) => ({
|
|
1395
|
+
...rest,
|
|
1396
|
+
value: getValueByPath(styleValue, nextFields)
|
|
1397
|
+
})).filter(({ value: styleValue }) => !isEmpty(styleValue));
|
|
1398
|
+
}
|
|
1399
|
+
return inheritanceChain;
|
|
1400
|
+
}
|
|
1401
|
+
};
|
|
1386
1402
|
}
|
|
1387
1403
|
function buildStyleVariantsByMetaMapping(styleDefs) {
|
|
1388
1404
|
const breakpointStateSlots = {};
|
|
@@ -1409,32 +1425,53 @@ function buildStyleVariantsByMetaMapping(styleDefs) {
|
|
|
1409
1425
|
});
|
|
1410
1426
|
return breakpointStateSlots;
|
|
1411
1427
|
}
|
|
1428
|
+
function getValueByPath(value, path) {
|
|
1429
|
+
if (!value || typeof value !== "object") {
|
|
1430
|
+
return null;
|
|
1431
|
+
}
|
|
1432
|
+
return path.reduce((currentScope, key) => {
|
|
1433
|
+
if (!currentScope) {
|
|
1434
|
+
return null;
|
|
1435
|
+
}
|
|
1436
|
+
if (isTransformable(currentScope)) {
|
|
1437
|
+
return currentScope.value?.[key];
|
|
1438
|
+
}
|
|
1439
|
+
if (typeof currentScope === "object") {
|
|
1440
|
+
return currentScope[key];
|
|
1441
|
+
}
|
|
1442
|
+
return null;
|
|
1443
|
+
}, value);
|
|
1444
|
+
}
|
|
1412
1445
|
|
|
1413
1446
|
// src/contexts/styles-inheritance-context.tsx
|
|
1414
1447
|
var Context4 = createContext5(null);
|
|
1415
1448
|
function StyleInheritanceProvider({ children }) {
|
|
1416
1449
|
const styleDefs = useAppliedStyles();
|
|
1417
1450
|
const breakpointsTree = getBreakpointsTree();
|
|
1418
|
-
const getSnapshot = createStylesInheritance(styleDefs, breakpointsTree);
|
|
1419
|
-
return /* @__PURE__ */ React17.createElement(Context4.Provider, { value: { getSnapshot } }, children);
|
|
1451
|
+
const { getSnapshot, getInheritanceChain } = createStylesInheritance(styleDefs, breakpointsTree);
|
|
1452
|
+
return /* @__PURE__ */ React17.createElement(Context4.Provider, { value: { getSnapshot, getInheritanceChain } }, children);
|
|
1420
1453
|
}
|
|
1421
|
-
function
|
|
1454
|
+
function useStylesInheritanceSnapshot() {
|
|
1422
1455
|
const context = useContext5(Context4);
|
|
1423
1456
|
const { meta } = useStyle();
|
|
1424
1457
|
if (!context) {
|
|
1425
|
-
throw new Error("
|
|
1458
|
+
throw new Error("useStylesInheritanceSnapshot must be used within a StyleInheritanceProvider");
|
|
1426
1459
|
}
|
|
1427
1460
|
if (!meta) {
|
|
1428
1461
|
return null;
|
|
1429
1462
|
}
|
|
1430
|
-
|
|
1431
|
-
return fields.reduce(
|
|
1432
|
-
(acc, key) => ({ ...acc, [key]: snapshot?.[key] ?? [] }),
|
|
1433
|
-
{}
|
|
1434
|
-
);
|
|
1463
|
+
return context.getSnapshot(meta) ?? null;
|
|
1435
1464
|
}
|
|
1436
|
-
function
|
|
1437
|
-
|
|
1465
|
+
function useStylesInheritanceChain(path) {
|
|
1466
|
+
const context = useContext5(Context4);
|
|
1467
|
+
if (!context) {
|
|
1468
|
+
throw new Error("useStylesInheritanceChain must be used within a StyleInheritanceProvider");
|
|
1469
|
+
}
|
|
1470
|
+
const snapshot = useStylesInheritanceSnapshot();
|
|
1471
|
+
if (!snapshot) {
|
|
1472
|
+
return [];
|
|
1473
|
+
}
|
|
1474
|
+
return context.getInheritanceChain(snapshot, path);
|
|
1438
1475
|
}
|
|
1439
1476
|
var useAppliedStyles = () => {
|
|
1440
1477
|
const { element } = useElement();
|
|
@@ -1483,7 +1520,7 @@ import { BackgroundControl } from "@elementor/editor-controls";
|
|
|
1483
1520
|
// src/controls-registry/styles-field.tsx
|
|
1484
1521
|
import * as React20 from "react";
|
|
1485
1522
|
import { ControlAdornmentsProvider, PropKeyProvider as PropKeyProvider2, PropProvider as PropProvider2 } from "@elementor/editor-controls";
|
|
1486
|
-
import { getStylesSchema
|
|
1523
|
+
import { getStylesSchema } from "@elementor/editor-styles";
|
|
1487
1524
|
|
|
1488
1525
|
// src/hooks/use-styles-fields.ts
|
|
1489
1526
|
import { useMemo as useMemo2 } from "react";
|
|
@@ -1629,6 +1666,7 @@ function useStylesField(propName) {
|
|
|
1629
1666
|
import * as React19 from "react";
|
|
1630
1667
|
import { useState as useState9 } from "react";
|
|
1631
1668
|
import { useBoundProp } from "@elementor/editor-controls";
|
|
1669
|
+
import { isEmpty as isEmpty2 } from "@elementor/editor-props";
|
|
1632
1670
|
import { ELEMENTS_BASE_STYLES_PROVIDER_KEY, isElementsStylesProvider as isElementsStylesProvider3 } from "@elementor/editor-styles-repository";
|
|
1633
1671
|
import { isExperimentActive as isExperimentActive2 } from "@elementor/editor-v1-adapters";
|
|
1634
1672
|
import { IconButton as IconButton2, Infotip } from "@elementor/ui";
|
|
@@ -1638,7 +1676,6 @@ import { __ as __5 } from "@wordpress/i18n";
|
|
|
1638
1676
|
import * as React18 from "react";
|
|
1639
1677
|
import { useMemo as useMemo3 } from "react";
|
|
1640
1678
|
import { createPropsResolver, styleTransformersRegistry } from "@elementor/editor-canvas";
|
|
1641
|
-
import { getStylesSchema } from "@elementor/editor-styles";
|
|
1642
1679
|
import { Card, CardContent, List as List2, ListItem, ListItemText as ListItemText2 } from "@elementor/ui";
|
|
1643
1680
|
|
|
1644
1681
|
// src/hooks/use-normalized-inheritance-chain-items.tsx
|
|
@@ -1682,15 +1719,15 @@ var getTransformedValue = async (item, bind, resolve) => {
|
|
|
1682
1719
|
};
|
|
1683
1720
|
|
|
1684
1721
|
// src/styles-inheritance/styles-inheritance-infotip.tsx
|
|
1685
|
-
var StyleIndicatorInfotip = ({ inheritanceChain,
|
|
1722
|
+
var StyleIndicatorInfotip = ({ inheritanceChain, propType, path }) => {
|
|
1723
|
+
const key = path.join(".");
|
|
1686
1724
|
const resolve = useMemo3(() => {
|
|
1687
|
-
const stylesSchema = getStylesSchema();
|
|
1688
1725
|
return createPropsResolver({
|
|
1689
1726
|
transformers: styleTransformersRegistry,
|
|
1690
|
-
schema: { [
|
|
1727
|
+
schema: { [key]: propType }
|
|
1691
1728
|
});
|
|
1692
|
-
}, [
|
|
1693
|
-
const items3 = useNormalizedInheritanceChainItems(inheritanceChain,
|
|
1729
|
+
}, [key, propType]);
|
|
1730
|
+
const items3 = useNormalizedInheritanceChainItems(inheritanceChain, key, resolve);
|
|
1694
1731
|
return /* @__PURE__ */ React18.createElement(Card, { elevation: 0, sx: { maxWidth: 320 } }, /* @__PURE__ */ React18.createElement(CardContent, { sx: { p: 1.5, pb: 2.5 } }, /* @__PURE__ */ React18.createElement(List2, null, items3.map((item) => /* @__PURE__ */ React18.createElement(ListItem, { key: item.id }, /* @__PURE__ */ React18.createElement(
|
|
1695
1732
|
ListItemText2,
|
|
1696
1733
|
{
|
|
@@ -1702,10 +1739,11 @@ var StyleIndicatorInfotip = ({ inheritanceChain, bind }) => {
|
|
|
1702
1739
|
// src/styles-inheritance/styles-inheritance-indicator.tsx
|
|
1703
1740
|
var StylesInheritanceIndicator = () => {
|
|
1704
1741
|
const [open, setOpen] = useState9(false);
|
|
1705
|
-
const { value, path } = useBoundProp();
|
|
1742
|
+
const { value, path, propType } = useBoundProp();
|
|
1706
1743
|
const { id: currentStyleId, provider: currentStyleProvider, meta: currentStyleMeta } = useStyle();
|
|
1707
|
-
const
|
|
1708
|
-
const
|
|
1744
|
+
const isUsingNestedProps = isExperimentActive2("e_v_3_30");
|
|
1745
|
+
const finalPath = isUsingNestedProps ? path : path.slice(0, 1);
|
|
1746
|
+
const inheritanceChain = useStylesInheritanceChain(finalPath);
|
|
1709
1747
|
if (!inheritanceChain.length) {
|
|
1710
1748
|
return null;
|
|
1711
1749
|
}
|
|
@@ -1715,7 +1753,7 @@ var StylesInheritanceIndicator = () => {
|
|
|
1715
1753
|
}
|
|
1716
1754
|
const { breakpoint, state } = variant.meta;
|
|
1717
1755
|
const isFinalValue = style.id === currentStyleId && breakpoint === currentStyleMeta.breakpoint && state === currentStyleMeta.state;
|
|
1718
|
-
const hasValue = value
|
|
1756
|
+
const hasValue = !isEmpty2(value);
|
|
1719
1757
|
const label = getLabel({ isFinalValue, hasValue });
|
|
1720
1758
|
const variantType = getVariant({ isFinalValue, hasValue, currentStyleProvider });
|
|
1721
1759
|
const eIndicationsPopover = isExperimentActive2("e_indications_popover");
|
|
@@ -1727,7 +1765,7 @@ var StylesInheritanceIndicator = () => {
|
|
|
1727
1765
|
Infotip,
|
|
1728
1766
|
{
|
|
1729
1767
|
placement: "top",
|
|
1730
|
-
content: /* @__PURE__ */ React19.createElement(StyleIndicatorInfotip, { inheritanceChain,
|
|
1768
|
+
content: /* @__PURE__ */ React19.createElement(StyleIndicatorInfotip, { inheritanceChain, path: finalPath, propType }),
|
|
1731
1769
|
open,
|
|
1732
1770
|
onClose: () => setOpen(false),
|
|
1733
1771
|
trigger: "manual"
|
|
@@ -1761,7 +1799,7 @@ var getVariant = ({
|
|
|
1761
1799
|
// src/controls-registry/styles-field.tsx
|
|
1762
1800
|
var StylesField = ({ bind, placeholder, children }) => {
|
|
1763
1801
|
const [value, setValue] = useStylesField(bind);
|
|
1764
|
-
const stylesSchema =
|
|
1802
|
+
const stylesSchema = getStylesSchema();
|
|
1765
1803
|
const propType = createTopLevelOjectType({ schema: stylesSchema });
|
|
1766
1804
|
const values = { [bind]: value };
|
|
1767
1805
|
const placeholderValues = { [bind]: placeholder };
|
|
@@ -2358,7 +2396,7 @@ var DisplayField = () => {
|
|
|
2358
2396
|
const placeholder = useDisplayPlaceholderValue();
|
|
2359
2397
|
return /* @__PURE__ */ React37.createElement(StylesField, { bind: "display", placeholder }, /* @__PURE__ */ React37.createElement(Stack10, { gap: 0.75 }, /* @__PURE__ */ React37.createElement(ControlLabel, null, __14("Display", "elementor")), /* @__PURE__ */ React37.createElement(ToggleControl4, { options: items3, maxItems: 4, fullWidth: true })));
|
|
2360
2398
|
};
|
|
2361
|
-
var useDisplayPlaceholderValue = () =>
|
|
2399
|
+
var useDisplayPlaceholderValue = () => useStylesInheritanceChain(["display"])[0]?.value ?? void 0;
|
|
2362
2400
|
|
|
2363
2401
|
// src/components/style-sections/layout-section/flex-direction-field.tsx
|
|
2364
2402
|
import * as React38 from "react";
|
|
@@ -3491,7 +3529,7 @@ var getAtomicDynamicTags = () => {
|
|
|
3491
3529
|
// src/dynamics/utils.ts
|
|
3492
3530
|
import {
|
|
3493
3531
|
createPropUtils,
|
|
3494
|
-
isTransformable
|
|
3532
|
+
isTransformable as isTransformable2
|
|
3495
3533
|
} from "@elementor/editor-props";
|
|
3496
3534
|
import { z } from "@elementor/schema";
|
|
3497
3535
|
var DYNAMIC_PROP_TYPE_KEY = "dynamic";
|
|
@@ -3501,7 +3539,7 @@ var getDynamicPropType = (propType) => {
|
|
|
3501
3539
|
return dynamicPropType && isDynamicPropType(dynamicPropType) ? dynamicPropType : null;
|
|
3502
3540
|
};
|
|
3503
3541
|
var isDynamicPropValue = (prop) => {
|
|
3504
|
-
return
|
|
3542
|
+
return isTransformable2(prop) && prop.$$type === DYNAMIC_PROP_TYPE_KEY;
|
|
3505
3543
|
};
|
|
3506
3544
|
var supportsDynamic = (propType) => {
|
|
3507
3545
|
return !!getDynamicPropType(propType);
|
|
@@ -3767,7 +3805,7 @@ var Control3 = ({ control }) => {
|
|
|
3767
3805
|
|
|
3768
3806
|
// src/dynamics/dynamic-transformer.ts
|
|
3769
3807
|
import { createTransformer } from "@elementor/editor-canvas";
|
|
3770
|
-
import { isTransformable as
|
|
3808
|
+
import { isTransformable as isTransformable3 } from "@elementor/editor-props";
|
|
3771
3809
|
|
|
3772
3810
|
// src/dynamics/errors.ts
|
|
3773
3811
|
import { createError as createError2 } from "@elementor/utils";
|
|
@@ -3785,7 +3823,7 @@ var dynamicTransformer = createTransformer((value) => {
|
|
|
3785
3823
|
});
|
|
3786
3824
|
function simpleTransform(props) {
|
|
3787
3825
|
const transformed = Object.entries(props).map(([settingKey, settingValue]) => {
|
|
3788
|
-
const value =
|
|
3826
|
+
const value = isTransformable3(settingValue) ? settingValue.value : settingValue;
|
|
3789
3827
|
return [settingKey, value];
|
|
3790
3828
|
});
|
|
3791
3829
|
return Object.fromEntries(transformed);
|