@elementor/editor-editing-panel 1.41.0 → 1.43.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 +29 -0
- package/dist/index.js +257 -187
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +235 -153
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/components/css-classes/css-class-item.tsx +4 -2
- package/src/components/css-classes/css-class-menu.tsx +4 -4
- package/src/components/css-classes/css-class-selector.tsx +36 -57
- package/src/components/css-classes/use-apply-and-unapply-class.ts +82 -10
- 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
|
@@ -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
|
+
}
|