@elementor/editor-editing-panel 1.43.0 → 1.44.0

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/index.d.mts +4 -1
  3. package/dist/index.d.ts +4 -1
  4. package/dist/index.js +1087 -905
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +857 -677
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +4 -4
  9. package/src/action.tsx +1 -1
  10. package/src/components/add-or-remove-content.tsx +3 -4
  11. package/src/components/collapsible-content.tsx +42 -14
  12. package/src/components/control-label.tsx +1 -1
  13. package/src/components/section.tsx +21 -7
  14. package/src/components/style-sections/border-section/border-field.tsx +2 -1
  15. package/src/components/style-sections/position-section/dimensions-field.tsx +8 -8
  16. package/src/components/style-sections/size-section/size-section.tsx +3 -3
  17. package/src/components/style-sections/typography-section/text-stroke-field.tsx +2 -1
  18. package/src/components/style-sections/typography-section/typography-section.tsx +15 -3
  19. package/src/components/style-tab-collapsible-content.tsx +22 -0
  20. package/src/components/style-tab-section.tsx +30 -0
  21. package/src/components/style-tab.tsx +51 -35
  22. package/src/controls-registry/styles-field.tsx +1 -1
  23. package/src/dynamics/components/dynamic-selection-control.tsx +11 -15
  24. package/src/index.ts +1 -0
  25. package/src/popover-action.tsx +3 -9
  26. package/src/styles-inheritance/components/{label-chip.tsx → infotip/label-chip.tsx} +1 -1
  27. package/src/styles-inheritance/{styles-inheritance-indicator.tsx → components/styles-inheritance-indicator.tsx} +8 -8
  28. package/src/styles-inheritance/{styles-inheritance-infotip.tsx → components/styles-inheritance-infotip.tsx} +7 -7
  29. package/src/styles-inheritance/components/styles-inheritance-section-indicators.tsx +113 -0
  30. /package/src/styles-inheritance/components/{action-icons.tsx → infotip/action-icons.tsx} +0 -0
  31. /package/src/styles-inheritance/components/{breakpoint-icon.tsx → infotip/breakpoint-icon.tsx} +0 -0
  32. /package/src/styles-inheritance/components/{index.ts → infotip/index.ts} +0 -0
  33. /package/src/styles-inheritance/components/{value-component.tsx → infotip/value-component.tsx} +0 -0
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { type ComponentType, type ElementType as ReactElementType, useId } from 'react';
3
- import { XIcon } from '@elementor/icons';
4
- import { bindPopover, bindToggle, IconButton, Popover, Stack, Tooltip, Typography, usePopupState } from '@elementor/ui';
3
+ import { PopoverHeader } from '@elementor/editor-ui';
4
+ import { bindPopover, bindToggle, IconButton, Popover, Tooltip, usePopupState } from '@elementor/ui';
5
5
 
6
6
  const SIZE = 'tiny';
7
7
 
@@ -44,13 +44,7 @@ export default function PopoverAction( {
44
44
  } }
45
45
  { ...bindPopover( popupState ) }
46
46
  >
47
- <Stack direction="row" alignItems="center" pl={ 1.5 } pr={ 0.5 } py={ 1.5 }>
48
- <Icon fontSize={ SIZE } sx={ { mr: 0.5 } } />
49
- <Typography variant="subtitle2">{ title }</Typography>
50
- <IconButton sx={ { ml: 'auto' } } size={ SIZE } onClick={ popupState.close }>
51
- <XIcon fontSize={ SIZE } />
52
- </IconButton>
53
- </Stack>
47
+ <PopoverHeader title={ title } onClose={ popupState.close } icon={ <Icon fontSize={ SIZE } /> } />
54
48
  <PopoverContent closePopover={ popupState.close } />
55
49
  </Popover>
56
50
  </>
@@ -4,7 +4,7 @@ import { InfoCircleIcon } from '@elementor/icons';
4
4
  import { Chip, type Theme, Tooltip } from '@elementor/ui';
5
5
  import { __ } from '@wordpress/i18n';
6
6
 
7
- import { type ChipColors } from '../types';
7
+ import { type ChipColors } from '../../types';
8
8
 
9
9
  type Props = {
10
10
  displayLabel: string;
@@ -6,12 +6,12 @@ import { isExperimentActive } from '@elementor/editor-v1-adapters';
6
6
  import { Tooltip } from '@elementor/ui';
7
7
  import { __ } from '@wordpress/i18n';
8
8
 
9
- import { StyleIndicator } from '../components/style-indicator';
10
- import { useStyle } from '../contexts/style-context';
11
- import { useStylesInheritanceChain } from '../contexts/styles-inheritance-context';
12
- import { EXPERIMENTAL_FEATURES } from '../sync/experiments-flags';
13
- import { isUsingIndicatorPopover } from './consts';
14
- import { StyleIndicatorInfotip } from './styles-inheritance-infotip';
9
+ import { StyleIndicator } from '../../components/style-indicator';
10
+ import { useStyle } from '../../contexts/style-context';
11
+ import { useStylesInheritanceChain } from '../../contexts/styles-inheritance-context';
12
+ import { EXPERIMENTAL_FEATURES } from '../../sync/experiments-flags';
13
+ import { isUsingIndicatorPopover } from '../consts';
14
+ import { StylesInheritanceInfotip } from './styles-inheritance-infotip';
15
15
 
16
16
  export const StylesInheritanceIndicator = () => {
17
17
  const { path, propType } = useBoundProp();
@@ -61,14 +61,14 @@ export const StylesInheritanceIndicator = () => {
61
61
  }
62
62
 
63
63
  return (
64
- <StyleIndicatorInfotip
64
+ <StylesInheritanceInfotip
65
65
  inheritanceChain={ inheritanceChain }
66
66
  path={ finalPath }
67
67
  propType={ propType }
68
68
  label={ label }
69
69
  >
70
70
  <StyleIndicator variant={ variantType } />
71
- </StyleIndicatorInfotip>
71
+ </StylesInheritanceInfotip>
72
72
  );
73
73
  };
74
74
 
@@ -18,12 +18,12 @@ import {
18
18
  } from '@elementor/ui';
19
19
  import { __ } from '@wordpress/i18n';
20
20
 
21
- import { useSectionContentRef } from '../components/section-content';
22
- import { useDirection } from '../hooks/use-direction';
23
- import { ActionIcons, BreakpointIcon, LabelChip, ValueComponent } from './components';
24
- import { useNormalizedInheritanceChainItems } from './hooks/use-normalized-inheritance-chain-items';
25
- import { stylesInheritanceTransformersRegistry } from './styles-inheritance-transformers-registry';
26
- import { type SnapshotPropValue } from './types';
21
+ import { useSectionContentRef } from '../../components/section-content';
22
+ import { useDirection } from '../../hooks/use-direction';
23
+ import { useNormalizedInheritanceChainItems } from '../hooks/use-normalized-inheritance-chain-items';
24
+ import { stylesInheritanceTransformersRegistry } from '../styles-inheritance-transformers-registry';
25
+ import { type SnapshotPropValue } from '../types';
26
+ import { ActionIcons, BreakpointIcon, LabelChip, ValueComponent } from './infotip';
27
27
 
28
28
  type Props = {
29
29
  inheritanceChain: SnapshotPropValue[];
@@ -35,7 +35,7 @@ type Props = {
35
35
 
36
36
  const SIZE = 'tiny';
37
37
 
38
- export const StyleIndicatorInfotip = ( { inheritanceChain, propType, path, label, children }: Props ) => {
38
+ export const StylesInheritanceInfotip = ( { inheritanceChain, propType, path, label, children }: Props ) => {
39
39
  const [ showInfotip, setShowInfotip ] = useState< boolean >( false );
40
40
  const toggleInfotip = () => setShowInfotip( ( prev ) => ! prev );
41
41
  const closeInfotip = () => setShowInfotip( false );
@@ -0,0 +1,113 @@
1
+ import * as React from 'react';
2
+ import { type PropKey } from '@elementor/editor-props';
3
+ import { type StyleDefinitionVariant } from '@elementor/editor-styles';
4
+ import { ELEMENTS_BASE_STYLES_PROVIDER_KEY, isElementsStylesProvider } from '@elementor/editor-styles-repository';
5
+ import { Stack, Tooltip } from '@elementor/ui';
6
+ import { __ } from '@wordpress/i18n';
7
+
8
+ import { StyleIndicator } from '../../components/style-indicator';
9
+ import { useStyle } from '../../contexts/style-context';
10
+ import { useStylesInheritanceSnapshot } from '../../contexts/styles-inheritance-context';
11
+ import { type SnapshotPropValue } from '../types';
12
+
13
+ type Props = {
14
+ fields: PropKey[];
15
+ };
16
+
17
+ type Indicators = {
18
+ global?: true;
19
+ local?: true;
20
+ overridden?: true;
21
+ };
22
+
23
+ const orderedVariants = [ 'global', 'local', 'overridden' ] as ( keyof Indicators )[];
24
+
25
+ export const StylesInheritanceSectionIndicators = ( { fields }: Props ) => {
26
+ const { id, meta } = useStyle();
27
+ const snapshot = useStylesInheritanceSnapshot();
28
+
29
+ const snapshotFields = Object.fromEntries(
30
+ Object.entries( snapshot ?? {} ).filter( ( [ key ] ) => fields.includes( key as PropKey ) )
31
+ );
32
+
33
+ const indicators = getIndicators( snapshotFields, id ?? '', meta );
34
+
35
+ if ( Object.values( indicators ).filter( Boolean ).length === 0 ) {
36
+ return null;
37
+ }
38
+
39
+ const hasActualValues = __( 'Has effective styles', 'elementor' );
40
+ const hasOverriddenValues = __( 'Has overridden styles', 'elementor' );
41
+
42
+ return (
43
+ <Tooltip title={ __( 'Has styles', 'elementor' ) } placement="top">
44
+ <Stack direction="row" sx={ { '& > *': { marginInlineStart: -0.25 } } } role="list">
45
+ { orderedVariants.map(
46
+ ( variant ) =>
47
+ indicators[ variant ] && (
48
+ <StyleIndicator
49
+ key={ variant }
50
+ variant={ variant }
51
+ data-variant={ variant }
52
+ role="listitem"
53
+ aria-label={ variant === 'overridden' ? hasOverriddenValues : hasActualValues }
54
+ />
55
+ )
56
+ ) }
57
+ </Stack>
58
+ </Tooltip>
59
+ );
60
+ };
61
+
62
+ function getIndicators(
63
+ snapshotFields: Record< PropKey, SnapshotPropValue[] >,
64
+ styleId: string,
65
+ meta: StyleDefinitionVariant[ 'meta' ]
66
+ ): Indicators {
67
+ const indicators: Indicators = {};
68
+
69
+ Object.values( snapshotFields ).forEach( ( inheritanceChain ) => {
70
+ const currentStyle = getCurrentStyleFromChain( inheritanceChain, styleId, meta );
71
+
72
+ if ( ! currentStyle ) {
73
+ return;
74
+ }
75
+
76
+ const [ actualStyle ] = inheritanceChain;
77
+
78
+ if ( currentStyle === actualStyle ) {
79
+ const providerKey = actualStyle.provider ?? '';
80
+
81
+ if ( isElementsStylesProvider( providerKey ) ) {
82
+ indicators.local = true;
83
+
84
+ return;
85
+ }
86
+
87
+ if ( providerKey !== ELEMENTS_BASE_STYLES_PROVIDER_KEY ) {
88
+ indicators.global = true;
89
+ }
90
+
91
+ return;
92
+ }
93
+
94
+ indicators.overridden = true;
95
+ } );
96
+
97
+ return indicators;
98
+ }
99
+
100
+ function getCurrentStyleFromChain(
101
+ chain: SnapshotPropValue[],
102
+ styleId: string,
103
+ meta: StyleDefinitionVariant[ 'meta' ]
104
+ ): SnapshotPropValue | undefined {
105
+ return chain.find(
106
+ ( {
107
+ style: { id },
108
+ variant: {
109
+ meta: { breakpoint, state },
110
+ },
111
+ } ) => id === styleId && breakpoint === meta.breakpoint && state === meta.state
112
+ );
113
+ }