@elementor/editor-variables 4.1.0-manual → 4.2.0-839
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/dist/index.d.mts +22 -13
- package/dist/index.d.ts +22 -13
- package/dist/index.js +567 -415
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +565 -411
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/src/components/global-styles-import-listener.tsx +3 -5
- package/src/components/variable-selection-popover.tsx +10 -4
- package/src/components/variables-manager/variables-manager-create-menu.tsx +8 -1
- package/src/components/variables-manager/variables-manager-panel.tsx +285 -150
- package/src/components/variables-repeater-item-slot.tsx +20 -0
- package/src/index.ts +4 -0
- package/src/init.ts +12 -9
- package/src/mcp/manage-variable-tool.ts +9 -0
- package/src/mcp/variables-resource.ts +30 -14
- package/src/repeater-injections.ts +22 -0
- package/src/types.ts +2 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-variables",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0-839",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,22 +39,22 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor": "4.
|
|
43
|
-
"@elementor/editor-canvas": "4.
|
|
44
|
-
"@elementor/editor-controls": "4.
|
|
45
|
-
"@elementor/editor-current-user": "4.
|
|
46
|
-
"@elementor/editor-mcp": "4.
|
|
47
|
-
"@elementor/editor-panels": "4.
|
|
48
|
-
"@elementor/editor-props": "4.
|
|
49
|
-
"@elementor/editor-ui": "4.
|
|
50
|
-
"@elementor/editor-v1-adapters": "4.
|
|
51
|
-
"@elementor/menus": "4.
|
|
52
|
-
"@elementor/http-client": "4.
|
|
53
|
-
"@elementor/icons": "
|
|
54
|
-
"@elementor/events": "4.
|
|
55
|
-
"@elementor/schema": "4.
|
|
42
|
+
"@elementor/editor": "4.2.0-839",
|
|
43
|
+
"@elementor/editor-canvas": "4.2.0-839",
|
|
44
|
+
"@elementor/editor-controls": "4.2.0-839",
|
|
45
|
+
"@elementor/editor-current-user": "4.2.0-839",
|
|
46
|
+
"@elementor/editor-mcp": "4.2.0-839",
|
|
47
|
+
"@elementor/editor-panels": "4.2.0-839",
|
|
48
|
+
"@elementor/editor-props": "4.2.0-839",
|
|
49
|
+
"@elementor/editor-ui": "4.2.0-839",
|
|
50
|
+
"@elementor/editor-v1-adapters": "4.2.0-839",
|
|
51
|
+
"@elementor/menus": "4.2.0-839",
|
|
52
|
+
"@elementor/http-client": "4.2.0-839",
|
|
53
|
+
"@elementor/icons": "~1.75.1",
|
|
54
|
+
"@elementor/events": "4.2.0-839",
|
|
55
|
+
"@elementor/schema": "4.2.0-839",
|
|
56
56
|
"@elementor/ui": "1.37.5",
|
|
57
|
-
"@elementor/utils": "4.
|
|
57
|
+
"@elementor/utils": "4.2.0-839",
|
|
58
58
|
"@wordpress/i18n": "^5.13.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
+
import { GLOBAL_STYLES_IMPORTED_EVENT } from '@elementor/editor-canvas';
|
|
2
3
|
|
|
3
4
|
import { service } from '../service';
|
|
4
5
|
import { styleVariablesRepository } from '../style-variables-repository';
|
|
@@ -19,13 +20,10 @@ export function GlobalStylesImportListener() {
|
|
|
19
20
|
service.load();
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
window.addEventListener(
|
|
23
|
+
window.addEventListener( GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported as EventListener );
|
|
23
24
|
|
|
24
25
|
return () => {
|
|
25
|
-
window.removeEventListener(
|
|
26
|
-
'elementor/global-styles/imported',
|
|
27
|
-
handleGlobalStylesImported as EventListener
|
|
28
|
-
);
|
|
26
|
+
window.removeEventListener( GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported as EventListener );
|
|
29
27
|
};
|
|
30
28
|
}, [] );
|
|
31
29
|
|
|
@@ -28,10 +28,16 @@ type Props = {
|
|
|
28
28
|
export const VariableSelectionPopover = ( { closePopover, propTypeKey, selectedVariable }: Props ) => {
|
|
29
29
|
const [ currentView, setCurrentView ] = useState< View >( VIEW_LIST );
|
|
30
30
|
const [ editId, setEditId ] = useState< string >( '' );
|
|
31
|
-
const { open } = usePanelActions();
|
|
31
|
+
const { open: openStandaloneVariablesPanel } = usePanelActions();
|
|
32
32
|
const onSettingsAvailable = isExperimentActive( 'e_variables_manager' )
|
|
33
33
|
? () => {
|
|
34
|
-
|
|
34
|
+
if ( isExperimentActive( 'e_editor_design_system_panel' ) ) {
|
|
35
|
+
window.dispatchEvent(
|
|
36
|
+
new CustomEvent( 'elementor/toggle-design-system', { detail: { tab: 'variables' as const } } )
|
|
37
|
+
);
|
|
38
|
+
} else {
|
|
39
|
+
openStandaloneVariablesPanel();
|
|
40
|
+
}
|
|
35
41
|
}
|
|
36
42
|
: undefined;
|
|
37
43
|
|
|
@@ -75,7 +81,7 @@ type Handlers = {
|
|
|
75
81
|
|
|
76
82
|
function RenderView( props: ViewProps ): React.ReactNode {
|
|
77
83
|
const userPermissions = usePermissions();
|
|
78
|
-
const
|
|
84
|
+
const userQuotaPermissions = useQuotaPermissions( props.propTypeKey );
|
|
79
85
|
|
|
80
86
|
const handlers: Handlers = {
|
|
81
87
|
onClose: () => {
|
|
@@ -121,7 +127,7 @@ function RenderView( props: ViewProps ): React.ReactNode {
|
|
|
121
127
|
onAdd={ handlers.onAdd }
|
|
122
128
|
onEdit={ handlers.onEdit }
|
|
123
129
|
onSettings={ handlers.onSettings }
|
|
124
|
-
disabled={ !
|
|
130
|
+
disabled={ ! userQuotaPermissions.canAdd() }
|
|
125
131
|
/>
|
|
126
132
|
);
|
|
127
133
|
}
|
|
@@ -32,9 +32,15 @@ type VariableManagerCreateMenuProps = {
|
|
|
32
32
|
onCreate: ( type: string, defaultName: string, defaultValue: string ) => void;
|
|
33
33
|
disabled?: boolean;
|
|
34
34
|
menuState: PopupState;
|
|
35
|
+
outlinedTrigger?: boolean;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
|
-
export const VariableManagerCreateMenu = ( {
|
|
38
|
+
export const VariableManagerCreateMenu = ( {
|
|
39
|
+
variables,
|
|
40
|
+
onCreate,
|
|
41
|
+
menuState,
|
|
42
|
+
outlinedTrigger = false,
|
|
43
|
+
}: VariableManagerCreateMenuProps ) => {
|
|
38
44
|
const buttonRef = useRef< HTMLButtonElement >( null );
|
|
39
45
|
|
|
40
46
|
const variableTypes = getVariableTypes();
|
|
@@ -59,6 +65,7 @@ export const VariableManagerCreateMenu = ( { variables, onCreate, menuState }: V
|
|
|
59
65
|
{ ...bindTrigger( menuState ) }
|
|
60
66
|
ref={ buttonRef }
|
|
61
67
|
size={ SIZE }
|
|
68
|
+
variant={ outlinedTrigger ? 'outlined' : undefined }
|
|
62
69
|
aria-label={ __( 'Add variable', 'elementor' ) }
|
|
63
70
|
>
|
|
64
71
|
<PlusIcon fontSize={ SIZE } />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { useSuppressedMessage } from '@elementor/editor-current-user';
|
|
4
4
|
import {
|
|
5
5
|
__createPanel as createPanel,
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
Alert,
|
|
17
17
|
AlertAction,
|
|
18
18
|
AlertTitle,
|
|
19
|
+
Box,
|
|
19
20
|
Button,
|
|
20
21
|
CloseButton,
|
|
21
22
|
Divider,
|
|
@@ -59,8 +60,54 @@ export const { panel, usePanelActions } = createPanel( {
|
|
|
59
60
|
isOpenPreviousElement: true,
|
|
60
61
|
} );
|
|
61
62
|
|
|
63
|
+
export type VariablesManagerPanelEmbeddedProps = {
|
|
64
|
+
onRequestClose: () => void | Promise< void >;
|
|
65
|
+
/**
|
|
66
|
+
* Registers the variables manager close handler (dirty check + save dialog) so parent panel chrome
|
|
67
|
+
* can invoke the same flow as the standalone panel close control.
|
|
68
|
+
*/
|
|
69
|
+
onExposeCloseAttempt?: ( attemptClose: ( () => void ) | null ) => void;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Variables UI without standalone panel chrome — use inside Design System panel when experiment is active.
|
|
74
|
+
* @param root0
|
|
75
|
+
* @param root0.onRequestClose
|
|
76
|
+
* @param root0.onExposeCloseAttempt
|
|
77
|
+
*/
|
|
78
|
+
export function VariablesManagerPanelEmbedded( {
|
|
79
|
+
onRequestClose,
|
|
80
|
+
onExposeCloseAttempt,
|
|
81
|
+
}: VariablesManagerPanelEmbeddedProps ) {
|
|
82
|
+
return (
|
|
83
|
+
<VariablesManagerPanelRoot
|
|
84
|
+
embedded
|
|
85
|
+
onRequestClose={ onRequestClose }
|
|
86
|
+
onExposeCloseAttempt={ onExposeCloseAttempt }
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
62
91
|
export function VariablesManagerPanel() {
|
|
63
|
-
|
|
92
|
+
return <VariablesManagerPanelRoot />;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type VariablesManagerPanelRootProps = {
|
|
96
|
+
embedded?: boolean;
|
|
97
|
+
onRequestClose?: () => void | Promise< void >;
|
|
98
|
+
onExposeCloseAttempt?: ( attemptClose: ( () => void ) | null ) => void;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
function VariablesManagerPanelRoot( {
|
|
102
|
+
embedded = false,
|
|
103
|
+
onRequestClose,
|
|
104
|
+
onExposeCloseAttempt,
|
|
105
|
+
}: VariablesManagerPanelRootProps = {} ) {
|
|
106
|
+
const { close: closeStandalonePanel } = usePanelActions();
|
|
107
|
+
const closePanel = useMemo(
|
|
108
|
+
() => ( embedded ? onRequestClose ?? ( async () => {} ) : closeStandalonePanel ),
|
|
109
|
+
[ embedded, onRequestClose, closeStandalonePanel ]
|
|
110
|
+
);
|
|
64
111
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
65
112
|
const [ isStopSyncSuppressed ] = useSuppressedMessage( STOP_SYNC_MESSAGE_KEY );
|
|
66
113
|
|
|
@@ -95,14 +142,24 @@ export function VariablesManagerPanel() {
|
|
|
95
142
|
|
|
96
143
|
usePreventUnload( isDirty );
|
|
97
144
|
|
|
98
|
-
const handleClosePanel = () => {
|
|
145
|
+
const handleClosePanel = useCallback( () => {
|
|
99
146
|
if ( isDirty ) {
|
|
100
147
|
openSaveChangesDialog();
|
|
101
148
|
return;
|
|
102
149
|
}
|
|
103
150
|
|
|
104
|
-
closePanel();
|
|
105
|
-
};
|
|
151
|
+
void closePanel();
|
|
152
|
+
}, [ isDirty, openSaveChangesDialog, closePanel ] );
|
|
153
|
+
|
|
154
|
+
useEffect( () => {
|
|
155
|
+
if ( ! embedded || ! onExposeCloseAttempt ) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
onExposeCloseAttempt( () => handleClosePanel() );
|
|
160
|
+
|
|
161
|
+
return () => onExposeCloseAttempt( null );
|
|
162
|
+
}, [ embedded, onExposeCloseAttempt, handleClosePanel ] );
|
|
106
163
|
|
|
107
164
|
const handleCreateVariable = useCallback(
|
|
108
165
|
( type: string, defaultName: string, defaultValue: string ) => {
|
|
@@ -239,153 +296,127 @@ export function VariablesManagerPanel() {
|
|
|
239
296
|
|
|
240
297
|
const hasVariables = Object.keys( variables ).length > 0;
|
|
241
298
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
aria-label="Close"
|
|
266
|
-
slotProps={ { icon: { fontSize: SIZE } } }
|
|
267
|
-
onClick={ () => {
|
|
268
|
-
handleClosePanel();
|
|
269
|
-
} }
|
|
270
|
-
/>
|
|
271
|
-
</Stack>
|
|
272
|
-
</Stack>
|
|
273
|
-
<Stack width="100%" direction="row" gap={ 1 }>
|
|
274
|
-
<SearchField
|
|
275
|
-
sx={ {
|
|
276
|
-
display: 'flex',
|
|
277
|
-
flex: 1,
|
|
278
|
-
} }
|
|
279
|
-
placeholder={ __( 'Search', 'elementor' ) }
|
|
280
|
-
value={ searchValue }
|
|
281
|
-
onSearch={ handleSearch }
|
|
282
|
-
/>
|
|
283
|
-
</Stack>
|
|
284
|
-
<Divider sx={ { width: '100%' } } />
|
|
285
|
-
</Stack>
|
|
286
|
-
</PanelHeader>
|
|
287
|
-
<PanelBody
|
|
288
|
-
sx={ {
|
|
289
|
-
display: 'flex',
|
|
290
|
-
flexDirection: 'column',
|
|
291
|
-
height: '100%',
|
|
292
|
-
} }
|
|
293
|
-
>
|
|
294
|
-
{ hasVariables && (
|
|
295
|
-
<VariablesManagerTable
|
|
296
|
-
menuActions={ buildMenuActions }
|
|
297
|
-
variables={ variables }
|
|
298
|
-
onChange={ handleOnChange }
|
|
299
|
-
autoEditVariableId={ autoEditVariableId }
|
|
300
|
-
onAutoEditComplete={ handleAutoEditComplete }
|
|
301
|
-
onFieldError={ setIsSaveDisabled }
|
|
302
|
-
/>
|
|
303
|
-
) }
|
|
299
|
+
const variablesSearchFieldSx = embedded
|
|
300
|
+
? {
|
|
301
|
+
flex: 1,
|
|
302
|
+
minWidth: 0,
|
|
303
|
+
px: 0,
|
|
304
|
+
py: 0,
|
|
305
|
+
display: 'flex',
|
|
306
|
+
alignItems: 'center',
|
|
307
|
+
alignSelf: 'stretch',
|
|
308
|
+
}
|
|
309
|
+
: {
|
|
310
|
+
display: 'flex',
|
|
311
|
+
flex: 1,
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
const searchField = (
|
|
315
|
+
<SearchField
|
|
316
|
+
placeholder={ __( 'Search', 'elementor' ) }
|
|
317
|
+
value={ searchValue }
|
|
318
|
+
onSearch={ handleSearch }
|
|
319
|
+
sx={ variablesSearchFieldSx }
|
|
320
|
+
/>
|
|
321
|
+
);
|
|
304
322
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
323
|
+
const bodyInner = (
|
|
324
|
+
<>
|
|
325
|
+
{ hasVariables && (
|
|
326
|
+
<VariablesManagerTable
|
|
327
|
+
menuActions={ buildMenuActions }
|
|
328
|
+
variables={ variables }
|
|
329
|
+
onChange={ handleOnChange }
|
|
330
|
+
autoEditVariableId={ autoEditVariableId }
|
|
331
|
+
onAutoEditComplete={ handleAutoEditComplete }
|
|
332
|
+
onFieldError={ setIsSaveDisabled }
|
|
333
|
+
/>
|
|
334
|
+
) }
|
|
335
|
+
|
|
336
|
+
{ ! hasVariables && searchValue && (
|
|
337
|
+
<NoSearchResults
|
|
338
|
+
searchValue={ searchValue }
|
|
339
|
+
onClear={ () => handleSearch( '' ) }
|
|
340
|
+
icon={ <ColorFilterIcon fontSize="large" /> }
|
|
341
|
+
/>
|
|
342
|
+
) }
|
|
312
343
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
) }
|
|
320
|
-
icon={ <ColorFilterIcon fontSize="large" /> }
|
|
321
|
-
onAdd={ createMenuState.open }
|
|
322
|
-
/>
|
|
344
|
+
{ ! hasVariables && ! searchValue && (
|
|
345
|
+
<EmptyState
|
|
346
|
+
title={ __( 'Create your first variable', 'elementor' ) }
|
|
347
|
+
message={ __(
|
|
348
|
+
'Variables are saved attributes that you can apply anywhere on your site.',
|
|
349
|
+
'elementor'
|
|
323
350
|
) }
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
{ serverError.action?.message }
|
|
359
|
-
</Alert>
|
|
360
|
-
) : null
|
|
361
|
-
}
|
|
362
|
-
arrow={ false }
|
|
363
|
-
slotProps={ {
|
|
364
|
-
popper: {
|
|
365
|
-
modifiers: [
|
|
366
|
-
{
|
|
367
|
-
name: 'offset',
|
|
368
|
-
options: { offset: [ -10, 10 ] },
|
|
369
|
-
},
|
|
370
|
-
],
|
|
371
|
-
},
|
|
372
|
-
} }
|
|
373
|
-
>
|
|
374
|
-
<Button
|
|
375
|
-
fullWidth
|
|
376
|
-
size="small"
|
|
377
|
-
color="global"
|
|
378
|
-
variant="contained"
|
|
379
|
-
disabled={ isSaveDisabled || ! isDirty || isSaving }
|
|
380
|
-
onClick={ handleSaveClick }
|
|
381
|
-
loading={ isSaving }
|
|
351
|
+
icon={ <ColorFilterIcon fontSize="large" /> }
|
|
352
|
+
onAdd={ createMenuState.open }
|
|
353
|
+
/>
|
|
354
|
+
) }
|
|
355
|
+
</>
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
const saveFooter = (
|
|
359
|
+
<PanelFooter>
|
|
360
|
+
<Infotip
|
|
361
|
+
placement="right"
|
|
362
|
+
open={ !! serverError }
|
|
363
|
+
content={
|
|
364
|
+
serverError ? (
|
|
365
|
+
<Alert
|
|
366
|
+
severity={ serverError.severity ?? 'error' }
|
|
367
|
+
action={
|
|
368
|
+
serverError.action?.label ? (
|
|
369
|
+
<AlertAction onClick={ serverError.action.callback }>
|
|
370
|
+
{ serverError.action.label }
|
|
371
|
+
</AlertAction>
|
|
372
|
+
) : undefined
|
|
373
|
+
}
|
|
374
|
+
onClose={
|
|
375
|
+
! serverError.action?.label
|
|
376
|
+
? () => {
|
|
377
|
+
setServerError( null );
|
|
378
|
+
setIsSaveDisabled( false );
|
|
379
|
+
}
|
|
380
|
+
: undefined
|
|
381
|
+
}
|
|
382
|
+
icon={
|
|
383
|
+
serverError.IconComponent ? <serverError.IconComponent /> : <AlertTriangleFilledIcon />
|
|
384
|
+
}
|
|
382
385
|
>
|
|
383
|
-
{
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
386
|
+
<AlertTitle>{ serverError.message }</AlertTitle>
|
|
387
|
+
{ serverError.action?.message }
|
|
388
|
+
</Alert>
|
|
389
|
+
) : null
|
|
390
|
+
}
|
|
391
|
+
arrow={ false }
|
|
392
|
+
slotProps={ {
|
|
393
|
+
popper: {
|
|
394
|
+
modifiers: [
|
|
395
|
+
{
|
|
396
|
+
name: 'offset',
|
|
397
|
+
options: { offset: [ -10, 10 ] },
|
|
398
|
+
},
|
|
399
|
+
],
|
|
400
|
+
},
|
|
401
|
+
} }
|
|
402
|
+
>
|
|
403
|
+
<Button
|
|
404
|
+
fullWidth
|
|
405
|
+
size="small"
|
|
406
|
+
color="global"
|
|
407
|
+
variant="contained"
|
|
408
|
+
disabled={ isSaveDisabled || ! isDirty || isSaving }
|
|
409
|
+
onClick={ handleSaveClick }
|
|
410
|
+
loading={ isSaving }
|
|
411
|
+
>
|
|
412
|
+
{ __( 'Save changes', 'elementor' ) }
|
|
413
|
+
</Button>
|
|
414
|
+
</Infotip>
|
|
415
|
+
</PanelFooter>
|
|
416
|
+
);
|
|
388
417
|
|
|
418
|
+
const dialogs = (
|
|
419
|
+
<>
|
|
389
420
|
{ deleteConfirmation && (
|
|
390
421
|
<DeleteConfirmationDialog
|
|
391
422
|
open
|
|
@@ -422,7 +453,7 @@ export function VariablesManagerPanel() {
|
|
|
422
453
|
label: __( 'Discard', 'elementor' ),
|
|
423
454
|
action: () => {
|
|
424
455
|
closeSaveChangesDialog();
|
|
425
|
-
closePanel();
|
|
456
|
+
void closePanel();
|
|
426
457
|
},
|
|
427
458
|
},
|
|
428
459
|
confirm: {
|
|
@@ -431,7 +462,7 @@ export function VariablesManagerPanel() {
|
|
|
431
462
|
const result = await handleSaveClick();
|
|
432
463
|
closeSaveChangesDialog();
|
|
433
464
|
if ( result?.success ) {
|
|
434
|
-
closePanel();
|
|
465
|
+
void closePanel();
|
|
435
466
|
}
|
|
436
467
|
},
|
|
437
468
|
},
|
|
@@ -439,8 +470,112 @@ export function VariablesManagerPanel() {
|
|
|
439
470
|
/>
|
|
440
471
|
</SaveChangesDialog>
|
|
441
472
|
) }
|
|
442
|
-
|
|
473
|
+
</>
|
|
474
|
+
);
|
|
475
|
+
|
|
476
|
+
const panelChrome = embedded ? (
|
|
477
|
+
<Stack
|
|
478
|
+
direction="column"
|
|
479
|
+
sx={ {
|
|
480
|
+
height: '100%',
|
|
481
|
+
width: '100%',
|
|
482
|
+
flex: 1,
|
|
483
|
+
minHeight: 0,
|
|
484
|
+
overflow: 'hidden',
|
|
485
|
+
} }
|
|
486
|
+
>
|
|
487
|
+
<Stack
|
|
488
|
+
direction="row"
|
|
489
|
+
alignItems="center"
|
|
490
|
+
spacing={ 1 }
|
|
491
|
+
width="100%"
|
|
492
|
+
sx={ {
|
|
493
|
+
flexShrink: 0,
|
|
494
|
+
px: 2,
|
|
495
|
+
pb: 1,
|
|
496
|
+
} }
|
|
497
|
+
>
|
|
498
|
+
{ searchField }
|
|
499
|
+
<Box sx={ { display: 'flex', flexShrink: 0, alignItems: 'center' } }>
|
|
500
|
+
<VariableManagerCreateMenu
|
|
501
|
+
outlinedTrigger
|
|
502
|
+
onCreate={ handleCreateVariable }
|
|
503
|
+
variables={ variables }
|
|
504
|
+
menuState={ createMenuState }
|
|
505
|
+
/>
|
|
506
|
+
</Box>
|
|
507
|
+
</Stack>
|
|
508
|
+
<Divider sx={ { width: '100%' } } />
|
|
509
|
+
<PanelBody
|
|
510
|
+
sx={ {
|
|
511
|
+
display: 'flex',
|
|
512
|
+
flexDirection: 'column',
|
|
513
|
+
flex: 1,
|
|
514
|
+
minHeight: 0,
|
|
515
|
+
overflow: 'hidden',
|
|
516
|
+
} }
|
|
517
|
+
>
|
|
518
|
+
{ bodyInner }
|
|
519
|
+
</PanelBody>
|
|
520
|
+
{ saveFooter }
|
|
521
|
+
</Stack>
|
|
522
|
+
) : (
|
|
523
|
+
<Panel>
|
|
524
|
+
<PanelHeader
|
|
525
|
+
sx={ {
|
|
526
|
+
height: 'unset',
|
|
527
|
+
} }
|
|
528
|
+
>
|
|
529
|
+
<Stack width="100%" direction="column" alignItems="center">
|
|
530
|
+
<Stack p={ 1 } pl={ 2 } width="100%" direction="row" alignItems="center">
|
|
531
|
+
<Stack width="100%" direction="row" gap={ 1 }>
|
|
532
|
+
<PanelHeaderTitle sx={ { display: 'flex', alignItems: 'center', gap: 0.5 } }>
|
|
533
|
+
<ColorFilterIcon fontSize="inherit" />
|
|
534
|
+
{ __( 'Variables Manager', 'elementor' ) }
|
|
535
|
+
</PanelHeaderTitle>
|
|
536
|
+
</Stack>
|
|
537
|
+
<Stack direction="row" gap={ 0.5 } alignItems="center">
|
|
538
|
+
<VariableManagerCreateMenu
|
|
539
|
+
onCreate={ handleCreateVariable }
|
|
540
|
+
variables={ variables }
|
|
541
|
+
menuState={ createMenuState }
|
|
542
|
+
/>
|
|
543
|
+
<CloseButton
|
|
544
|
+
aria-label="Close"
|
|
545
|
+
slotProps={ { icon: { fontSize: SIZE } } }
|
|
546
|
+
onClick={ () => {
|
|
547
|
+
handleClosePanel();
|
|
548
|
+
} }
|
|
549
|
+
/>
|
|
550
|
+
</Stack>
|
|
551
|
+
</Stack>
|
|
552
|
+
<Stack width="100%" direction="row" gap={ 1 }>
|
|
553
|
+
{ searchField }
|
|
554
|
+
</Stack>
|
|
555
|
+
<Divider sx={ { width: '100%' } } />
|
|
556
|
+
</Stack>
|
|
557
|
+
</PanelHeader>
|
|
558
|
+
<PanelBody
|
|
559
|
+
sx={ {
|
|
560
|
+
display: 'flex',
|
|
561
|
+
flexDirection: 'column',
|
|
562
|
+
height: '100%',
|
|
563
|
+
} }
|
|
564
|
+
>
|
|
565
|
+
{ bodyInner }
|
|
566
|
+
</PanelBody>
|
|
567
|
+
{ saveFooter }
|
|
568
|
+
</Panel>
|
|
569
|
+
);
|
|
570
|
+
|
|
571
|
+
const core = (
|
|
572
|
+
<>
|
|
573
|
+
{ panelChrome }
|
|
574
|
+
{ dialogs }
|
|
575
|
+
</>
|
|
443
576
|
);
|
|
577
|
+
|
|
578
|
+
return embedded ? core : <ThemeProvider>{ core }</ThemeProvider>;
|
|
444
579
|
}
|
|
445
580
|
|
|
446
581
|
const usePreventUnload = ( isDirty: boolean ) => {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
cssFilterFunctionPropUtil,
|
|
6
6
|
dropShadowFilterPropTypeUtil,
|
|
7
7
|
type KeyValuePropValue,
|
|
8
|
+
moveTransformPropTypeUtil,
|
|
8
9
|
type PropValue,
|
|
9
10
|
selectionSizePropTypeUtil,
|
|
10
11
|
type SelectionSizePropValue,
|
|
@@ -115,6 +116,25 @@ export const BoxShadowRepeaterLabel = ( { value }: Props ) => {
|
|
|
115
116
|
);
|
|
116
117
|
};
|
|
117
118
|
|
|
119
|
+
export const TransformRepeaterLabel = ( { value }: Props ) => {
|
|
120
|
+
const labels: string[] = [];
|
|
121
|
+
|
|
122
|
+
if ( moveTransformPropTypeUtil.isValid( value ) ) {
|
|
123
|
+
labels.push( __( 'Move:', 'elementor' ) );
|
|
124
|
+
|
|
125
|
+
const { x, y, z } = moveTransformPropTypeUtil.extract( value ) || {};
|
|
126
|
+
|
|
127
|
+
for ( const val of [ x, y, z ] ) {
|
|
128
|
+
const rendered = sizeValue( val );
|
|
129
|
+
if ( rendered ) {
|
|
130
|
+
labels.push( rendered );
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return <Box component="span">{ labels.join( ' ' ) }</Box>;
|
|
136
|
+
};
|
|
137
|
+
|
|
118
138
|
export const TransitionsSizeVariableLabel = ( { value: prop }: Props ) => {
|
|
119
139
|
let label = '';
|
|
120
140
|
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export {
|
|
2
|
+
VariablesManagerPanelEmbedded,
|
|
3
|
+
type VariablesManagerPanelEmbeddedProps,
|
|
4
|
+
} from './components/variables-manager/variables-manager-panel';
|
|
1
5
|
export { init } from './init';
|
|
2
6
|
export { GLOBAL_VARIABLES_URI } from './mcp/variables-resource';
|
|
3
7
|
export { sizeVariablePropTypeUtil } from './prop-types/size-variable-prop-type';
|