@elementor/editor-editing-panel 1.41.0 → 1.42.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 +14 -0
- package/dist/index.js +108 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +128 -79
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/style-sections/size-section/object-fit-field.tsx +2 -6
- package/src/components/style-sections/size-section/object-position-field.tsx +2 -6
- package/src/components/style-sections/size-section/size-section.tsx +4 -10
- package/src/styles-inheritance/components/label-chip.tsx +14 -9
- package/src/styles-inheritance/consts.ts +1 -1
- package/src/styles-inheritance/hooks/use-normalized-inheritance-chain-items.tsx +17 -1
- package/src/styles-inheritance/styles-inheritance-infotip.tsx +142 -87
- package/src/styles-inheritance/types.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-editing-panel",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@elementor/editor": "0.19.4",
|
|
43
43
|
"@elementor/editor-canvas": "0.22.2",
|
|
44
|
-
"@elementor/editor-controls": "0.34.
|
|
44
|
+
"@elementor/editor-controls": "0.34.1",
|
|
45
45
|
"@elementor/editor-current-user": "0.5.0",
|
|
46
46
|
"@elementor/editor-documents": "0.13.6",
|
|
47
47
|
"@elementor/editor-elements": "0.8.4",
|
|
@@ -14,11 +14,7 @@ const positionOptions = [
|
|
|
14
14
|
{ label: __( 'Scale down', 'elementor' ), value: 'scale-down' },
|
|
15
15
|
];
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
onChange?: ( newValue: string | null, previousValue: string | null | undefined ) => void;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const ObjectFitField = ( { onChange }: Props ) => {
|
|
17
|
+
export const ObjectFitField = () => {
|
|
22
18
|
return (
|
|
23
19
|
<StylesField bind="object-fit">
|
|
24
20
|
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
@@ -26,7 +22,7 @@ export const ObjectFitField = ( { onChange }: Props ) => {
|
|
|
26
22
|
<ControlLabel>{ __( 'Object fit', 'elementor' ) }</ControlLabel>
|
|
27
23
|
</Grid>
|
|
28
24
|
<Grid item xs={ 6 } sx={ { overflow: 'hidden' } }>
|
|
29
|
-
<SelectControl options={ positionOptions }
|
|
25
|
+
<SelectControl options={ positionOptions } />
|
|
30
26
|
</Grid>
|
|
31
27
|
</Grid>
|
|
32
28
|
</StylesField>
|
|
@@ -18,11 +18,7 @@ const positionOptions = [
|
|
|
18
18
|
{ label: __( 'Bottom right', 'elementor' ), value: 'bottom right' },
|
|
19
19
|
];
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
onChange?: ( newValue: string | null, previousValue: string | null | undefined ) => void;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const ObjectPositionField = ( { onChange }: Props ) => {
|
|
21
|
+
export const ObjectPositionField = () => {
|
|
26
22
|
return (
|
|
27
23
|
<StylesField bind="object-position">
|
|
28
24
|
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
@@ -30,7 +26,7 @@ export const ObjectPositionField = ( { onChange }: Props ) => {
|
|
|
30
26
|
<ControlLabel>{ __( 'Object position', 'elementor' ) }</ControlLabel>
|
|
31
27
|
</Grid>
|
|
32
28
|
<Grid item xs={ 6 } sx={ { overflow: 'hidden' } }>
|
|
33
|
-
<SelectControl options={ positionOptions }
|
|
29
|
+
<SelectControl options={ positionOptions } />
|
|
34
30
|
</Grid>
|
|
35
31
|
</Grid>
|
|
36
32
|
</StylesField>
|
|
@@ -16,18 +16,12 @@ import { ObjectPositionField } from './object-position-field';
|
|
|
16
16
|
import { OverflowField } from './overflow-field';
|
|
17
17
|
|
|
18
18
|
export const SizeSection = () => {
|
|
19
|
-
const [ fitValue
|
|
19
|
+
const [ fitValue ] = useStylesField< StringPropValue >( 'object-fit' );
|
|
20
|
+
|
|
20
21
|
const isNotFill = fitValue && fitValue?.value !== 'fill';
|
|
21
22
|
|
|
22
|
-
const onFitChange = ( newFit: string | null, previousValue: string | null | undefined ) => {
|
|
23
|
-
if ( newFit && newFit !== previousValue ) {
|
|
24
|
-
setFitValue( {
|
|
25
|
-
value: newFit,
|
|
26
|
-
$$type: 'string',
|
|
27
|
-
} );
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
23
|
const isVersion330Active = isExperimentActive( 'e_v_3_30' );
|
|
24
|
+
|
|
31
25
|
return (
|
|
32
26
|
<SectionContent>
|
|
33
27
|
<Grid container gap={ 2 } flexWrap="nowrap">
|
|
@@ -73,7 +67,7 @@ export const SizeSection = () => {
|
|
|
73
67
|
<AspectRatioControl label={ __( 'Aspect Ratio', 'elementor' ) } />
|
|
74
68
|
</StylesField>
|
|
75
69
|
<PanelDivider />
|
|
76
|
-
<ObjectFitField
|
|
70
|
+
<ObjectFitField />
|
|
77
71
|
{ isNotFill && (
|
|
78
72
|
<Grid item xs={ 6 }>
|
|
79
73
|
<ObjectPositionField />
|
|
@@ -4,28 +4,33 @@ 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';
|
|
8
|
+
|
|
7
9
|
type Props = {
|
|
8
10
|
displayLabel: string;
|
|
9
11
|
provider?: string;
|
|
12
|
+
chipColor: ChipColors;
|
|
10
13
|
};
|
|
11
14
|
|
|
12
15
|
const SIZE = 'tiny';
|
|
13
16
|
|
|
14
|
-
export const LabelChip = ( { displayLabel, provider }: Props ) => {
|
|
17
|
+
export const LabelChip = ( { displayLabel, provider, chipColor }: Props ) => {
|
|
18
|
+
const isBaseStyle = provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY;
|
|
19
|
+
|
|
20
|
+
const chipIcon = isBaseStyle ? (
|
|
21
|
+
<Tooltip title={ __( 'Inherited from base styles', 'elementor' ) } placement="top">
|
|
22
|
+
<InfoCircleIcon fontSize={ SIZE } />
|
|
23
|
+
</Tooltip>
|
|
24
|
+
) : undefined;
|
|
25
|
+
|
|
15
26
|
return (
|
|
16
27
|
<Chip
|
|
17
28
|
label={ displayLabel }
|
|
18
29
|
size={ SIZE }
|
|
19
|
-
color=
|
|
30
|
+
color={ chipColor }
|
|
20
31
|
variant="standard"
|
|
21
32
|
state="enabled"
|
|
22
|
-
icon={
|
|
23
|
-
provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY ? (
|
|
24
|
-
<Tooltip title={ __( 'Inherited from base styles', 'elementor' ) } placement="top">
|
|
25
|
-
<InfoCircleIcon fontSize={ SIZE } />
|
|
26
|
-
</Tooltip>
|
|
27
|
-
) : undefined
|
|
28
|
-
}
|
|
33
|
+
icon={ chipIcon }
|
|
29
34
|
sx={ ( theme: Theme ) => ( {
|
|
30
35
|
lineHeight: 1,
|
|
31
36
|
flexWrap: 'nowrap',
|
|
@@ -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 SnapshotPropValue } from '../types';
|
|
8
|
+
import { type ChipColors, type SnapshotPropValue } from '../types';
|
|
9
9
|
|
|
10
10
|
const MAXIMUM_ITEMS = 2;
|
|
11
11
|
|
|
@@ -15,6 +15,7 @@ type NormalizedItem = {
|
|
|
15
15
|
breakpoint?: StyleDefinitionVariant[ 'meta' ][ 'breakpoint' ];
|
|
16
16
|
displayLabel: string;
|
|
17
17
|
value: ReactNode | string;
|
|
18
|
+
chipColor: ChipColors;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
export const useNormalizedInheritanceChainItems = (
|
|
@@ -73,6 +74,7 @@ export const normalizeInheritanceItem = async (
|
|
|
73
74
|
breakpoint: breakpoint ?? DEFAULT_BREAKPOINT,
|
|
74
75
|
displayLabel,
|
|
75
76
|
value: await getTransformedValue( item, bind, resolve ),
|
|
77
|
+
chipColor: getChipColor( item ),
|
|
76
78
|
};
|
|
77
79
|
};
|
|
78
80
|
|
|
@@ -103,3 +105,17 @@ const getTransformedValue = async (
|
|
|
103
105
|
return '';
|
|
104
106
|
}
|
|
105
107
|
};
|
|
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
|
+
};
|
|
@@ -2,7 +2,20 @@ import * as React from 'react';
|
|
|
2
2
|
import { useMemo, useState } from 'react';
|
|
3
3
|
import { createPropsResolver, type PropsResolver } from '@elementor/editor-canvas';
|
|
4
4
|
import { type PropKey, type PropType } from '@elementor/editor-props';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Backdrop,
|
|
7
|
+
Box,
|
|
8
|
+
Card,
|
|
9
|
+
CardContent,
|
|
10
|
+
ClickAwayListener,
|
|
11
|
+
CloseButton,
|
|
12
|
+
IconButton,
|
|
13
|
+
Infotip,
|
|
14
|
+
Stack,
|
|
15
|
+
type Theme,
|
|
16
|
+
Tooltip,
|
|
17
|
+
Typography,
|
|
18
|
+
} from '@elementor/ui';
|
|
6
19
|
import { __ } from '@wordpress/i18n';
|
|
7
20
|
|
|
8
21
|
import { useSectionContentRef } from '../components/section-content';
|
|
@@ -23,8 +36,10 @@ type Props = {
|
|
|
23
36
|
const SIZE = 'tiny';
|
|
24
37
|
|
|
25
38
|
export const StyleIndicatorInfotip = ( { inheritanceChain, propType, path, label, children }: Props ) => {
|
|
26
|
-
const [
|
|
27
|
-
const
|
|
39
|
+
const [ showInfotip, setShowInfotip ] = useState< boolean >( false );
|
|
40
|
+
const toggleInfotip = () => setShowInfotip( ( prev ) => ! prev );
|
|
41
|
+
const closeInfotip = () => setShowInfotip( false );
|
|
42
|
+
|
|
28
43
|
const key = path.join( '.' );
|
|
29
44
|
|
|
30
45
|
const sectionContentRef = useSectionContentRef();
|
|
@@ -39,99 +54,139 @@ export const StyleIndicatorInfotip = ( { inheritanceChain, propType, path, label
|
|
|
39
54
|
|
|
40
55
|
const items = useNormalizedInheritanceChainItems( inheritanceChain, key, resolve );
|
|
41
56
|
|
|
42
|
-
const toggleOpen = () => setOpen( ( prev ) => ! prev );
|
|
43
|
-
const closeInfotip = () => {
|
|
44
|
-
setOpen( false );
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const forceInfotipAlignLeft = isSiteRtl ? 9999999 : -9999999;
|
|
48
|
-
|
|
49
57
|
const infotipContent = (
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
width: `${ sectionContentWidth }px`,
|
|
54
|
-
maxWidth: 500,
|
|
55
|
-
overflowX: 'hidden',
|
|
56
|
-
} }
|
|
57
|
-
>
|
|
58
|
-
<CardContent
|
|
58
|
+
<ClickAwayListener onClickAway={ closeInfotip }>
|
|
59
|
+
<Card
|
|
60
|
+
elevation={ 0 }
|
|
59
61
|
sx={ {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
p: 0,
|
|
64
|
-
'&:last-child': {
|
|
65
|
-
pb: 0,
|
|
66
|
-
},
|
|
62
|
+
width: `${ sectionContentWidth }px`,
|
|
63
|
+
maxWidth: 500,
|
|
64
|
+
overflowX: 'hidden',
|
|
67
65
|
} }
|
|
68
66
|
>
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
67
|
+
<CardContent
|
|
68
|
+
sx={ {
|
|
69
|
+
display: 'flex',
|
|
70
|
+
gap: 0.5,
|
|
71
|
+
flexDirection: 'column',
|
|
72
|
+
p: 0,
|
|
73
|
+
'&:last-child': {
|
|
74
|
+
pb: 0,
|
|
75
|
+
},
|
|
76
|
+
} }
|
|
77
|
+
>
|
|
78
|
+
<Stack direction="row" alignItems="center" sx={ { pl: 1.5, pr: 0.5, minHeight: 36, py: 0.5 } }>
|
|
79
|
+
<Typography variant="subtitle2" color="secondary" sx={ { fontSize: 12, fontWeight: '500' } }>
|
|
80
|
+
{ __( 'Style origin', 'elementor' ) }
|
|
81
|
+
</Typography>
|
|
82
|
+
<CloseButton
|
|
83
|
+
slotProps={ { icon: { fontSize: SIZE } } }
|
|
84
|
+
sx={ { ml: 'auto' } }
|
|
85
|
+
onClick={ closeInfotip }
|
|
86
|
+
/>
|
|
87
|
+
</Stack>
|
|
88
|
+
<Stack
|
|
89
|
+
gap={ 1.5 }
|
|
90
|
+
sx={ { pl: 2, pr: 1, pb: 2, overflowX: 'hidden', overflowY: 'auto' } }
|
|
91
|
+
role="list"
|
|
92
|
+
>
|
|
93
|
+
{ items.map( ( item, index ) => {
|
|
94
|
+
return (
|
|
95
|
+
<Box
|
|
96
|
+
key={ item.id }
|
|
97
|
+
display="flex"
|
|
98
|
+
gap={ 0.5 }
|
|
99
|
+
role="listitem"
|
|
100
|
+
/* translators: %s: Label of the inheritance item */
|
|
101
|
+
aria-label={ __( 'Inheritance item: %s', 'elementor' ).replace(
|
|
102
|
+
'%s',
|
|
103
|
+
item.displayLabel
|
|
104
|
+
) }
|
|
105
|
+
>
|
|
106
|
+
<Box display="flex" gap={ 0.5 } sx={ { flexWrap: 'wrap', width: '100%' } }>
|
|
107
|
+
<BreakpointIcon breakpoint={ item.breakpoint } />
|
|
108
|
+
<LabelChip
|
|
109
|
+
displayLabel={ item.displayLabel }
|
|
110
|
+
provider={ item.provider }
|
|
111
|
+
chipColor={ item.chipColor }
|
|
112
|
+
/>
|
|
113
|
+
<ValueComponent index={ index } value={ item.value } />
|
|
114
|
+
</Box>
|
|
115
|
+
<ActionIcons />
|
|
97
116
|
</Box>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
</Card>
|
|
117
|
+
);
|
|
118
|
+
} ) }
|
|
119
|
+
</Stack>
|
|
120
|
+
</CardContent>
|
|
121
|
+
</Card>
|
|
122
|
+
</ClickAwayListener>
|
|
105
123
|
);
|
|
106
124
|
|
|
107
125
|
return (
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
content={ infotipContent }
|
|
111
|
-
open={ open }
|
|
112
|
-
onClose={ closeInfotip }
|
|
113
|
-
disableHoverListener={ true }
|
|
114
|
-
componentsProps={ {
|
|
115
|
-
tooltip: {
|
|
116
|
-
sx: {
|
|
117
|
-
mx: 2,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
} }
|
|
121
|
-
slotProps={ {
|
|
122
|
-
popper: {
|
|
123
|
-
modifiers: [
|
|
124
|
-
{
|
|
125
|
-
name: 'offset',
|
|
126
|
-
options: { offset: [ forceInfotipAlignLeft, 0 ] },
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
},
|
|
130
|
-
} }
|
|
131
|
-
>
|
|
132
|
-
<IconButton onClick={ toggleOpen } aria-label={ label } sx={ { my: '-1px' } }>
|
|
126
|
+
<TooltipOrInfotip showInfotip={ showInfotip } onClose={ closeInfotip } infotipContent={ infotipContent }>
|
|
127
|
+
<IconButton onClick={ toggleInfotip } aria-label={ label } sx={ { my: '-1px' } }>
|
|
133
128
|
{ children }
|
|
134
129
|
</IconButton>
|
|
135
|
-
</
|
|
130
|
+
</TooltipOrInfotip>
|
|
136
131
|
);
|
|
137
132
|
};
|
|
133
|
+
|
|
134
|
+
function TooltipOrInfotip( {
|
|
135
|
+
children,
|
|
136
|
+
showInfotip,
|
|
137
|
+
onClose,
|
|
138
|
+
infotipContent,
|
|
139
|
+
}: {
|
|
140
|
+
children: React.ReactNode;
|
|
141
|
+
showInfotip: boolean;
|
|
142
|
+
onClose: () => void;
|
|
143
|
+
infotipContent: React.ReactNode;
|
|
144
|
+
} ) {
|
|
145
|
+
const { isSiteRtl } = useDirection();
|
|
146
|
+
const forceInfotipAlignLeft = isSiteRtl ? 9999999 : -9999999;
|
|
147
|
+
|
|
148
|
+
if ( showInfotip ) {
|
|
149
|
+
return (
|
|
150
|
+
<>
|
|
151
|
+
<Backdrop
|
|
152
|
+
open={ showInfotip }
|
|
153
|
+
onClick={ onClose }
|
|
154
|
+
sx={ {
|
|
155
|
+
backgroundColor: 'transparent',
|
|
156
|
+
zIndex: ( theme: Theme ) => theme.zIndex.modal - 1,
|
|
157
|
+
} }
|
|
158
|
+
/>
|
|
159
|
+
<Infotip
|
|
160
|
+
placement="top"
|
|
161
|
+
content={ infotipContent }
|
|
162
|
+
open={ showInfotip }
|
|
163
|
+
onClose={ onClose }
|
|
164
|
+
disableHoverListener
|
|
165
|
+
componentsProps={ {
|
|
166
|
+
tooltip: {
|
|
167
|
+
sx: { mx: 2 },
|
|
168
|
+
},
|
|
169
|
+
} }
|
|
170
|
+
slotProps={ {
|
|
171
|
+
popper: {
|
|
172
|
+
modifiers: [
|
|
173
|
+
{
|
|
174
|
+
name: 'offset',
|
|
175
|
+
options: { offset: [ forceInfotipAlignLeft, 0 ] },
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
} }
|
|
180
|
+
>
|
|
181
|
+
{ children }
|
|
182
|
+
</Infotip>
|
|
183
|
+
</>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<Tooltip title={ __( 'Style origin', 'elementor' ) } placement="top">
|
|
189
|
+
{ children }
|
|
190
|
+
</Tooltip>
|
|
191
|
+
);
|
|
192
|
+
}
|