@elementor/editor-editing-panel 1.48.0 → 3.32.0-20
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 +21 -0
- package/dist/index.d.mts +78 -47
- package/dist/index.d.ts +78 -47
- package/dist/index.js +1770 -1406
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1550 -1157
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/components/css-classes/css-class-convert-local.tsx +77 -0
- package/src/components/css-classes/css-class-item.tsx +18 -3
- package/src/components/css-classes/css-class-menu.tsx +10 -3
- package/src/components/css-classes/css-class-selector.tsx +10 -2
- package/src/components/css-classes/local-class-sub-menu.tsx +23 -0
- package/src/components/css-classes/use-apply-and-unapply-class.ts +7 -50
- package/src/components/css-classes/use-can-convert-local-class-to-global.ts +22 -0
- package/src/components/custom-css.tsx +21 -0
- package/src/components/editing-panel-tabs.tsx +1 -5
- package/src/components/popover-body.tsx +12 -0
- package/src/components/section.tsx +1 -5
- package/src/components/settings-tab.tsx +6 -15
- package/src/components/style-sections/effects-section/effects-section.tsx +32 -19
- package/src/components/style-sections/layout-section/display-field.tsx +11 -20
- package/src/components/style-sections/layout-section/flex-order-field.tsx +6 -1
- package/src/components/style-sections/layout-section/flex-size-field.tsx +86 -52
- package/src/components/style-sections/position-section/offset-field.tsx +2 -2
- package/src/components/style-sections/position-section/position-section.tsx +2 -8
- package/src/components/style-sections/size-section/size-section.tsx +16 -31
- package/src/components/style-sections/typography-section/typography-section.tsx +2 -19
- package/src/components/style-tab-collapsible-content.tsx +1 -5
- package/src/components/style-tab-section.tsx +1 -5
- package/src/components/style-tab.tsx +15 -2
- package/src/controls-actions.ts +1 -1
- package/src/controls-registry/conditional-field.tsx +26 -0
- package/src/controls-registry/control.tsx +2 -2
- package/src/controls-registry/controls-registry.tsx +44 -3
- package/src/controls-registry/settings-field.tsx +33 -45
- package/src/controls-registry/styles-field.tsx +14 -14
- package/src/dynamics/components/dynamic-selection-control.tsx +24 -16
- package/src/dynamics/components/dynamic-selection.tsx +32 -36
- package/src/errors.ts +10 -0
- package/src/hooks/use-custom-css.ts +184 -0
- package/src/hooks/use-state-by-element.ts +1 -4
- package/src/hooks/use-styles-fields.ts +129 -106
- package/src/index.ts +9 -10
- package/src/init.ts +2 -5
- package/src/popover-action.tsx +36 -15
- package/src/reset-style-props.tsx +2 -6
- package/src/styles-inheritance/components/infotip/value-component.tsx +1 -0
- package/src/styles-inheritance/components/styles-inheritance-indicator.tsx +6 -23
- package/src/styles-inheritance/components/styles-inheritance-infotip.tsx +18 -9
- package/src/styles-inheritance/consts.ts +0 -4
- package/src/styles-inheritance/init.ts +1 -4
- package/src/styles-inheritance/transformers/background-color-overlay-transformer.tsx +5 -1
- package/src/styles-inheritance/transformers/background-gradient-overlay-transformer.tsx +3 -3
- package/src/styles-inheritance/transformers/background-image-overlay-transformer.tsx +2 -1
- package/src/utils/get-styles-provider-color.ts +8 -0
- package/src/utils/prop-dependency-utils.ts +156 -0
- package/src/components/popover-scrollable-content.tsx +0 -12
- package/src/components/style-sections/size-section/object-position-field.tsx +0 -15
- package/src/sync/experiments-flags.ts +0 -5
- /package/src/components/style-sections/{layout-section → effects-section}/opacity-control-field.tsx +0 -0
|
@@ -7,7 +7,7 @@ export type Color = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export const backgroundColorOverlayTransformer = createTransformer( ( value: Color ) => (
|
|
10
|
-
<Stack direction="row" gap={
|
|
10
|
+
<Stack direction="row" gap={ 1 } alignItems="center">
|
|
11
11
|
<ItemIconColor value={ value } />
|
|
12
12
|
<ItemLabelColor value={ value } />
|
|
13
13
|
</Stack>
|
|
@@ -23,5 +23,9 @@ const ItemLabelColor = ( { value: { color } }: { value: Color } ) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export const StyledUnstableColorIndicator = styled( UnstableColorIndicator )( ( { theme } ) => ( {
|
|
26
|
+
width: '1em',
|
|
27
|
+
height: '1em',
|
|
26
28
|
borderRadius: `${ theme.shape.borderRadius / 2 }px`,
|
|
29
|
+
outline: `1px solid ${ theme.palette.action.disabled }`,
|
|
30
|
+
flexShrink: 0,
|
|
27
31
|
} ) );
|
|
@@ -17,7 +17,7 @@ type Gradient = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const backgroundGradientOverlayTransformer = createTransformer( ( value: Gradient ) => (
|
|
20
|
-
<Stack direction="row" gap={
|
|
20
|
+
<Stack direction="row" gap={ 1 } alignItems="center">
|
|
21
21
|
<ItemIconGradient value={ value } />
|
|
22
22
|
<ItemLabelGradient value={ value } />
|
|
23
23
|
</Stack>
|
|
@@ -31,10 +31,10 @@ const ItemIconGradient = ( { value }: { value: Gradient } ) => {
|
|
|
31
31
|
|
|
32
32
|
const ItemLabelGradient = ( { value }: { value: Gradient } ) => {
|
|
33
33
|
if ( value.type === 'linear' ) {
|
|
34
|
-
return <span>{ __( 'Linear
|
|
34
|
+
return <span>{ __( 'Linear gradient', 'elementor' ) }</span>;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
return <span>{ __( 'Radial
|
|
37
|
+
return <span>{ __( 'Radial gradient', 'elementor' ) }</span>;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const getGradientValue = ( gradient: Gradient ) => {
|
|
@@ -16,7 +16,7 @@ type Image = {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export const backgroundImageOverlayTransformer = createTransformer( ( value: Image ) => (
|
|
19
|
-
<Stack direction="row" gap={
|
|
19
|
+
<Stack direction="row" gap={ 1 } alignItems="center">
|
|
20
20
|
<ItemIconImage value={ value } />
|
|
21
21
|
<ItemLabelImage value={ value } />
|
|
22
22
|
</Stack>
|
|
@@ -33,6 +33,7 @@ const ItemIconImage = ( { value }: { value: Image } ) => {
|
|
|
33
33
|
width: '1em',
|
|
34
34
|
borderRadius: `${ theme.shape.borderRadius / 2 }px`,
|
|
35
35
|
outline: `1px solid ${ theme.palette.action.disabled }`,
|
|
36
|
+
flexShrink: 0,
|
|
36
37
|
} ) }
|
|
37
38
|
/>
|
|
38
39
|
);
|
|
@@ -26,3 +26,11 @@ export const getStylesProviderThemeColor = ( provider: string ): ( ( theme: Them
|
|
|
26
26
|
|
|
27
27
|
return getStyleProviderColors( provider ).getThemeColor;
|
|
28
28
|
};
|
|
29
|
+
|
|
30
|
+
export function getTempStylesProviderThemeColor( provider: string ): ( ( theme: Theme ) => string ) | null {
|
|
31
|
+
if ( isElementsStylesProvider( provider ) ) {
|
|
32
|
+
return ( theme: Theme ) => theme.palette.primary.main;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return getStylesProviderThemeColor( provider );
|
|
36
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractValue,
|
|
3
|
+
isDependencyMet,
|
|
4
|
+
type PropsSchema,
|
|
5
|
+
type PropType,
|
|
6
|
+
type TransformablePropValue,
|
|
7
|
+
} from '@elementor/editor-props';
|
|
8
|
+
|
|
9
|
+
type Value = TransformablePropValue< string > | null;
|
|
10
|
+
|
|
11
|
+
export type Values = Record< string, Value >;
|
|
12
|
+
|
|
13
|
+
export function extractOrderedDependencies(
|
|
14
|
+
bind: string,
|
|
15
|
+
propsSchema: PropsSchema,
|
|
16
|
+
elementValues: Values,
|
|
17
|
+
dependenciesPerTargetMapping: Record< string, string[] >
|
|
18
|
+
): string[] {
|
|
19
|
+
const prop = getPropType( propsSchema, elementValues, bind.split( '.' ) );
|
|
20
|
+
|
|
21
|
+
if ( ! prop ) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const dependencies: string[] = [];
|
|
26
|
+
|
|
27
|
+
if ( 'object' === prop.kind ) {
|
|
28
|
+
dependencies.push( ...Object.keys( prop.shape ).map( ( key ) => bind + '.' + key ) );
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const directDependencies = extractPropOrderedDependencies( bind, dependenciesPerTargetMapping );
|
|
32
|
+
|
|
33
|
+
if ( ! dependencies.length ) {
|
|
34
|
+
return directDependencies;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return dependencies.reduce(
|
|
38
|
+
( carry, dependency ) => [
|
|
39
|
+
...carry,
|
|
40
|
+
...extractOrderedDependencies( dependency, propsSchema, elementValues, dependenciesPerTargetMapping ),
|
|
41
|
+
],
|
|
42
|
+
directDependencies
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function extractPropOrderedDependencies(
|
|
47
|
+
bind: string,
|
|
48
|
+
dependenciesPerTargetMapping: Record< string, string[] >
|
|
49
|
+
): string[] {
|
|
50
|
+
if ( ! dependenciesPerTargetMapping?.[ bind ]?.length ) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return dependenciesPerTargetMapping[ bind ].reduce< string[] >(
|
|
55
|
+
( dependencies, dependency ) => [
|
|
56
|
+
...dependencies,
|
|
57
|
+
dependency,
|
|
58
|
+
...extractPropOrderedDependencies( dependency, dependenciesPerTargetMapping ),
|
|
59
|
+
],
|
|
60
|
+
[]
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function updateValues(
|
|
65
|
+
values: Values,
|
|
66
|
+
dependencies: string[],
|
|
67
|
+
propsSchema: PropsSchema,
|
|
68
|
+
elementValues: Values
|
|
69
|
+
): Values {
|
|
70
|
+
if ( ! dependencies.length ) {
|
|
71
|
+
return values;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return dependencies.reduce(
|
|
75
|
+
( newValues, dependency ) => {
|
|
76
|
+
const path = dependency.split( '.' );
|
|
77
|
+
const propType = getPropType( propsSchema, elementValues, path );
|
|
78
|
+
const combinedValues = { ...elementValues, ...newValues };
|
|
79
|
+
|
|
80
|
+
if ( ! propType ) {
|
|
81
|
+
return newValues;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if ( ! isDependencyMet( propType?.dependencies, combinedValues ) ) {
|
|
85
|
+
return {
|
|
86
|
+
...newValues,
|
|
87
|
+
...updateValue( path, null, combinedValues ),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return newValues;
|
|
92
|
+
},
|
|
93
|
+
{ ...values }
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getPropType( schema: PropsSchema, elementValues: Values, path: string[] ): PropType | null {
|
|
98
|
+
if ( ! path.length ) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const [ basePropKey, ...keys ] = path;
|
|
103
|
+
const baseProp = schema[ basePropKey ];
|
|
104
|
+
|
|
105
|
+
if ( ! baseProp ) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return keys.reduce( ( prop: PropType | null, key, index ) => {
|
|
110
|
+
if ( ! prop?.kind ) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if ( 'union' === prop.kind ) {
|
|
115
|
+
const value = extractValue( path.slice( 0, index + 1 ), elementValues );
|
|
116
|
+
const type = ( value?.$$type as string ) ?? null;
|
|
117
|
+
|
|
118
|
+
return getPropType(
|
|
119
|
+
{ [ basePropKey ]: prop.prop_types?.[ type ] },
|
|
120
|
+
elementValues,
|
|
121
|
+
path.slice( 0, index + 2 )
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if ( 'array' === prop.kind ) {
|
|
126
|
+
return prop.item_prop_type;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if ( 'object' === prop.kind ) {
|
|
130
|
+
return prop.shape[ key ];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return prop[ key as keyof typeof prop ] as PropType;
|
|
134
|
+
}, baseProp );
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function updateValue( path: string[], value: Value, values: Values ) {
|
|
138
|
+
const topPropKey = path[ 0 ];
|
|
139
|
+
const newValue: Values = { ...values };
|
|
140
|
+
|
|
141
|
+
path.reduce( ( carry: Values | null, key, index ) => {
|
|
142
|
+
if ( ! carry ) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if ( index === path.length - 1 ) {
|
|
147
|
+
carry[ key ] = value !== null ? ( { ...( carry[ key ] ?? {} ), value } as Value ) : null;
|
|
148
|
+
|
|
149
|
+
return ( carry[ key ]?.value as Values ) ?? carry.value;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return ( carry[ key ]?.value as Values ) ?? carry.value;
|
|
153
|
+
}, newValue );
|
|
154
|
+
|
|
155
|
+
return { [ topPropKey ]: newValue[ topPropKey ] ?? null };
|
|
156
|
+
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { PopoverScrollableContent as BasePopoverScrollableContent } from '@elementor/editor-ui';
|
|
3
|
-
|
|
4
|
-
import { useSectionWidth } from '../contexts/section-context';
|
|
5
|
-
|
|
6
|
-
type Props = React.ComponentProps< typeof BasePopoverScrollableContent >;
|
|
7
|
-
|
|
8
|
-
export const PopoverScrollableContent = ( props: Props ) => {
|
|
9
|
-
const sectionWidth = useSectionWidth();
|
|
10
|
-
|
|
11
|
-
return <BasePopoverScrollableContent { ...props } width={ sectionWidth } />;
|
|
12
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { PositionControl } from '@elementor/editor-controls';
|
|
3
|
-
import { __ } from '@wordpress/i18n';
|
|
4
|
-
|
|
5
|
-
import { StylesField } from '../../../controls-registry/styles-field';
|
|
6
|
-
|
|
7
|
-
const OBJECT_POSITION_LABEL = __( 'Object position', 'elementor' );
|
|
8
|
-
|
|
9
|
-
export const ObjectPositionField = () => {
|
|
10
|
-
return (
|
|
11
|
-
<StylesField bind="object-position" propDisplayName={ OBJECT_POSITION_LABEL }>
|
|
12
|
-
<PositionControl />
|
|
13
|
-
</StylesField>
|
|
14
|
-
);
|
|
15
|
-
};
|
/package/src/components/style-sections/{layout-section → effects-section}/opacity-control-field.tsx
RENAMED
|
File without changes
|