@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
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { isExperimentActive } from '@elementor/editor-v1-adapters';
|
|
3
2
|
import { getSessionStorageItem, setSessionStorageItem } from '@elementor/session';
|
|
4
3
|
|
|
5
4
|
import { useElement } from '../contexts/element-context';
|
|
6
|
-
import { EXPERIMENTAL_FEATURES } from '../sync/experiments-flags';
|
|
7
5
|
|
|
8
6
|
export const useStateByElement = < T >( key: string, initialValue: T ) => {
|
|
9
7
|
const { element } = useElement();
|
|
10
|
-
const isFeatureActive = isExperimentActive( EXPERIMENTAL_FEATURES.V_3_30 );
|
|
11
8
|
const lookup = `elementor/editor-state/${ element.id }/${ key }`;
|
|
12
|
-
const storedValue =
|
|
9
|
+
const storedValue = getSessionStorageItem< T >( lookup );
|
|
13
10
|
const [ value, setValue ] = useState( storedValue ?? initialValue );
|
|
14
11
|
|
|
15
12
|
const doUpdate = ( newValue: T ) => {
|
|
@@ -1,37 +1,43 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createElementStyle,
|
|
4
|
+
deleteElementStyle,
|
|
5
|
+
type ElementID,
|
|
6
|
+
getElementLabel,
|
|
7
|
+
shouldCreateNewLocalStyle,
|
|
8
|
+
} from '@elementor/editor-elements';
|
|
3
9
|
import type { Props } from '@elementor/editor-props';
|
|
4
10
|
import { getVariantByMeta, type StyleDefinition, type StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
5
11
|
import { isElementsStylesProvider, type StylesProvider } from '@elementor/editor-styles-repository';
|
|
6
12
|
import { ELEMENTS_STYLES_RESERVED_LABEL } from '@elementor/editor-styles-repository';
|
|
7
|
-
import {
|
|
13
|
+
import { undoable } from '@elementor/editor-v1-adapters';
|
|
8
14
|
import { __ } from '@wordpress/i18n';
|
|
9
15
|
|
|
10
16
|
import { useClassesProp } from '../contexts/classes-prop-context';
|
|
11
17
|
import { useElement } from '../contexts/element-context';
|
|
12
18
|
import { useStyle } from '../contexts/style-context';
|
|
13
19
|
import { StyleNotFoundUnderProviderError, StylesProviderCannotUpdatePropsError } from '../errors';
|
|
14
|
-
import { EXPERIMENTAL_FEATURES } from '../sync/experiments-flags';
|
|
15
20
|
import { useStylesRerender } from './use-styles-rerender';
|
|
16
21
|
|
|
22
|
+
export const HISTORY_DEBOUNCE_WAIT = 800;
|
|
23
|
+
|
|
17
24
|
export function useStylesFields< T extends Props >( propNames: ( keyof T & string )[] ) {
|
|
18
25
|
const {
|
|
19
26
|
element: { id: elementId },
|
|
20
27
|
} = useElement();
|
|
21
28
|
const { id: styleId, meta, provider, canEdit } = useStyle();
|
|
22
29
|
|
|
23
|
-
const undoableUpdateStyle =
|
|
24
|
-
const undoableCreateElementStyle = useUndoableCreateElementStyle( { elementId, meta } );
|
|
30
|
+
const undoableUpdateStyle = useUndoableActions( { elementId, meta } );
|
|
25
31
|
|
|
26
32
|
useStylesRerender();
|
|
27
33
|
|
|
28
34
|
const values = getProps< T >( { elementId, styleId, provider, meta, propNames } );
|
|
29
35
|
|
|
30
36
|
const setValues = ( props: T, { history: { propDisplayName } }: { history: { propDisplayName: string } } ) => {
|
|
31
|
-
if ( styleId
|
|
32
|
-
|
|
37
|
+
if ( ! styleId ) {
|
|
38
|
+
undoableUpdateStyle( { styleId: null, provider: null, props, propDisplayName } );
|
|
33
39
|
} else {
|
|
34
|
-
undoableUpdateStyle( {
|
|
40
|
+
undoableUpdateStyle( { styleId, provider, props, propDisplayName } );
|
|
35
41
|
}
|
|
36
42
|
};
|
|
37
43
|
|
|
@@ -68,14 +74,36 @@ function getProps< T extends Props >( { styleId, elementId, provider, meta, prop
|
|
|
68
74
|
) as NullableValues< T >;
|
|
69
75
|
}
|
|
70
76
|
|
|
71
|
-
type
|
|
77
|
+
type UpdateStyleArgs = {
|
|
78
|
+
styleId: StyleDefinition[ 'id' ];
|
|
79
|
+
provider: StylesProvider;
|
|
72
80
|
props: Props;
|
|
73
81
|
propDisplayName: string;
|
|
74
82
|
};
|
|
75
83
|
|
|
76
|
-
|
|
84
|
+
type CreateStyleArgs = {
|
|
85
|
+
styleId: null;
|
|
86
|
+
provider: null;
|
|
87
|
+
props: Props;
|
|
88
|
+
propDisplayName: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type UpdateStyleReturn = {
|
|
92
|
+
styleId: StyleDefinition[ 'id' ];
|
|
93
|
+
provider: StylesProvider;
|
|
94
|
+
prevProps: Props;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
type CreateStyleReturn = {
|
|
98
|
+
createdStyleId: StyleDefinition[ 'id' ];
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
type UndoableUpdateStylePayload = UpdateStyleArgs | CreateStyleArgs;
|
|
102
|
+
type UndoableUpdateStyleReturn = UpdateStyleReturn | CreateStyleReturn;
|
|
103
|
+
|
|
104
|
+
function useUndoableActions( {
|
|
77
105
|
elementId,
|
|
78
|
-
meta,
|
|
106
|
+
meta: { breakpoint, state },
|
|
79
107
|
}: {
|
|
80
108
|
elementId: ElementID;
|
|
81
109
|
meta: StyleDefinitionVariant[ 'meta' ];
|
|
@@ -83,108 +111,72 @@ function useUndoableCreateElementStyle( {
|
|
|
83
111
|
const classesProp = useClassesProp();
|
|
84
112
|
|
|
85
113
|
return useMemo( () => {
|
|
86
|
-
const
|
|
114
|
+
const meta = { breakpoint, state };
|
|
87
115
|
|
|
88
116
|
const createStyleArgs = { elementId, classesProp, meta, label: ELEMENTS_STYLES_RESERVED_LABEL };
|
|
89
117
|
|
|
90
118
|
return undoable(
|
|
91
119
|
{
|
|
92
|
-
do: (
|
|
93
|
-
|
|
120
|
+
do: ( payload: UndoableUpdateStylePayload ): UndoableUpdateStyleReturn => {
|
|
121
|
+
if ( shouldCreateNewLocalStyle< StylesProvider >( payload ) ) {
|
|
122
|
+
return create( payload as CreateStyleArgs );
|
|
123
|
+
}
|
|
124
|
+
return update( payload as UpdateStyleArgs );
|
|
94
125
|
},
|
|
126
|
+
undo: ( payload: UndoableUpdateStylePayload, doReturn: UndoableUpdateStyleReturn ) => {
|
|
127
|
+
const wasLocalStyleCreated = shouldCreateNewLocalStyle< StylesProvider >( payload );
|
|
95
128
|
|
|
96
|
-
|
|
97
|
-
|
|
129
|
+
if ( wasLocalStyleCreated ) {
|
|
130
|
+
return undoCreate( payload as CreateStyleArgs, doReturn as CreateStyleReturn );
|
|
131
|
+
}
|
|
132
|
+
return undo( payload as UpdateStyleArgs, doReturn as UpdateStyleReturn );
|
|
98
133
|
},
|
|
134
|
+
redo: ( payload: UndoableUpdateStylePayload, doReturn: UndoableUpdateStyleReturn ) => {
|
|
135
|
+
const wasLocalStyleCreated = shouldCreateNewLocalStyle< StylesProvider >( payload );
|
|
99
136
|
|
|
100
|
-
|
|
101
|
-
|
|
137
|
+
if ( wasLocalStyleCreated ) {
|
|
138
|
+
return create( payload as CreateStyleArgs, doReturn as CreateStyleReturn );
|
|
139
|
+
}
|
|
140
|
+
return update( payload as UpdateStyleArgs );
|
|
102
141
|
},
|
|
103
142
|
},
|
|
104
143
|
{
|
|
105
|
-
title: () => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return historyTitlesV330.title( { elementId } );
|
|
110
|
-
},
|
|
111
|
-
subtitle: ( { propDisplayName } ) => {
|
|
112
|
-
if ( isVersion331Active ) {
|
|
113
|
-
return localStyleHistoryTitlesV331.subtitle( { propDisplayName } );
|
|
114
|
-
}
|
|
115
|
-
return historyTitlesV330.subtitle;
|
|
116
|
-
},
|
|
144
|
+
title: ( { provider, styleId } ) => getTitle( { provider, styleId, elementId } ),
|
|
145
|
+
subtitle: ( { provider, styleId, propDisplayName } ) =>
|
|
146
|
+
getSubtitle( { provider, styleId, elementId, propDisplayName } ),
|
|
147
|
+
debounce: { wait: HISTORY_DEBOUNCE_WAIT },
|
|
117
148
|
}
|
|
118
149
|
);
|
|
119
|
-
}, [ classesProp, elementId, meta ] );
|
|
120
|
-
}
|
|
121
150
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
provider: StylesProvider;
|
|
125
|
-
props: Props;
|
|
126
|
-
propDisplayName: string;
|
|
127
|
-
};
|
|
151
|
+
function create( { props }: CreateStyleArgs, redoArgs?: CreateStyleReturn ): CreateStyleReturn {
|
|
152
|
+
const createdStyle = createElementStyle( { ...createStyleArgs, props, styleId: redoArgs?.createdStyleId } );
|
|
128
153
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
meta,
|
|
132
|
-
}: {
|
|
133
|
-
elementId: ElementID;
|
|
134
|
-
|
|
135
|
-
meta: StyleDefinitionVariant[ 'meta' ];
|
|
136
|
-
} ) {
|
|
137
|
-
return useMemo( () => {
|
|
138
|
-
const isVersion331Active = isExperimentActive( EXPERIMENTAL_FEATURES.V_3_31 );
|
|
154
|
+
return { createdStyleId: createdStyle };
|
|
155
|
+
}
|
|
139
156
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if ( ! provider.actions.updateProps ) {
|
|
144
|
-
throw new StylesProviderCannotUpdatePropsError( {
|
|
145
|
-
context: { providerKey: provider.getKey() },
|
|
146
|
-
} );
|
|
147
|
-
}
|
|
157
|
+
function undoCreate( _: UndoableUpdateStylePayload, { createdStyleId }: CreateStyleReturn ) {
|
|
158
|
+
deleteElementStyle( elementId, createdStyleId );
|
|
159
|
+
}
|
|
148
160
|
|
|
149
|
-
|
|
161
|
+
function update( { provider, styleId, props }: UpdateStyleArgs ): UpdateStyleReturn {
|
|
162
|
+
if ( ! provider.actions.updateProps ) {
|
|
163
|
+
throw new StylesProviderCannotUpdatePropsError( {
|
|
164
|
+
context: { providerKey: provider.getKey() },
|
|
165
|
+
} );
|
|
166
|
+
}
|
|
150
167
|
|
|
151
|
-
|
|
168
|
+
const style = provider.actions.get( styleId, { elementId } );
|
|
169
|
+
const prevProps = getCurrentProps( style, meta );
|
|
152
170
|
|
|
153
|
-
|
|
171
|
+
provider.actions.updateProps( { id: styleId, meta, props }, { elementId } );
|
|
154
172
|
|
|
155
|
-
|
|
156
|
-
|
|
173
|
+
return { styleId, provider, prevProps };
|
|
174
|
+
}
|
|
157
175
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
{
|
|
163
|
-
title: ( { provider } ) => {
|
|
164
|
-
if ( isVersion331Active ) {
|
|
165
|
-
const isLocal = isElementsStylesProvider( provider.getKey() );
|
|
166
|
-
|
|
167
|
-
if ( isLocal ) {
|
|
168
|
-
return localStyleHistoryTitlesV331.title( { elementId } );
|
|
169
|
-
}
|
|
170
|
-
return defaultHistoryTitlesV331.title( { provider } );
|
|
171
|
-
}
|
|
172
|
-
return historyTitlesV330.title( { elementId } );
|
|
173
|
-
},
|
|
174
|
-
subtitle: ( { provider, styleId, propDisplayName } ) => {
|
|
175
|
-
if ( isVersion331Active ) {
|
|
176
|
-
const isLocal = isElementsStylesProvider( provider.getKey() );
|
|
177
|
-
|
|
178
|
-
if ( isLocal ) {
|
|
179
|
-
return localStyleHistoryTitlesV331.subtitle( { propDisplayName } );
|
|
180
|
-
}
|
|
181
|
-
return defaultHistoryTitlesV331.subtitle( { provider, styleId, elementId, propDisplayName } );
|
|
182
|
-
}
|
|
183
|
-
return historyTitlesV330.subtitle;
|
|
184
|
-
},
|
|
185
|
-
}
|
|
186
|
-
);
|
|
187
|
-
}, [ elementId, meta ] );
|
|
176
|
+
function undo( _: UndoableUpdateStylePayload, { styleId, provider, prevProps }: UpdateStyleReturn ) {
|
|
177
|
+
provider.actions.updateProps?.( { id: styleId, meta, props: prevProps }, { elementId } );
|
|
178
|
+
}
|
|
179
|
+
}, [ elementId, breakpoint, state, classesProp ] );
|
|
188
180
|
}
|
|
189
181
|
|
|
190
182
|
function getCurrentProps( style: StyleDefinition | null, meta: StyleDefinitionVariant[ 'meta' ] ) {
|
|
@@ -199,28 +191,23 @@ function getCurrentProps( style: StyleDefinition | null, meta: StyleDefinitionVa
|
|
|
199
191
|
return structuredClone( props );
|
|
200
192
|
}
|
|
201
193
|
|
|
202
|
-
|
|
203
|
-
title: ( { elementId }: { elementId: ElementID } ) => getElementLabel( elementId ),
|
|
204
|
-
subtitle: __( 'Style edited', 'elementor' ),
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
type DefaultHistoryTitleV331Args = {
|
|
194
|
+
type DefaultHistoryTitleArgs = {
|
|
208
195
|
provider: StylesProvider;
|
|
209
196
|
};
|
|
210
197
|
|
|
211
|
-
type
|
|
198
|
+
type DefaultHistorySubtitleArgs = {
|
|
212
199
|
provider: StylesProvider;
|
|
213
200
|
styleId: StyleDefinition[ 'id' ];
|
|
214
201
|
elementId: ElementID;
|
|
215
202
|
propDisplayName: string;
|
|
216
203
|
};
|
|
217
204
|
|
|
218
|
-
const
|
|
219
|
-
title: ( { provider }:
|
|
205
|
+
const defaultHistoryTitles = {
|
|
206
|
+
title: ( { provider }: DefaultHistoryTitleArgs ) => {
|
|
220
207
|
const providerLabel = provider.labels?.singular;
|
|
221
208
|
return providerLabel ? capitalize( providerLabel ) : __( 'Style', 'elementor' );
|
|
222
209
|
},
|
|
223
|
-
subtitle: ( { provider, styleId, elementId, propDisplayName }:
|
|
210
|
+
subtitle: ( { provider, styleId, elementId, propDisplayName }: DefaultHistorySubtitleArgs ) => {
|
|
224
211
|
const styleLabel = provider.actions.get( styleId, { elementId } )?.label;
|
|
225
212
|
|
|
226
213
|
if ( ! styleLabel ) {
|
|
@@ -232,17 +219,17 @@ const defaultHistoryTitlesV331 = {
|
|
|
232
219
|
},
|
|
233
220
|
};
|
|
234
221
|
|
|
235
|
-
type
|
|
222
|
+
type LocalStyleHistoryTitleArgs = {
|
|
236
223
|
elementId: ElementID;
|
|
237
224
|
};
|
|
238
225
|
|
|
239
|
-
type
|
|
226
|
+
type LocalStyleHistorySubtitleArgs = {
|
|
240
227
|
propDisplayName: string;
|
|
241
228
|
};
|
|
242
229
|
|
|
243
|
-
const
|
|
244
|
-
title: ( { elementId }:
|
|
245
|
-
subtitle: ( { propDisplayName }:
|
|
230
|
+
const localStyleHistoryTitles = {
|
|
231
|
+
title: ( { elementId }: LocalStyleHistoryTitleArgs ) => getElementLabel( elementId ),
|
|
232
|
+
subtitle: ( { propDisplayName }: LocalStyleHistorySubtitleArgs ) =>
|
|
246
233
|
// translators: %s is the name of the style property being edited
|
|
247
234
|
__( `%s edited`, 'elementor' ).replace( '%s', propDisplayName ),
|
|
248
235
|
};
|
|
@@ -250,3 +237,39 @@ const localStyleHistoryTitlesV331 = {
|
|
|
250
237
|
function capitalize( str: string ) {
|
|
251
238
|
return str.charAt( 0 ).toUpperCase() + str.slice( 1 );
|
|
252
239
|
}
|
|
240
|
+
|
|
241
|
+
const isLocalStyle = ( provider: StylesProvider | null, styleId: StyleDefinition[ 'id' ] | null ) =>
|
|
242
|
+
! provider || ! styleId || isElementsStylesProvider( provider.getKey() );
|
|
243
|
+
|
|
244
|
+
type TitleOptions = {
|
|
245
|
+
provider: StylesProvider | null;
|
|
246
|
+
styleId: string | null;
|
|
247
|
+
elementId: string;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
type SubtitleOptions = TitleOptions & { propDisplayName: string };
|
|
251
|
+
|
|
252
|
+
export const getTitle = ( { provider, styleId, elementId }: TitleOptions ) => {
|
|
253
|
+
const isLocal = isLocalStyle( provider, styleId );
|
|
254
|
+
|
|
255
|
+
if ( isLocal ) {
|
|
256
|
+
return localStyleHistoryTitles.title( { elementId } );
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return defaultHistoryTitles.title( { provider: provider as StylesProvider } );
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
export const getSubtitle = ( { provider, styleId, propDisplayName, elementId }: SubtitleOptions ) => {
|
|
263
|
+
const isLocal = isLocalStyle( provider, styleId );
|
|
264
|
+
|
|
265
|
+
if ( isLocal ) {
|
|
266
|
+
return localStyleHistoryTitles.subtitle( { propDisplayName } );
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return defaultHistoryTitles.subtitle( {
|
|
270
|
+
provider: provider as StylesProvider,
|
|
271
|
+
styleId: styleId as StyleDefinition[ 'id' ],
|
|
272
|
+
elementId,
|
|
273
|
+
propDisplayName,
|
|
274
|
+
} );
|
|
275
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
export { EXPERIMENTAL_FEATURES } from './sync/experiments-flags';
|
|
2
|
-
|
|
3
1
|
export { useBoundProp } from '@elementor/editor-controls';
|
|
4
|
-
export type
|
|
5
|
-
export {
|
|
6
|
-
export { registerStyleProviderToColors } from './provider-colors-registry';
|
|
2
|
+
export { type ValidationEvent, type ValidationResult } from './components/creatable-autocomplete';
|
|
3
|
+
export { injectIntoCssClassConvert } from './components/css-classes/css-class-convert-local';
|
|
7
4
|
export { injectIntoClassSelectorActions } from './components/css-classes/css-class-selector';
|
|
8
|
-
export {
|
|
9
|
-
export { type ValidationResult, type ValidationEvent } from './components/creatable-autocomplete';
|
|
10
|
-
export { controlActionsMenu } from './controls-actions';
|
|
5
|
+
export { PopoverBody } from './components/popover-body';
|
|
11
6
|
export { useFontFamilies } from './components/style-sections/typography-section/hooks/use-font-families';
|
|
12
|
-
export { PopoverScrollableContent } from './components/popover-scrollable-content';
|
|
13
7
|
export { useSectionWidth } from './contexts/section-context';
|
|
14
|
-
|
|
8
|
+
export { registerControlReplacement } from './control-replacement';
|
|
9
|
+
export { controlActionsMenu } from './controls-actions';
|
|
15
10
|
export { init } from './init';
|
|
11
|
+
export { usePanelActions, usePanelStatus } from './panel';
|
|
12
|
+
export type { PopoverActionProps } from './popover-action';
|
|
13
|
+
export { registerStyleProviderToColors } from './provider-colors-registry';
|
|
14
|
+
export { stylesInheritanceTransformersRegistry } from './styles-inheritance/styles-inheritance-transformers-registry';
|
package/src/init.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { injectIntoLogic } from '@elementor/editor';
|
|
2
2
|
import { __registerPanel as registerPanel } from '@elementor/editor-panels';
|
|
3
|
-
import { blockCommand
|
|
3
|
+
import { blockCommand } from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
5
5
|
import { EditingPanelHooks } from './components/editing-panel-hooks';
|
|
6
6
|
import { init as initDynamics } from './dynamics/init';
|
|
7
7
|
import { panel } from './panel';
|
|
8
8
|
import { initResetStyleProps } from './reset-style-props';
|
|
9
9
|
import { init as initStylesInheritance } from './styles-inheritance/init';
|
|
10
|
-
import { EXPERIMENTAL_FEATURES } from './sync/experiments-flags';
|
|
11
10
|
import { isAtomicWidgetSelected } from './sync/is-atomic-widget-selected';
|
|
12
11
|
|
|
13
12
|
export function init() {
|
|
@@ -25,9 +24,7 @@ export function init() {
|
|
|
25
24
|
// TODO: Move it from here once we have styles-inheritance package.
|
|
26
25
|
initStylesInheritance();
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
initResetStyleProps();
|
|
30
|
-
}
|
|
27
|
+
initResetStyleProps();
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
const blockV1Panel = () => {
|
package/src/popover-action.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { type ComponentType, type ElementType as ReactElementType
|
|
3
|
-
import {
|
|
2
|
+
import { type ComponentType, type ElementType as ReactElementType } from 'react';
|
|
3
|
+
import { useFloatingActionsBar } from '@elementor/editor-controls';
|
|
4
|
+
import { bindPopover, bindTrigger, IconButton, Popover, Tooltip, usePopupState } from '@elementor/ui';
|
|
4
5
|
|
|
5
6
|
const SIZE = 'tiny';
|
|
6
7
|
|
|
@@ -11,17 +12,8 @@ export type PopoverActionProps = {
|
|
|
11
12
|
content: ComponentType< { close: () => void } >;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
visible = true,
|
|
17
|
-
icon: Icon,
|
|
18
|
-
content: PopoverContent,
|
|
19
|
-
}: PopoverActionProps ) {
|
|
20
|
-
const id = useId();
|
|
21
|
-
const popupState = usePopupState( {
|
|
22
|
-
variant: 'popover',
|
|
23
|
-
popupId: `elementor-popover-action-${ id }`,
|
|
24
|
-
} );
|
|
15
|
+
export function PopoverAction( { title, visible = true, icon: Icon, content: PopoverContent }: PopoverActionProps ) {
|
|
16
|
+
const { popupState, triggerProps, popoverProps } = useFloatingActionsPopover();
|
|
25
17
|
|
|
26
18
|
if ( ! visible ) {
|
|
27
19
|
return null;
|
|
@@ -30,7 +22,7 @@ export default function PopoverAction( {
|
|
|
30
22
|
return (
|
|
31
23
|
<>
|
|
32
24
|
<Tooltip placement="top" title={ title }>
|
|
33
|
-
<IconButton aria-label={ title }
|
|
25
|
+
<IconButton aria-label={ title } size={ SIZE } { ...triggerProps }>
|
|
34
26
|
<Icon fontSize={ SIZE } />
|
|
35
27
|
</IconButton>
|
|
36
28
|
</Tooltip>
|
|
@@ -48,10 +40,39 @@ export default function PopoverAction( {
|
|
|
48
40
|
PaperProps={ {
|
|
49
41
|
sx: { my: 2.5 },
|
|
50
42
|
} }
|
|
51
|
-
{ ...
|
|
43
|
+
{ ...popoverProps }
|
|
52
44
|
>
|
|
53
45
|
<PopoverContent close={ popupState.close } />
|
|
54
46
|
</Popover>
|
|
55
47
|
</>
|
|
56
48
|
);
|
|
57
49
|
}
|
|
50
|
+
|
|
51
|
+
export function useFloatingActionsPopover() {
|
|
52
|
+
const { setOpen } = useFloatingActionsBar();
|
|
53
|
+
const popupState = usePopupState( { variant: 'popover' } );
|
|
54
|
+
|
|
55
|
+
const triggerProps = bindTrigger( popupState );
|
|
56
|
+
const popoverProps = bindPopover( popupState );
|
|
57
|
+
|
|
58
|
+
const onClick = ( e: React.MouseEvent ) => {
|
|
59
|
+
triggerProps.onClick( e );
|
|
60
|
+
setOpen( true );
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const onClose = () => {
|
|
64
|
+
popoverProps.onClose();
|
|
65
|
+
setOpen( false );
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const close = () => {
|
|
69
|
+
popupState.close();
|
|
70
|
+
setOpen( false );
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
popupState: { ...popupState, close },
|
|
75
|
+
triggerProps: { ...triggerProps, onClick },
|
|
76
|
+
popoverProps: { ...popoverProps, onClose },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -14,16 +14,12 @@ export function initResetStyleProps() {
|
|
|
14
14
|
} );
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
// Temporary fix for the issue with ControlToggleButtonGroup.
|
|
18
|
-
const EXCLUDED_BINDS = [ 'order', 'flex-grow', 'flex-shrink', 'flex-basis' ];
|
|
19
|
-
|
|
20
17
|
export function useResetStyleValueProps() {
|
|
21
18
|
const isStyle = useIsStyle();
|
|
22
|
-
const { value, setValue, path
|
|
19
|
+
const { value, setValue, path } = useBoundProp();
|
|
23
20
|
|
|
24
21
|
return {
|
|
25
|
-
visible:
|
|
26
|
-
isStyle && value !== null && value !== undefined && path.length <= 2 && ! EXCLUDED_BINDS.includes( bind ),
|
|
22
|
+
visible: isStyle && value !== null && value !== undefined && path.length <= 2,
|
|
27
23
|
title: __( 'Clear', 'elementor' ),
|
|
28
24
|
icon: BrushBigIcon,
|
|
29
25
|
onClick: () => setValue( null ),
|
|
@@ -3,34 +3,28 @@ import { type ComponentProps } from 'react';
|
|
|
3
3
|
import { useBoundProp } from '@elementor/editor-controls';
|
|
4
4
|
import { isEmpty, type PropType } from '@elementor/editor-props';
|
|
5
5
|
import { ELEMENTS_BASE_STYLES_PROVIDER_KEY } from '@elementor/editor-styles-repository';
|
|
6
|
-
import { isExperimentActive } from '@elementor/editor-v1-adapters';
|
|
7
|
-
import { Tooltip } from '@elementor/ui';
|
|
8
6
|
import { __ } from '@wordpress/i18n';
|
|
9
7
|
|
|
10
8
|
import { StyleIndicator } from '../../components/style-indicator';
|
|
11
9
|
import { useStyle } from '../../contexts/style-context';
|
|
12
10
|
import { useStylesInheritanceChain } from '../../contexts/styles-inheritance-context';
|
|
13
|
-
import { EXPERIMENTAL_FEATURES } from '../../sync/experiments-flags';
|
|
14
11
|
import { getStylesProviderThemeColor } from '../../utils/get-styles-provider-color';
|
|
15
|
-
import { isUsingIndicatorPopover } from '../consts';
|
|
16
12
|
import { type SnapshotPropValue } from '../types';
|
|
17
13
|
import { getValueFromInheritanceChain } from '../utils';
|
|
18
14
|
import { StylesInheritanceInfotip } from './styles-inheritance-infotip';
|
|
19
15
|
|
|
16
|
+
const skipControls = [ 'box-shadow', 'background-overlay', 'filter', 'backdrop-filter', 'transform' ];
|
|
17
|
+
|
|
20
18
|
export const StylesInheritanceIndicator = () => {
|
|
21
19
|
const { path, propType } = useBoundProp();
|
|
22
20
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const finalPath = isUsingNestedProps ? path : path.slice( 0, 1 );
|
|
26
|
-
|
|
27
|
-
const inheritanceChain = useStylesInheritanceChain( finalPath );
|
|
21
|
+
const inheritanceChain = useStylesInheritanceChain( path );
|
|
28
22
|
|
|
29
|
-
if ( ! inheritanceChain.length ) {
|
|
23
|
+
if ( ! path || path.some( ( pathItem ) => skipControls.includes( pathItem ) ) || ! inheritanceChain.length ) {
|
|
30
24
|
return null;
|
|
31
25
|
}
|
|
32
26
|
|
|
33
|
-
return <Indicator inheritanceChain={ inheritanceChain } path={
|
|
27
|
+
return <Indicator inheritanceChain={ inheritanceChain } path={ path } propType={ propType } />;
|
|
34
28
|
};
|
|
35
29
|
|
|
36
30
|
type IndicatorProps = {
|
|
@@ -50,10 +44,7 @@ const Indicator = ( { inheritanceChain, path, propType }: IndicatorProps ) => {
|
|
|
50
44
|
|
|
51
45
|
const [ actualStyle ] = inheritanceChain;
|
|
52
46
|
|
|
53
|
-
if (
|
|
54
|
-
! isExperimentActive( EXPERIMENTAL_FEATURES.V_3_31 ) &&
|
|
55
|
-
actualStyle.provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY
|
|
56
|
-
) {
|
|
47
|
+
if ( actualStyle.provider === ELEMENTS_BASE_STYLES_PROVIDER_KEY ) {
|
|
57
48
|
return null;
|
|
58
49
|
}
|
|
59
50
|
|
|
@@ -69,14 +60,6 @@ const Indicator = ( { inheritanceChain, path, propType }: IndicatorProps ) => {
|
|
|
69
60
|
isOverridden: hasValue && ! isFinalValue ? true : undefined,
|
|
70
61
|
};
|
|
71
62
|
|
|
72
|
-
if ( ! isUsingIndicatorPopover() ) {
|
|
73
|
-
return (
|
|
74
|
-
<Tooltip title={ __( 'Style origin', 'elementor' ) } placement="top">
|
|
75
|
-
<StyleIndicator { ...styleIndicatorProps } aria-label={ label } />
|
|
76
|
-
</Tooltip>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
63
|
return (
|
|
81
64
|
<StylesInheritanceInfotip
|
|
82
65
|
inheritanceChain={ inheritanceChain }
|
|
@@ -41,7 +41,7 @@ export const StylesInheritanceInfotip = ( { inheritanceChain, propType, path, la
|
|
|
41
41
|
|
|
42
42
|
const key = path.join( '.' );
|
|
43
43
|
|
|
44
|
-
const sectionWidth = useSectionWidth()
|
|
44
|
+
const sectionWidth = useSectionWidth();
|
|
45
45
|
|
|
46
46
|
const resolve = useMemo< PropsResolver >( () => {
|
|
47
47
|
return createPropsResolver( {
|
|
@@ -59,27 +59,36 @@ export const StylesInheritanceInfotip = ( { inheritanceChain, propType, path, la
|
|
|
59
59
|
sx={ {
|
|
60
60
|
width: `${ sectionWidth - SECTION_PADDING_INLINE }px`,
|
|
61
61
|
maxWidth: 496,
|
|
62
|
+
maxHeight: 268,
|
|
62
63
|
overflowX: 'hidden',
|
|
64
|
+
display: 'flex',
|
|
65
|
+
flexDirection: 'column',
|
|
63
66
|
} }
|
|
64
67
|
>
|
|
68
|
+
<Box
|
|
69
|
+
sx={ {
|
|
70
|
+
position: 'sticky',
|
|
71
|
+
top: 0,
|
|
72
|
+
zIndex: 1,
|
|
73
|
+
backgroundColor: 'background.paper',
|
|
74
|
+
} }
|
|
75
|
+
>
|
|
76
|
+
<PopoverHeader title={ __( 'Style origin', 'elementor' ) } onClose={ closeInfotip } />
|
|
77
|
+
</Box>
|
|
78
|
+
|
|
65
79
|
<CardContent
|
|
66
80
|
sx={ {
|
|
67
81
|
display: 'flex',
|
|
68
|
-
gap: 0.5,
|
|
69
82
|
flexDirection: 'column',
|
|
70
83
|
p: 0,
|
|
84
|
+
flex: 1,
|
|
85
|
+
overflow: 'auto',
|
|
71
86
|
'&:last-child': {
|
|
72
87
|
pb: 0,
|
|
73
88
|
},
|
|
74
89
|
} }
|
|
75
90
|
>
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
<Stack
|
|
79
|
-
gap={ 1.5 }
|
|
80
|
-
sx={ { pl: 2, pr: 1, pb: 2, overflowX: 'hidden', overflowY: 'auto' } }
|
|
81
|
-
role="list"
|
|
82
|
-
>
|
|
91
|
+
<Stack gap={ 1.5 } sx={ { pl: 3, pr: 1, pb: 2 } } role="list">
|
|
83
92
|
{ items.map( ( item, index ) => {
|
|
84
93
|
return (
|
|
85
94
|
<Box
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { isExperimentActive } from '@elementor/editor-v1-adapters';
|
|
2
|
-
|
|
3
1
|
// the following prop types' style transformers would be ignored to provide alternative transformers for the styles inheritance popover
|
|
4
2
|
export const excludePropTypeTransformers = new Set( [
|
|
5
3
|
'background-color-overlay',
|
|
@@ -13,5 +11,3 @@ export const excludePropTypeTransformers = new Set( [
|
|
|
13
11
|
'image',
|
|
14
12
|
'background-overlay',
|
|
15
13
|
] );
|
|
16
|
-
|
|
17
|
-
export const isUsingIndicatorPopover = () => isExperimentActive( 'e_v_3_30' );
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { isUsingIndicatorPopover } from './consts';
|
|
2
1
|
import { initStylesInheritanceTransformers } from './init-styles-inheritance-transformers';
|
|
3
2
|
|
|
4
3
|
export const init = () => {
|
|
5
|
-
|
|
6
|
-
initStylesInheritanceTransformers();
|
|
7
|
-
}
|
|
4
|
+
initStylesInheritanceTransformers();
|
|
8
5
|
};
|