@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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.38.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 27c4c1f: Added a separated style inheritance indicator to background-color
8
+ - Updated dependencies [7c8df3b]
9
+ - Updated dependencies [15450a8]
10
+ - Updated dependencies [89dfaf2]
11
+ - Updated dependencies [97fbdf0]
12
+ - Updated dependencies [27c4c1f]
13
+ - @elementor/editor-controls@0.31.0
14
+ - @elementor/editor-styles-repository@0.9.0
15
+ - @elementor/editor-canvas@0.22.0
16
+ - @elementor/editor-current-user@0.4.0
17
+ - @elementor/editor-props@0.12.1
18
+ - @elementor/editor-elements@0.8.4
19
+ - @elementor/editor-styles@0.6.8
20
+
3
21
  ## 1.38.0
4
22
 
5
23
  ### Minor Changes
package/dist/index.js CHANGED
@@ -1242,7 +1242,7 @@ var Control2 = ({ control }) => {
1242
1242
  // src/components/style-tab.tsx
1243
1243
  var React72 = __toESM(require("react"));
1244
1244
  var import_react25 = require("react");
1245
- var import_editor_props7 = require("@elementor/editor-props");
1245
+ var import_editor_props9 = require("@elementor/editor-props");
1246
1246
  var import_editor_responsive2 = require("@elementor/editor-responsive");
1247
1247
  var import_session4 = require("@elementor/session");
1248
1248
  var import_ui60 = require("@elementor/ui");
@@ -1252,7 +1252,7 @@ var import_i18n48 = require("@wordpress/i18n");
1252
1252
  var React17 = __toESM(require("react"));
1253
1253
  var import_react14 = require("react");
1254
1254
  var import_editor_elements4 = require("@elementor/editor-elements");
1255
- var import_editor_props3 = require("@elementor/editor-props");
1255
+ var import_editor_props4 = require("@elementor/editor-props");
1256
1256
  var import_editor_responsive = require("@elementor/editor-responsive");
1257
1257
  var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
1258
1258
 
@@ -1264,6 +1264,9 @@ var useStylesRerender = () => {
1264
1264
  (0, import_react13.useEffect)(() => provider?.subscribe(reRender), [provider]);
1265
1265
  };
1266
1266
 
1267
+ // src/styles-inheritance/create-styles-inheritance.ts
1268
+ var import_editor_props3 = require("@elementor/editor-props");
1269
+
1267
1270
  // src/styles-inheritance/create-snapshots-manager.ts
1268
1271
  var import_editor_props2 = require("@elementor/editor-props");
1269
1272
 
@@ -1393,7 +1396,20 @@ function mergeSnapshots(snapshots) {
1393
1396
  function createStylesInheritance(styleDefs, breakpointsRoot) {
1394
1397
  const styleVariantsByMeta = buildStyleVariantsByMetaMapping(styleDefs);
1395
1398
  const getStyles = ({ breakpoint, state }) => styleVariantsByMeta?.[getBreakpointKey(breakpoint)]?.[getStateKey(state)] ?? [];
1396
- return createSnapshotsManager(getStyles, breakpointsRoot);
1399
+ return {
1400
+ getSnapshot: createSnapshotsManager(getStyles, breakpointsRoot),
1401
+ getInheritanceChain: (snapshot, path) => {
1402
+ const [field, ...nextFields] = path;
1403
+ let inheritanceChain = snapshot[field] ?? [];
1404
+ if (nextFields.length > 0) {
1405
+ inheritanceChain = inheritanceChain.map(({ value: styleValue, ...rest }) => ({
1406
+ ...rest,
1407
+ value: getValueByPath(styleValue, nextFields)
1408
+ })).filter(({ value: styleValue }) => !(0, import_editor_props3.isEmpty)(styleValue));
1409
+ }
1410
+ return inheritanceChain;
1411
+ }
1412
+ };
1397
1413
  }
1398
1414
  function buildStyleVariantsByMetaMapping(styleDefs) {
1399
1415
  const breakpointStateSlots = {};
@@ -1420,32 +1436,53 @@ function buildStyleVariantsByMetaMapping(styleDefs) {
1420
1436
  });
1421
1437
  return breakpointStateSlots;
1422
1438
  }
1439
+ function getValueByPath(value, path) {
1440
+ if (!value || typeof value !== "object") {
1441
+ return null;
1442
+ }
1443
+ return path.reduce((currentScope, key) => {
1444
+ if (!currentScope) {
1445
+ return null;
1446
+ }
1447
+ if ((0, import_editor_props3.isTransformable)(currentScope)) {
1448
+ return currentScope.value?.[key];
1449
+ }
1450
+ if (typeof currentScope === "object") {
1451
+ return currentScope[key];
1452
+ }
1453
+ return null;
1454
+ }, value);
1455
+ }
1423
1456
 
1424
1457
  // src/contexts/styles-inheritance-context.tsx
1425
1458
  var Context4 = (0, import_react14.createContext)(null);
1426
1459
  function StyleInheritanceProvider({ children }) {
1427
1460
  const styleDefs = useAppliedStyles();
1428
1461
  const breakpointsTree = (0, import_editor_responsive.getBreakpointsTree)();
1429
- const getSnapshot = createStylesInheritance(styleDefs, breakpointsTree);
1430
- return /* @__PURE__ */ React17.createElement(Context4.Provider, { value: { getSnapshot } }, children);
1462
+ const { getSnapshot, getInheritanceChain } = createStylesInheritance(styleDefs, breakpointsTree);
1463
+ return /* @__PURE__ */ React17.createElement(Context4.Provider, { value: { getSnapshot, getInheritanceChain } }, children);
1431
1464
  }
1432
- function useStylesInheritanceFields(fields) {
1465
+ function useStylesInheritanceSnapshot() {
1433
1466
  const context = (0, import_react14.useContext)(Context4);
1434
1467
  const { meta } = useStyle();
1435
1468
  if (!context) {
1436
- throw new Error("useStylesInheritanceFields must be used within a StyleInheritanceProvider");
1469
+ throw new Error("useStylesInheritanceSnapshot must be used within a StyleInheritanceProvider");
1437
1470
  }
1438
1471
  if (!meta) {
1439
1472
  return null;
1440
1473
  }
1441
- const snapshot = context.getSnapshot(meta);
1442
- return fields.reduce(
1443
- (acc, key) => ({ ...acc, [key]: snapshot?.[key] ?? [] }),
1444
- {}
1445
- );
1474
+ return context.getSnapshot(meta) ?? null;
1446
1475
  }
1447
- function useStylesInheritanceField(field) {
1448
- return useStylesInheritanceFields([field])?.[field] ?? [];
1476
+ function useStylesInheritanceChain(path) {
1477
+ const context = (0, import_react14.useContext)(Context4);
1478
+ if (!context) {
1479
+ throw new Error("useStylesInheritanceChain must be used within a StyleInheritanceProvider");
1480
+ }
1481
+ const snapshot = useStylesInheritanceSnapshot();
1482
+ if (!snapshot) {
1483
+ return [];
1484
+ }
1485
+ return context.getInheritanceChain(snapshot, path);
1449
1486
  }
1450
1487
  var useAppliedStyles = () => {
1451
1488
  const { element } = useElement();
@@ -1453,7 +1490,7 @@ var useAppliedStyles = () => {
1453
1490
  const baseStyles = useBaseStyles();
1454
1491
  useStylesRerender();
1455
1492
  const classesProp = (0, import_editor_elements4.useElementSetting)(element.id, currentClassesProp);
1456
- const appliedStyles = import_editor_props3.classesPropTypeUtil.extract(classesProp);
1493
+ const appliedStyles = import_editor_props4.classesPropTypeUtil.extract(classesProp);
1457
1494
  return import_editor_styles_repository5.stylesRepository.all().filter((style) => appliedStyles?.includes(style.id)).concat(baseStyles);
1458
1495
  };
1459
1496
  var useBaseStyles = () => {
@@ -1494,7 +1531,7 @@ var import_editor_controls7 = require("@elementor/editor-controls");
1494
1531
  // src/controls-registry/styles-field.tsx
1495
1532
  var React20 = __toESM(require("react"));
1496
1533
  var import_editor_controls6 = require("@elementor/editor-controls");
1497
- var import_editor_styles3 = require("@elementor/editor-styles");
1534
+ var import_editor_styles2 = require("@elementor/editor-styles");
1498
1535
 
1499
1536
  // src/hooks/use-styles-fields.ts
1500
1537
  var import_react16 = require("react");
@@ -1636,6 +1673,7 @@ function useStylesField(propName) {
1636
1673
  var React19 = __toESM(require("react"));
1637
1674
  var import_react19 = require("react");
1638
1675
  var import_editor_controls5 = require("@elementor/editor-controls");
1676
+ var import_editor_props5 = require("@elementor/editor-props");
1639
1677
  var import_editor_styles_repository7 = require("@elementor/editor-styles-repository");
1640
1678
  var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
1641
1679
  var import_ui16 = require("@elementor/ui");
@@ -1645,7 +1683,6 @@ var import_i18n5 = require("@wordpress/i18n");
1645
1683
  var React18 = __toESM(require("react"));
1646
1684
  var import_react18 = require("react");
1647
1685
  var import_editor_canvas = require("@elementor/editor-canvas");
1648
- var import_editor_styles2 = require("@elementor/editor-styles");
1649
1686
  var import_ui15 = require("@elementor/ui");
1650
1687
 
1651
1688
  // src/hooks/use-normalized-inheritance-chain-items.tsx
@@ -1689,15 +1726,15 @@ var getTransformedValue = async (item, bind, resolve) => {
1689
1726
  };
1690
1727
 
1691
1728
  // src/styles-inheritance/styles-inheritance-infotip.tsx
1692
- var StyleIndicatorInfotip = ({ inheritanceChain, bind }) => {
1729
+ var StyleIndicatorInfotip = ({ inheritanceChain, propType, path }) => {
1730
+ const key = path.join(".");
1693
1731
  const resolve = (0, import_react18.useMemo)(() => {
1694
- const stylesSchema = (0, import_editor_styles2.getStylesSchema)();
1695
1732
  return (0, import_editor_canvas.createPropsResolver)({
1696
1733
  transformers: import_editor_canvas.styleTransformersRegistry,
1697
- schema: { [bind]: stylesSchema[bind] }
1734
+ schema: { [key]: propType }
1698
1735
  });
1699
- }, [bind]);
1700
- const items3 = useNormalizedInheritanceChainItems(inheritanceChain, bind, resolve);
1736
+ }, [key, propType]);
1737
+ const items3 = useNormalizedInheritanceChainItems(inheritanceChain, key, resolve);
1701
1738
  return /* @__PURE__ */ React18.createElement(import_ui15.Card, { elevation: 0, sx: { maxWidth: 320 } }, /* @__PURE__ */ React18.createElement(import_ui15.CardContent, { sx: { p: 1.5, pb: 2.5 } }, /* @__PURE__ */ React18.createElement(import_ui15.List, null, items3.map((item) => /* @__PURE__ */ React18.createElement(import_ui15.ListItem, { key: item.id }, /* @__PURE__ */ React18.createElement(
1702
1739
  import_ui15.ListItemText,
1703
1740
  {
@@ -1709,10 +1746,11 @@ var StyleIndicatorInfotip = ({ inheritanceChain, bind }) => {
1709
1746
  // src/styles-inheritance/styles-inheritance-indicator.tsx
1710
1747
  var StylesInheritanceIndicator = () => {
1711
1748
  const [open, setOpen] = (0, import_react19.useState)(false);
1712
- const { value, path } = (0, import_editor_controls5.useBoundProp)();
1749
+ const { value, path, propType } = (0, import_editor_controls5.useBoundProp)();
1713
1750
  const { id: currentStyleId, provider: currentStyleProvider, meta: currentStyleMeta } = useStyle();
1714
- const [bind] = path;
1715
- const inheritanceChain = useStylesInheritanceField(bind);
1751
+ const isUsingNestedProps = (0, import_editor_v1_adapters3.isExperimentActive)("e_v_3_30");
1752
+ const finalPath = isUsingNestedProps ? path : path.slice(0, 1);
1753
+ const inheritanceChain = useStylesInheritanceChain(finalPath);
1716
1754
  if (!inheritanceChain.length) {
1717
1755
  return null;
1718
1756
  }
@@ -1722,7 +1760,7 @@ var StylesInheritanceIndicator = () => {
1722
1760
  }
1723
1761
  const { breakpoint, state } = variant.meta;
1724
1762
  const isFinalValue = style.id === currentStyleId && breakpoint === currentStyleMeta.breakpoint && state === currentStyleMeta.state;
1725
- const hasValue = value !== null && value !== void 0;
1763
+ const hasValue = !(0, import_editor_props5.isEmpty)(value);
1726
1764
  const label = getLabel({ isFinalValue, hasValue });
1727
1765
  const variantType = getVariant({ isFinalValue, hasValue, currentStyleProvider });
1728
1766
  const eIndicationsPopover = (0, import_editor_v1_adapters3.isExperimentActive)("e_indications_popover");
@@ -1734,7 +1772,7 @@ var StylesInheritanceIndicator = () => {
1734
1772
  import_ui16.Infotip,
1735
1773
  {
1736
1774
  placement: "top",
1737
- content: /* @__PURE__ */ React19.createElement(StyleIndicatorInfotip, { inheritanceChain, bind }),
1775
+ content: /* @__PURE__ */ React19.createElement(StyleIndicatorInfotip, { inheritanceChain, path: finalPath, propType }),
1738
1776
  open,
1739
1777
  onClose: () => setOpen(false),
1740
1778
  trigger: "manual"
@@ -1768,7 +1806,7 @@ var getVariant = ({
1768
1806
  // src/controls-registry/styles-field.tsx
1769
1807
  var StylesField = ({ bind, placeholder, children }) => {
1770
1808
  const [value, setValue] = useStylesField(bind);
1771
- const stylesSchema = (0, import_editor_styles3.getStylesSchema)();
1809
+ const stylesSchema = (0, import_editor_styles2.getStylesSchema)();
1772
1810
  const propType = createTopLevelOjectType({ schema: stylesSchema });
1773
1811
  const values = { [bind]: value };
1774
1812
  const placeholderValues = { [bind]: placeholder };
@@ -1883,7 +1921,7 @@ var BorderStyleField = () => {
1883
1921
  // src/components/style-sections/border-section/border-width-field.tsx
1884
1922
  var React28 = __toESM(require("react"));
1885
1923
  var import_editor_controls11 = require("@elementor/editor-controls");
1886
- var import_editor_props4 = require("@elementor/editor-props");
1924
+ var import_editor_props6 = require("@elementor/editor-props");
1887
1925
  var import_icons6 = require("@elementor/icons");
1888
1926
  var import_ui24 = require("@elementor/ui");
1889
1927
  var import_i18n8 = require("@wordpress/i18n");
@@ -1942,7 +1980,7 @@ var BorderWidthField = () => {
1942
1980
  label: (0, import_i18n8.__)("Border width", "elementor"),
1943
1981
  icon: /* @__PURE__ */ React28.createElement(import_icons6.SideAllIcon, { fontSize: "tiny" }),
1944
1982
  tooltipLabel: (0, import_i18n8.__)("Adjust borders", "elementor"),
1945
- multiSizePropTypeUtil: import_editor_props4.borderWidthPropTypeUtil
1983
+ multiSizePropTypeUtil: import_editor_props6.borderWidthPropTypeUtil
1946
1984
  }
1947
1985
  ));
1948
1986
  };
@@ -1983,7 +2021,7 @@ var BorderField = () => {
1983
2021
  // src/components/style-sections/border-section/border-radius-field.tsx
1984
2022
  var React30 = __toESM(require("react"));
1985
2023
  var import_editor_controls12 = require("@elementor/editor-controls");
1986
- var import_editor_props5 = require("@elementor/editor-props");
2024
+ var import_editor_props7 = require("@elementor/editor-props");
1987
2025
  var import_icons7 = require("@elementor/icons");
1988
2026
  var import_ui25 = require("@elementor/ui");
1989
2027
  var import_i18n10 = require("@wordpress/i18n");
@@ -2026,7 +2064,7 @@ var BorderRadiusField = () => {
2026
2064
  label: (0, import_i18n10.__)("Border radius", "elementor"),
2027
2065
  icon: /* @__PURE__ */ React30.createElement(import_icons7.BorderCornersIcon, { fontSize: "tiny" }),
2028
2066
  tooltipLabel: (0, import_i18n10.__)("Adjust corners", "elementor"),
2029
- multiSizePropTypeUtil: import_editor_props5.borderRadiusPropTypeUtil
2067
+ multiSizePropTypeUtil: import_editor_props7.borderRadiusPropTypeUtil
2030
2068
  }
2031
2069
  ));
2032
2070
  };
@@ -2342,7 +2380,7 @@ var DisplayField = () => {
2342
2380
  const placeholder = useDisplayPlaceholderValue();
2343
2381
  return /* @__PURE__ */ React37.createElement(StylesField, { bind: "display", placeholder }, /* @__PURE__ */ React37.createElement(import_ui30.Stack, { gap: 0.75 }, /* @__PURE__ */ React37.createElement(ControlLabel, null, (0, import_i18n14.__)("Display", "elementor")), /* @__PURE__ */ React37.createElement(import_editor_controls17.ToggleControl, { options: items3, maxItems: 4, fullWidth: true })));
2344
2382
  };
2345
- var useDisplayPlaceholderValue = () => useStylesInheritanceField("display")[0]?.value ?? void 0;
2383
+ var useDisplayPlaceholderValue = () => useStylesInheritanceChain(["display"])[0]?.value ?? void 0;
2346
2384
 
2347
2385
  // src/components/style-sections/layout-section/flex-direction-field.tsx
2348
2386
  var React38 = __toESM(require("react"));
@@ -2465,7 +2503,7 @@ var getGroupControlValue = (order) => {
2465
2503
  var React40 = __toESM(require("react"));
2466
2504
  var import_react22 = require("react");
2467
2505
  var import_editor_controls20 = require("@elementor/editor-controls");
2468
- var import_editor_props6 = require("@elementor/editor-props");
2506
+ var import_editor_props8 = require("@elementor/editor-props");
2469
2507
  var import_icons13 = require("@elementor/icons");
2470
2508
  var import_ui33 = require("@elementor/ui");
2471
2509
  var import_i18n17 = require("@wordpress/i18n");
@@ -2510,7 +2548,7 @@ var FlexSizeField = () => {
2510
2548
  if (group === "flex-grow") {
2511
2549
  setFields({
2512
2550
  "flex-basis": null,
2513
- "flex-grow": import_editor_props6.numberPropTypeUtil.create(DEFAULT),
2551
+ "flex-grow": import_editor_props8.numberPropTypeUtil.create(DEFAULT),
2514
2552
  "flex-shrink": null
2515
2553
  });
2516
2554
  return;
@@ -2518,7 +2556,7 @@ var FlexSizeField = () => {
2518
2556
  setFields({
2519
2557
  "flex-basis": null,
2520
2558
  "flex-grow": null,
2521
- "flex-shrink": import_editor_props6.numberPropTypeUtil.create(DEFAULT)
2559
+ "flex-shrink": import_editor_props8.numberPropTypeUtil.create(DEFAULT)
2522
2560
  });
2523
2561
  };
2524
2562
  return /* @__PURE__ */ React40.createElement(import_ui33.DirectionProvider, { rtl: isSiteRtl }, /* @__PURE__ */ React40.createElement(import_ui33.ThemeProvider, null, /* @__PURE__ */ React40.createElement(SectionContent, null, /* @__PURE__ */ React40.createElement(import_ui33.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React40.createElement(import_ui33.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React40.createElement(StylesField, { bind: activeGroup ?? "" }, /* @__PURE__ */ React40.createElement(ControlLabel, null, (0, import_i18n17.__)("Size", "elementor")))), /* @__PURE__ */ React40.createElement(import_ui33.Grid, { item: true, xs: 6, sx: { display: "flex", justifyContent: "end" } }, /* @__PURE__ */ React40.createElement(
@@ -3296,7 +3334,7 @@ function ClassesHeader({ children }) {
3296
3334
  function useCurrentClassesProp() {
3297
3335
  const { elementType } = useElement();
3298
3336
  const prop = Object.entries(elementType.propsSchema).find(
3299
- ([, propType]) => propType.kind === "plain" && propType.key === import_editor_props7.CLASSES_PROP_KEY
3337
+ ([, propType]) => propType.kind === "plain" && propType.key === import_editor_props9.CLASSES_PROP_KEY
3300
3338
  );
3301
3339
  if (!prop) {
3302
3340
  throw new Error("Element does not have a classes prop");
@@ -3445,7 +3483,7 @@ var getAtomicDynamicTags = () => {
3445
3483
  };
3446
3484
 
3447
3485
  // src/dynamics/utils.ts
3448
- var import_editor_props8 = require("@elementor/editor-props");
3486
+ var import_editor_props10 = require("@elementor/editor-props");
3449
3487
  var import_schema = require("@elementor/schema");
3450
3488
  var DYNAMIC_PROP_TYPE_KEY = "dynamic";
3451
3489
  var isDynamicPropType = (prop) => prop.key === DYNAMIC_PROP_TYPE_KEY;
@@ -3454,12 +3492,12 @@ var getDynamicPropType = (propType) => {
3454
3492
  return dynamicPropType && isDynamicPropType(dynamicPropType) ? dynamicPropType : null;
3455
3493
  };
3456
3494
  var isDynamicPropValue = (prop) => {
3457
- return (0, import_editor_props8.isTransformable)(prop) && prop.$$type === DYNAMIC_PROP_TYPE_KEY;
3495
+ return (0, import_editor_props10.isTransformable)(prop) && prop.$$type === DYNAMIC_PROP_TYPE_KEY;
3458
3496
  };
3459
3497
  var supportsDynamic = (propType) => {
3460
3498
  return !!getDynamicPropType(propType);
3461
3499
  };
3462
- var dynamicPropTypeUtil = (0, import_editor_props8.createPropUtils)(
3500
+ var dynamicPropTypeUtil = (0, import_editor_props10.createPropUtils)(
3463
3501
  DYNAMIC_PROP_TYPE_KEY,
3464
3502
  import_schema.z.strictObject({
3465
3503
  name: import_schema.z.string(),
@@ -3709,7 +3747,7 @@ var Control3 = ({ control }) => {
3709
3747
 
3710
3748
  // src/dynamics/dynamic-transformer.ts
3711
3749
  var import_editor_canvas2 = require("@elementor/editor-canvas");
3712
- var import_editor_props9 = require("@elementor/editor-props");
3750
+ var import_editor_props11 = require("@elementor/editor-props");
3713
3751
 
3714
3752
  // src/dynamics/errors.ts
3715
3753
  var import_utils8 = require("@elementor/utils");
@@ -3727,7 +3765,7 @@ var dynamicTransformer = (0, import_editor_canvas2.createTransformer)((value) =>
3727
3765
  });
3728
3766
  function simpleTransform(props) {
3729
3767
  const transformed = Object.entries(props).map(([settingKey, settingValue]) => {
3730
- const value = (0, import_editor_props9.isTransformable)(settingValue) ? settingValue.value : settingValue;
3768
+ const value = (0, import_editor_props11.isTransformable)(settingValue) ? settingValue.value : settingValue;
3731
3769
  return [settingKey, value];
3732
3770
  });
3733
3771
  return Object.fromEntries(transformed);