@elementor/editor-editing-panel 1.45.0 → 1.47.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.
- package/CHANGELOG.md +90 -0
- package/dist/index.d.mts +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.js +1187 -1051
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1027 -893
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -17
- package/src/components/css-classes/css-class-menu.tsx +6 -8
- package/src/components/css-classes/css-class-selector.tsx +17 -11
- package/src/components/popover-scrollable-content.tsx +12 -0
- package/src/components/section-content.tsx +6 -16
- package/src/components/section.tsx +8 -4
- package/src/components/settings-tab.tsx +30 -4
- package/src/components/style-indicator.tsx +19 -15
- package/src/components/style-sections/background-section/background-section.tsx +4 -1
- package/src/components/style-sections/border-section/border-color-field.tsx +10 -16
- package/src/components/style-sections/border-section/border-field.tsx +4 -6
- package/src/components/style-sections/border-section/border-radius-field.tsx +4 -2
- package/src/components/style-sections/border-section/border-style-field.tsx +11 -16
- package/src/components/style-sections/border-section/border-width-field.tsx +4 -2
- package/src/components/style-sections/effects-section/effects-section.tsx +22 -2
- package/src/components/style-sections/layout-section/align-content-field.tsx +11 -12
- package/src/components/style-sections/layout-section/align-items-field.tsx +8 -11
- package/src/components/style-sections/layout-section/align-self-child-field.tsx +11 -16
- package/src/components/style-sections/layout-section/display-field.tsx +6 -6
- package/src/components/style-sections/layout-section/flex-direction-field.tsx +11 -14
- package/src/components/style-sections/layout-section/flex-order-field.tsx +32 -37
- package/src/components/style-sections/layout-section/flex-size-field.tsx +35 -58
- package/src/components/style-sections/layout-section/gap-control-field.tsx +5 -6
- package/src/components/style-sections/layout-section/justify-content-field.tsx +11 -12
- package/src/components/style-sections/layout-section/layout-section.tsx +2 -2
- package/src/components/style-sections/layout-section/opacity-control-field.tsx +21 -0
- package/src/components/style-sections/layout-section/utils/rotated-icon.tsx +1 -1
- package/src/components/style-sections/layout-section/wrap-field.tsx +10 -14
- package/src/components/style-sections/position-section/dimensions-field.tsx +4 -4
- package/src/components/style-sections/position-section/offset-field.tsx +12 -14
- package/src/components/style-sections/position-section/position-field.tsx +7 -11
- package/src/components/style-sections/position-section/position-section.tsx +6 -6
- package/src/components/style-sections/position-section/z-index-field.tsx +7 -11
- package/src/components/style-sections/size-section/object-fit-field.tsx +7 -11
- package/src/components/style-sections/size-section/object-position-field.tsx +4 -23
- package/src/components/style-sections/size-section/overflow-field.tsx +7 -11
- package/src/components/style-sections/size-section/size-section.tsx +10 -8
- package/src/components/style-sections/spacing-section/spacing-section.tsx +7 -4
- package/src/components/style-sections/typography-section/column-count-field.tsx +7 -11
- package/src/components/style-sections/typography-section/column-gap-field.tsx +9 -13
- package/src/components/style-sections/typography-section/font-family-field.tsx +9 -11
- package/src/components/style-sections/typography-section/font-size-field.tsx +9 -13
- package/src/components/style-sections/typography-section/font-style-field.tsx +13 -13
- package/src/components/style-sections/typography-section/font-weight-field.tsx +7 -11
- package/src/components/style-sections/typography-section/letter-spacing-field.tsx +9 -13
- package/src/components/style-sections/typography-section/line-height-field.tsx +9 -13
- package/src/components/style-sections/typography-section/text-alignment-field.tsx +11 -14
- package/src/components/style-sections/typography-section/text-color-field.tsx +7 -11
- package/src/components/style-sections/typography-section/text-decoration-field.tsx +7 -11
- package/src/components/style-sections/typography-section/text-direction-field.tsx +7 -11
- package/src/components/style-sections/typography-section/text-stroke-field.tsx +8 -8
- package/src/components/style-sections/typography-section/transform-field.tsx +7 -11
- package/src/components/style-sections/typography-section/typography-section.tsx +4 -2
- package/src/components/style-sections/typography-section/word-spacing-field.tsx +9 -13
- package/src/components/styles-field-layout.tsx +50 -0
- package/src/contexts/section-context.tsx +14 -0
- package/src/controls-registry/control-type-container.tsx +6 -2
- package/src/controls-registry/controls-registry.tsx +30 -10
- package/src/controls-registry/settings-field.tsx +65 -6
- package/src/controls-registry/styles-field.tsx +11 -5
- package/src/dynamics/components/dynamic-selection-control.tsx +20 -22
- package/src/dynamics/components/dynamic-selection.tsx +64 -79
- package/src/dynamics/hooks/use-prop-dynamic-action.tsx +1 -1
- package/src/hooks/use-default-panel-settings.ts +4 -0
- package/src/hooks/use-styles-field.ts +9 -3
- package/src/hooks/use-styles-fields.ts +4 -4
- package/src/index.ts +5 -0
- package/src/popover-action.tsx +11 -6
- package/src/provider-colors-registry.ts +20 -0
- package/src/styles-inheritance/components/infotip/label-chip.tsx +4 -5
- package/src/styles-inheritance/components/styles-inheritance-indicator.tsx +36 -41
- package/src/styles-inheritance/components/styles-inheritance-infotip.tsx +10 -24
- package/src/styles-inheritance/components/styles-inheritance-section-indicators.tsx +29 -44
- package/src/styles-inheritance/hooks/use-normalized-inheritance-chain-items.tsx +1 -17
- package/src/styles-inheritance/types.ts +0 -2
- package/src/styles-inheritance/utils.ts +17 -1
- package/src/sync/experiments-flags.ts +1 -0
- package/src/utils/get-styles-provider-color.ts +28 -0
- package/src/components/popover-content.tsx +0 -15
|
@@ -1,58 +1,54 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type PropKey } from '@elementor/editor-props';
|
|
3
3
|
import { type StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
4
|
-
import {
|
|
4
|
+
import { isElementsStylesProvider } from '@elementor/editor-styles-repository';
|
|
5
5
|
import { Stack, Tooltip } from '@elementor/ui';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
|
|
8
8
|
import { StyleIndicator } from '../../components/style-indicator';
|
|
9
9
|
import { useStyle } from '../../contexts/style-context';
|
|
10
10
|
import { useStylesInheritanceSnapshot } from '../../contexts/styles-inheritance-context';
|
|
11
|
+
import { getStylesProviderThemeColor } from '../../utils/get-styles-provider-color';
|
|
11
12
|
import { type SnapshotPropValue } from '../types';
|
|
12
|
-
|
|
13
13
|
type Props = {
|
|
14
14
|
fields: PropKey[];
|
|
15
15
|
};
|
|
16
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
17
|
export const StylesInheritanceSectionIndicators = ( { fields }: Props ) => {
|
|
26
|
-
const { id, meta } = useStyle();
|
|
18
|
+
const { id, meta, provider } = useStyle();
|
|
27
19
|
const snapshot = useStylesInheritanceSnapshot();
|
|
28
20
|
|
|
29
21
|
const snapshotFields = Object.fromEntries(
|
|
30
22
|
Object.entries( snapshot ?? {} ).filter( ( [ key ] ) => fields.includes( key as PropKey ) )
|
|
31
23
|
);
|
|
32
24
|
|
|
33
|
-
const
|
|
25
|
+
const { hasValues, hasOverrides } = getIndicators( snapshotFields, id ?? '', meta );
|
|
34
26
|
|
|
35
|
-
if (
|
|
27
|
+
if ( ! hasValues && ! hasOverrides ) {
|
|
36
28
|
return null;
|
|
37
29
|
}
|
|
38
30
|
|
|
39
|
-
const
|
|
40
|
-
const
|
|
31
|
+
const hasValueLabel = __( 'Has effective styles', 'elementor' );
|
|
32
|
+
const hasOverridesLabel = __( 'Has overridden styles', 'elementor' );
|
|
41
33
|
|
|
42
34
|
return (
|
|
43
35
|
<Tooltip title={ __( 'Has styles', 'elementor' ) } placement="top">
|
|
44
36
|
<Stack direction="row" sx={ { '& > *': { marginInlineStart: -0.25 } } } role="list">
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
37
|
+
{ hasValues && provider && (
|
|
38
|
+
<StyleIndicator
|
|
39
|
+
getColor={ getStylesProviderThemeColor( provider.getKey() ) }
|
|
40
|
+
data-variant={ isElementsStylesProvider( provider.getKey() ) ? 'local' : 'global' }
|
|
41
|
+
role="listitem"
|
|
42
|
+
aria-label={ hasValueLabel }
|
|
43
|
+
/>
|
|
44
|
+
) }
|
|
45
|
+
{ hasOverrides && (
|
|
46
|
+
<StyleIndicator
|
|
47
|
+
isOverridden
|
|
48
|
+
data-variant="overridden"
|
|
49
|
+
role="listitem"
|
|
50
|
+
aria-label={ hasOverridesLabel }
|
|
51
|
+
/>
|
|
56
52
|
) }
|
|
57
53
|
</Stack>
|
|
58
54
|
</Tooltip>
|
|
@@ -63,8 +59,9 @@ function getIndicators(
|
|
|
63
59
|
snapshotFields: Record< PropKey, SnapshotPropValue[] >,
|
|
64
60
|
styleId: string,
|
|
65
61
|
meta: StyleDefinitionVariant[ 'meta' ]
|
|
66
|
-
):
|
|
67
|
-
|
|
62
|
+
): { hasValues: boolean; hasOverrides: boolean } {
|
|
63
|
+
let hasValues = false;
|
|
64
|
+
let hasOverrides = false;
|
|
68
65
|
|
|
69
66
|
Object.values( snapshotFields ).forEach( ( inheritanceChain ) => {
|
|
70
67
|
const currentStyle = getCurrentStyleFromChain( inheritanceChain, styleId, meta );
|
|
@@ -76,25 +73,13 @@ function getIndicators(
|
|
|
76
73
|
const [ actualStyle ] = inheritanceChain;
|
|
77
74
|
|
|
78
75
|
if ( currentStyle === actualStyle ) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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;
|
|
76
|
+
hasValues = true;
|
|
77
|
+
} else {
|
|
78
|
+
hasOverrides = true;
|
|
92
79
|
}
|
|
93
|
-
|
|
94
|
-
indicators.overridden = true;
|
|
95
80
|
} );
|
|
96
81
|
|
|
97
|
-
return
|
|
82
|
+
return { hasValues, hasOverrides };
|
|
98
83
|
}
|
|
99
84
|
|
|
100
85
|
function getCurrentStyleFromChain(
|
|
@@ -5,7 +5,7 @@ import { type StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
|
5
5
|
import { ELEMENTS_BASE_STYLES_PROVIDER_KEY } from '@elementor/editor-styles-repository';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
|
|
8
|
-
import { type
|
|
8
|
+
import { type SnapshotPropValue } from '../types';
|
|
9
9
|
|
|
10
10
|
const MAXIMUM_ITEMS = 2;
|
|
11
11
|
|
|
@@ -15,7 +15,6 @@ type NormalizedItem = {
|
|
|
15
15
|
breakpoint?: StyleDefinitionVariant[ 'meta' ][ 'breakpoint' ];
|
|
16
16
|
displayLabel: string;
|
|
17
17
|
value: ReactNode | string;
|
|
18
|
-
chipColor: ChipColors;
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
export const useNormalizedInheritanceChainItems = (
|
|
@@ -74,7 +73,6 @@ export const normalizeInheritanceItem = async (
|
|
|
74
73
|
breakpoint: breakpoint ?? DEFAULT_BREAKPOINT,
|
|
75
74
|
displayLabel,
|
|
76
75
|
value: await getTransformedValue( item, bind, resolve ),
|
|
77
|
-
chipColor: getChipColor( item ),
|
|
78
76
|
};
|
|
79
77
|
};
|
|
80
78
|
|
|
@@ -105,17 +103,3 @@ const getTransformedValue = async (
|
|
|
105
103
|
return '';
|
|
106
104
|
}
|
|
107
105
|
};
|
|
108
|
-
|
|
109
|
-
const getChipColor = ( item: SnapshotPropValue ) => {
|
|
110
|
-
const { provider = '', style } = item;
|
|
111
|
-
|
|
112
|
-
if ( provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY ) {
|
|
113
|
-
return 'default';
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if ( style?.label === 'local' ) {
|
|
117
|
-
return 'accent';
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return 'global';
|
|
121
|
-
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type BreakpointId } from '@elementor/editor-responsive';
|
|
2
|
-
import { type StyleDefinitionState } from '@elementor/editor-styles';
|
|
2
|
+
import { type StyleDefinitionState, type StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
3
|
+
|
|
4
|
+
import { type SnapshotPropValue } from './types';
|
|
3
5
|
|
|
4
6
|
export const DEFAULT_STATE = 'normal';
|
|
5
7
|
|
|
@@ -8,3 +10,17 @@ const DEFAULT_BREAKPOINT = 'desktop';
|
|
|
8
10
|
export const getStateKey = ( state: StyleDefinitionState ) => state ?? DEFAULT_STATE;
|
|
9
11
|
|
|
10
12
|
export const getBreakpointKey = ( breakpoint: BreakpointId | null ): BreakpointId => breakpoint ?? DEFAULT_BREAKPOINT;
|
|
13
|
+
|
|
14
|
+
export const getValueFromInheritanceChain = (
|
|
15
|
+
inheritanceChain: SnapshotPropValue[],
|
|
16
|
+
styleId: string,
|
|
17
|
+
meta: StyleDefinitionVariant[ 'meta' ]
|
|
18
|
+
) =>
|
|
19
|
+
inheritanceChain.find(
|
|
20
|
+
( {
|
|
21
|
+
style,
|
|
22
|
+
variant: {
|
|
23
|
+
meta: { breakpoint, state },
|
|
24
|
+
},
|
|
25
|
+
} ) => style.id === styleId && breakpoint === meta.breakpoint && state === meta.state
|
|
26
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ELEMENTS_BASE_STYLES_PROVIDER_KEY, isElementsStylesProvider } from '@elementor/editor-styles-repository';
|
|
2
|
+
import { type ChipProps, type Theme } from '@elementor/ui';
|
|
3
|
+
|
|
4
|
+
import { getStyleProviderColors } from '../provider-colors-registry';
|
|
5
|
+
|
|
6
|
+
export const getStylesProviderColorName = ( provider: string ): ChipProps[ 'color' ] => {
|
|
7
|
+
if ( ! provider || provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY ) {
|
|
8
|
+
return 'default';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if ( isElementsStylesProvider( provider ) ) {
|
|
12
|
+
return 'accent';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return getStyleProviderColors( provider ).name;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const getStylesProviderThemeColor = ( provider: string ): ( ( theme: Theme ) => string ) | null => {
|
|
19
|
+
if ( ! provider || provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY ) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if ( isElementsStylesProvider( provider ) ) {
|
|
24
|
+
return ( theme: Theme ) => theme.palette.accent.main;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return getStyleProviderColors( provider ).getThemeColor;
|
|
28
|
+
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type FC, type PropsWithChildren } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { Stack } from '@elementor/ui';
|
|
4
|
-
|
|
5
|
-
type PopoverContentProps = PropsWithChildren< {
|
|
6
|
-
alignItems?: 'center';
|
|
7
|
-
gap?: number;
|
|
8
|
-
p?: 1.5 | 2 | 2.5;
|
|
9
|
-
} >;
|
|
10
|
-
|
|
11
|
-
export const PopoverContent: FC< PopoverContentProps > = ( { alignItems, gap = 1.5, p, children } ) => (
|
|
12
|
-
<Stack alignItems={ alignItems } gap={ gap } p={ p }>
|
|
13
|
-
{ children }
|
|
14
|
-
</Stack>
|
|
15
|
-
);
|