@elementor/editor-variables 4.2.0-880 → 4.2.0-882
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 +0 -10
- package/dist/index.d.ts +0 -10
- package/dist/index.js +278 -426
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +273 -443
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/variable-selection-popover.tsx +3 -9
- package/src/components/variables-manager/hooks/use-variables-manager-state.ts +18 -2
- package/src/components/variables-manager/ui/variable-table-row.tsx +1 -1
- package/src/components/variables-manager/variables-manager-panel.tsx +158 -295
- package/src/init.ts +0 -19
- package/src/components/open-panel-from-event.tsx +0 -46
- package/src/components/open-panel-from-url.tsx +0 -40
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-variables",
|
|
3
|
-
"version": "4.2.0-
|
|
3
|
+
"version": "4.2.0-882",
|
|
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.2.0-
|
|
43
|
-
"@elementor/editor-canvas": "4.2.0-
|
|
44
|
-
"@elementor/editor-controls": "4.2.0-
|
|
45
|
-
"@elementor/editor-current-user": "4.2.0-
|
|
46
|
-
"@elementor/editor-mcp": "4.2.0-
|
|
47
|
-
"@elementor/editor-panels": "4.2.0-
|
|
48
|
-
"@elementor/editor-props": "4.2.0-
|
|
49
|
-
"@elementor/editor-ui": "4.2.0-
|
|
50
|
-
"@elementor/editor-v1-adapters": "4.2.0-
|
|
51
|
-
"@elementor/menus": "4.2.0-
|
|
52
|
-
"@elementor/http-client": "4.2.0-
|
|
42
|
+
"@elementor/editor": "4.2.0-882",
|
|
43
|
+
"@elementor/editor-canvas": "4.2.0-882",
|
|
44
|
+
"@elementor/editor-controls": "4.2.0-882",
|
|
45
|
+
"@elementor/editor-current-user": "4.2.0-882",
|
|
46
|
+
"@elementor/editor-mcp": "4.2.0-882",
|
|
47
|
+
"@elementor/editor-panels": "4.2.0-882",
|
|
48
|
+
"@elementor/editor-props": "4.2.0-882",
|
|
49
|
+
"@elementor/editor-ui": "4.2.0-882",
|
|
50
|
+
"@elementor/editor-v1-adapters": "4.2.0-882",
|
|
51
|
+
"@elementor/menus": "4.2.0-882",
|
|
52
|
+
"@elementor/http-client": "4.2.0-882",
|
|
53
53
|
"@elementor/icons": "~1.75.1",
|
|
54
|
-
"@elementor/events": "4.2.0-
|
|
55
|
-
"@elementor/schema": "4.2.0-
|
|
54
|
+
"@elementor/events": "4.2.0-882",
|
|
55
|
+
"@elementor/schema": "4.2.0-882",
|
|
56
56
|
"@elementor/ui": "1.37.5",
|
|
57
|
-
"@elementor/utils": "4.2.0-
|
|
57
|
+
"@elementor/utils": "4.2.0-882",
|
|
58
58
|
"@wordpress/i18n": "^5.13.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -10,7 +10,6 @@ import { useQuotaPermissions } from '../hooks/use-quota-permissions';
|
|
|
10
10
|
import { type Variable } from '../types';
|
|
11
11
|
import { VariableCreation } from './variable-creation';
|
|
12
12
|
import { VariableEdit } from './variable-edit';
|
|
13
|
-
import { usePanelActions } from './variables-manager/variables-manager-panel';
|
|
14
13
|
import { VariablesSelection } from './variables-selection';
|
|
15
14
|
|
|
16
15
|
const VIEW_LIST = 'list';
|
|
@@ -28,16 +27,11 @@ type Props = {
|
|
|
28
27
|
export const VariableSelectionPopover = ( { closePopover, propTypeKey, selectedVariable }: Props ) => {
|
|
29
28
|
const [ currentView, setCurrentView ] = useState< View >( VIEW_LIST );
|
|
30
29
|
const [ editId, setEditId ] = useState< string >( '' );
|
|
31
|
-
const { open: openStandaloneVariablesPanel } = usePanelActions();
|
|
32
30
|
const onSettingsAvailable = isExperimentActive( 'e_variables_manager' )
|
|
33
31
|
? () => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
38
|
-
} else {
|
|
39
|
-
openStandaloneVariablesPanel();
|
|
40
|
-
}
|
|
32
|
+
window.dispatchEvent(
|
|
33
|
+
new CustomEvent( 'elementor/toggle-design-system', { detail: { tab: 'variables' as const } } )
|
|
34
|
+
);
|
|
41
35
|
}
|
|
42
36
|
: undefined;
|
|
43
37
|
|
|
@@ -33,8 +33,24 @@ export const useVariablesManagerState = () => {
|
|
|
33
33
|
|
|
34
34
|
const handleOnChange = useCallback(
|
|
35
35
|
( newVariables: TVariablesList ) => {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const hasChanges = Object.entries( newVariables ).some( ( [ id, newVar ] ) => {
|
|
37
|
+
const existingVar = variables[ id ];
|
|
38
|
+
if ( ! existingVar ) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return (
|
|
42
|
+
existingVar.label !== newVar.label ||
|
|
43
|
+
existingVar.value !== newVar.value ||
|
|
44
|
+
existingVar.order !== newVar.order ||
|
|
45
|
+
existingVar.type !== newVar.type ||
|
|
46
|
+
( existingVar.sync_to_v3 ?? false ) !== ( newVar.sync_to_v3 ?? false )
|
|
47
|
+
);
|
|
48
|
+
} );
|
|
49
|
+
|
|
50
|
+
if ( hasChanges ) {
|
|
51
|
+
setVariables( { ...variables, ...newVariables } );
|
|
52
|
+
setIsDirty( true );
|
|
53
|
+
}
|
|
38
54
|
},
|
|
39
55
|
[ variables ]
|
|
40
56
|
);
|
|
@@ -162,7 +162,7 @@ export const VariableRow = (
|
|
|
162
162
|
value,
|
|
163
163
|
onChange,
|
|
164
164
|
onPropTypeKeyChange: ( type ) => {
|
|
165
|
-
if ( ! isDisabled ) {
|
|
165
|
+
if ( ! isDisabled && type !== row.type ) {
|
|
166
166
|
handleOnChange( {
|
|
167
167
|
...variables,
|
|
168
168
|
[ row.id ]: { ...variables[ row.id ], type },
|
|
@@ -1,29 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useCallback, useEffect,
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
3
|
import { useSuppressedMessage } from '@elementor/editor-current-user';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
Panel,
|
|
7
|
-
PanelBody,
|
|
8
|
-
PanelFooter,
|
|
9
|
-
PanelHeader,
|
|
10
|
-
PanelHeaderTitle,
|
|
11
|
-
} from '@elementor/editor-panels';
|
|
12
|
-
import { ConfirmationDialog, SaveChangesDialog, SearchField, ThemeProvider, useDialog } from '@elementor/editor-ui';
|
|
13
|
-
import { changeEditMode } from '@elementor/editor-v1-adapters';
|
|
4
|
+
import { PanelBody, PanelFooter } from '@elementor/editor-panels';
|
|
5
|
+
import { ConfirmationDialog, SaveChangesDialog, SearchField, useDialog } from '@elementor/editor-ui';
|
|
14
6
|
import { AlertTriangleFilledIcon, ColorFilterIcon, CopyIcon, TrashIcon } from '@elementor/icons';
|
|
15
|
-
import {
|
|
16
|
-
Alert,
|
|
17
|
-
AlertAction,
|
|
18
|
-
AlertTitle,
|
|
19
|
-
Box,
|
|
20
|
-
Button,
|
|
21
|
-
CloseButton,
|
|
22
|
-
Divider,
|
|
23
|
-
Infotip,
|
|
24
|
-
Stack,
|
|
25
|
-
usePopupState,
|
|
26
|
-
} from '@elementor/ui';
|
|
7
|
+
import { Alert, AlertAction, AlertTitle, Box, Button, Divider, Infotip, Stack, usePopupState } from '@elementor/ui';
|
|
27
8
|
import { __ } from '@wordpress/i18n';
|
|
28
9
|
|
|
29
10
|
import { trackVariablesManagerEvent, trackVariableSyncToV3 } from '../../utils/tracking';
|
|
@@ -35,10 +16,9 @@ import { NoSearchResults } from '../ui/no-search-results';
|
|
|
35
16
|
import { useAutoEdit } from './hooks/use-auto-edit';
|
|
36
17
|
import { useErrorNavigation } from './hooks/use-error-navigation';
|
|
37
18
|
import { useVariablesManagerState } from './hooks/use-variables-manager-state';
|
|
38
|
-
import {
|
|
19
|
+
import { VariableManagerCreateMenu } from './variables-manager-create-menu';
|
|
39
20
|
import { VariablesManagerTable } from './variables-manager-table';
|
|
40
21
|
|
|
41
|
-
const id = 'variables-manager';
|
|
42
22
|
const STOP_SYNC_MESSAGE_KEY = 'stop-sync-variable';
|
|
43
23
|
|
|
44
24
|
type StopSyncConfirmationDialogProps = {
|
|
@@ -47,67 +27,26 @@ type StopSyncConfirmationDialogProps = {
|
|
|
47
27
|
onConfirm: () => void;
|
|
48
28
|
};
|
|
49
29
|
|
|
50
|
-
export const { panel, usePanelActions } = createPanel( {
|
|
51
|
-
id,
|
|
52
|
-
component: VariablesManagerPanel,
|
|
53
|
-
allowedEditModes: [ 'edit', id ],
|
|
54
|
-
onOpen: () => {
|
|
55
|
-
changeEditMode( id );
|
|
56
|
-
},
|
|
57
|
-
onClose: async () => {
|
|
58
|
-
changeEditMode( 'edit' );
|
|
59
|
-
},
|
|
60
|
-
isOpenPreviousElement: true,
|
|
61
|
-
} );
|
|
62
|
-
|
|
63
30
|
export type VariablesManagerPanelEmbeddedProps = {
|
|
64
31
|
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
32
|
onExposeCloseAttempt?: ( attemptClose: ( () => void ) | null ) => void;
|
|
70
33
|
};
|
|
71
34
|
|
|
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
35
|
export function VariablesManagerPanelEmbedded( {
|
|
79
36
|
onRequestClose,
|
|
80
37
|
onExposeCloseAttempt,
|
|
81
38
|
}: VariablesManagerPanelEmbeddedProps ) {
|
|
82
39
|
return (
|
|
83
|
-
<
|
|
84
|
-
embedded
|
|
85
|
-
onRequestClose={ onRequestClose }
|
|
86
|
-
onExposeCloseAttempt={ onExposeCloseAttempt }
|
|
87
|
-
/>
|
|
40
|
+
<VariablesManagerPanelContent onRequestClose={ onRequestClose } onExposeCloseAttempt={ onExposeCloseAttempt } />
|
|
88
41
|
);
|
|
89
42
|
}
|
|
90
43
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
type VariablesManagerPanelRootProps = {
|
|
96
|
-
embedded?: boolean;
|
|
97
|
-
onRequestClose?: () => void | Promise< void >;
|
|
44
|
+
type VariablesManagerPanelContentProps = {
|
|
45
|
+
onRequestClose: () => void | Promise< void >;
|
|
98
46
|
onExposeCloseAttempt?: ( attemptClose: ( () => void ) | null ) => void;
|
|
99
47
|
};
|
|
100
48
|
|
|
101
|
-
function
|
|
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
|
-
);
|
|
49
|
+
function VariablesManagerPanelContent( { onRequestClose, onExposeCloseAttempt }: VariablesManagerPanelContentProps ) {
|
|
111
50
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
112
51
|
const [ isStopSyncSuppressed ] = useSuppressedMessage( STOP_SYNC_MESSAGE_KEY );
|
|
113
52
|
|
|
@@ -148,18 +87,18 @@ function VariablesManagerPanelRoot( {
|
|
|
148
87
|
return;
|
|
149
88
|
}
|
|
150
89
|
|
|
151
|
-
void
|
|
152
|
-
}, [ isDirty, openSaveChangesDialog,
|
|
90
|
+
void onRequestClose();
|
|
91
|
+
}, [ isDirty, openSaveChangesDialog, onRequestClose ] );
|
|
153
92
|
|
|
154
93
|
useEffect( () => {
|
|
155
|
-
if ( !
|
|
94
|
+
if ( ! onExposeCloseAttempt ) {
|
|
156
95
|
return;
|
|
157
96
|
}
|
|
158
97
|
|
|
159
98
|
onExposeCloseAttempt( () => handleClosePanel() );
|
|
160
99
|
|
|
161
100
|
return () => onExposeCloseAttempt( null );
|
|
162
|
-
}, [
|
|
101
|
+
}, [ onExposeCloseAttempt, handleClosePanel ] );
|
|
163
102
|
|
|
164
103
|
const handleCreateVariable = useCallback(
|
|
165
104
|
( type: string, defaultName: string, defaultValue: string ) => {
|
|
@@ -296,127 +235,154 @@ function VariablesManagerPanelRoot( {
|
|
|
296
235
|
|
|
297
236
|
const hasVariables = Object.keys( variables ).length > 0;
|
|
298
237
|
|
|
299
|
-
|
|
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
|
-
);
|
|
322
|
-
|
|
323
|
-
const bodyInner = (
|
|
238
|
+
return (
|
|
324
239
|
<>
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
/>
|
|
334
|
-
) }
|
|
335
|
-
|
|
336
|
-
{ ! hasVariables && searchValue && (
|
|
337
|
-
<NoSearchResults
|
|
338
|
-
searchValue={ searchValue }
|
|
339
|
-
onClear={ () => handleSearch( '' ) }
|
|
340
|
-
icon={ <ColorFilterIcon fontSize="large" /> }
|
|
341
|
-
/>
|
|
342
|
-
) }
|
|
343
|
-
|
|
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'
|
|
350
|
-
) }
|
|
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
|
-
}
|
|
385
|
-
>
|
|
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
|
-
},
|
|
240
|
+
<Stack
|
|
241
|
+
direction="column"
|
|
242
|
+
sx={ {
|
|
243
|
+
height: '100%',
|
|
244
|
+
width: '100%',
|
|
245
|
+
flex: 1,
|
|
246
|
+
minHeight: 0,
|
|
247
|
+
overflow: 'hidden',
|
|
401
248
|
} }
|
|
402
249
|
>
|
|
403
|
-
<
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
250
|
+
<Stack
|
|
251
|
+
direction="row"
|
|
252
|
+
alignItems="center"
|
|
253
|
+
spacing={ 1 }
|
|
254
|
+
width="100%"
|
|
255
|
+
sx={ {
|
|
256
|
+
flexShrink: 0,
|
|
257
|
+
px: 2,
|
|
258
|
+
pb: 1,
|
|
259
|
+
} }
|
|
411
260
|
>
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
261
|
+
<SearchField
|
|
262
|
+
placeholder={ __( 'Search', 'elementor' ) }
|
|
263
|
+
value={ searchValue }
|
|
264
|
+
onSearch={ handleSearch }
|
|
265
|
+
sx={ {
|
|
266
|
+
flex: 1,
|
|
267
|
+
minWidth: 0,
|
|
268
|
+
px: 0,
|
|
269
|
+
py: 0,
|
|
270
|
+
display: 'flex',
|
|
271
|
+
alignItems: 'center',
|
|
272
|
+
alignSelf: 'stretch',
|
|
273
|
+
} }
|
|
274
|
+
/>
|
|
275
|
+
<Box sx={ { display: 'flex', flexShrink: 0, alignItems: 'center' } }>
|
|
276
|
+
<VariableManagerCreateMenu
|
|
277
|
+
outlinedTrigger
|
|
278
|
+
onCreate={ handleCreateVariable }
|
|
279
|
+
variables={ variables }
|
|
280
|
+
menuState={ createMenuState }
|
|
281
|
+
/>
|
|
282
|
+
</Box>
|
|
283
|
+
</Stack>
|
|
284
|
+
<Divider sx={ { width: '100%' } } />
|
|
285
|
+
<PanelBody
|
|
286
|
+
sx={ {
|
|
287
|
+
display: 'flex',
|
|
288
|
+
flexDirection: 'column',
|
|
289
|
+
flex: 1,
|
|
290
|
+
minHeight: 0,
|
|
291
|
+
} }
|
|
292
|
+
>
|
|
293
|
+
{ hasVariables && (
|
|
294
|
+
<VariablesManagerTable
|
|
295
|
+
menuActions={ buildMenuActions }
|
|
296
|
+
variables={ variables }
|
|
297
|
+
onChange={ handleOnChange }
|
|
298
|
+
autoEditVariableId={ autoEditVariableId }
|
|
299
|
+
onAutoEditComplete={ handleAutoEditComplete }
|
|
300
|
+
onFieldError={ setIsSaveDisabled }
|
|
301
|
+
/>
|
|
302
|
+
) }
|
|
417
303
|
|
|
418
|
-
|
|
419
|
-
|
|
304
|
+
{ ! hasVariables && searchValue && (
|
|
305
|
+
<NoSearchResults
|
|
306
|
+
searchValue={ searchValue }
|
|
307
|
+
onClear={ () => handleSearch( '' ) }
|
|
308
|
+
icon={ <ColorFilterIcon fontSize="large" /> }
|
|
309
|
+
/>
|
|
310
|
+
) }
|
|
311
|
+
|
|
312
|
+
{ ! hasVariables && ! searchValue && (
|
|
313
|
+
<EmptyState
|
|
314
|
+
title={ __( 'Create your first variable', 'elementor' ) }
|
|
315
|
+
message={ __(
|
|
316
|
+
'Variables are saved attributes that you can apply anywhere on your site.',
|
|
317
|
+
'elementor'
|
|
318
|
+
) }
|
|
319
|
+
icon={ <ColorFilterIcon fontSize="large" /> }
|
|
320
|
+
onAdd={ createMenuState.open }
|
|
321
|
+
/>
|
|
322
|
+
) }
|
|
323
|
+
</PanelBody>
|
|
324
|
+
<PanelFooter>
|
|
325
|
+
<Infotip
|
|
326
|
+
placement="right"
|
|
327
|
+
open={ !! serverError }
|
|
328
|
+
content={
|
|
329
|
+
serverError ? (
|
|
330
|
+
<Alert
|
|
331
|
+
severity={ serverError.severity ?? 'error' }
|
|
332
|
+
action={
|
|
333
|
+
serverError.action?.label ? (
|
|
334
|
+
<AlertAction onClick={ serverError.action.callback }>
|
|
335
|
+
{ serverError.action.label }
|
|
336
|
+
</AlertAction>
|
|
337
|
+
) : undefined
|
|
338
|
+
}
|
|
339
|
+
onClose={
|
|
340
|
+
! serverError.action?.label
|
|
341
|
+
? () => {
|
|
342
|
+
setServerError( null );
|
|
343
|
+
setIsSaveDisabled( false );
|
|
344
|
+
}
|
|
345
|
+
: undefined
|
|
346
|
+
}
|
|
347
|
+
icon={
|
|
348
|
+
serverError.IconComponent ? (
|
|
349
|
+
<serverError.IconComponent />
|
|
350
|
+
) : (
|
|
351
|
+
<AlertTriangleFilledIcon />
|
|
352
|
+
)
|
|
353
|
+
}
|
|
354
|
+
>
|
|
355
|
+
<AlertTitle>{ serverError.message }</AlertTitle>
|
|
356
|
+
{ serverError.action?.message }
|
|
357
|
+
</Alert>
|
|
358
|
+
) : null
|
|
359
|
+
}
|
|
360
|
+
arrow={ false }
|
|
361
|
+
slotProps={ {
|
|
362
|
+
popper: {
|
|
363
|
+
modifiers: [
|
|
364
|
+
{
|
|
365
|
+
name: 'offset',
|
|
366
|
+
options: { offset: [ -10, 10 ] },
|
|
367
|
+
},
|
|
368
|
+
],
|
|
369
|
+
},
|
|
370
|
+
} }
|
|
371
|
+
>
|
|
372
|
+
<Button
|
|
373
|
+
fullWidth
|
|
374
|
+
size="small"
|
|
375
|
+
color="global"
|
|
376
|
+
variant="contained"
|
|
377
|
+
disabled={ isSaveDisabled || ! isDirty || isSaving }
|
|
378
|
+
onClick={ handleSaveClick }
|
|
379
|
+
loading={ isSaving }
|
|
380
|
+
>
|
|
381
|
+
{ __( 'Save changes', 'elementor' ) }
|
|
382
|
+
</Button>
|
|
383
|
+
</Infotip>
|
|
384
|
+
</PanelFooter>
|
|
385
|
+
</Stack>
|
|
420
386
|
{ deleteConfirmation && (
|
|
421
387
|
<DeleteConfirmationDialog
|
|
422
388
|
open
|
|
@@ -453,7 +419,7 @@ function VariablesManagerPanelRoot( {
|
|
|
453
419
|
label: __( 'Discard', 'elementor' ),
|
|
454
420
|
action: () => {
|
|
455
421
|
closeSaveChangesDialog();
|
|
456
|
-
void
|
|
422
|
+
void onRequestClose();
|
|
457
423
|
},
|
|
458
424
|
},
|
|
459
425
|
confirm: {
|
|
@@ -462,7 +428,7 @@ function VariablesManagerPanelRoot( {
|
|
|
462
428
|
const result = await handleSaveClick();
|
|
463
429
|
closeSaveChangesDialog();
|
|
464
430
|
if ( result?.success ) {
|
|
465
|
-
void
|
|
431
|
+
void onRequestClose();
|
|
466
432
|
}
|
|
467
433
|
},
|
|
468
434
|
},
|
|
@@ -472,109 +438,6 @@ function VariablesManagerPanelRoot( {
|
|
|
472
438
|
) }
|
|
473
439
|
</>
|
|
474
440
|
);
|
|
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
|
-
} }
|
|
516
|
-
>
|
|
517
|
-
{ bodyInner }
|
|
518
|
-
</PanelBody>
|
|
519
|
-
{ saveFooter }
|
|
520
|
-
</Stack>
|
|
521
|
-
) : (
|
|
522
|
-
<Panel>
|
|
523
|
-
<PanelHeader
|
|
524
|
-
sx={ {
|
|
525
|
-
height: 'unset',
|
|
526
|
-
} }
|
|
527
|
-
>
|
|
528
|
-
<Stack width="100%" direction="column" alignItems="center">
|
|
529
|
-
<Stack p={ 1 } pl={ 2 } width="100%" direction="row" alignItems="center">
|
|
530
|
-
<Stack width="100%" direction="row" gap={ 1 }>
|
|
531
|
-
<PanelHeaderTitle sx={ { display: 'flex', alignItems: 'center', gap: 0.5 } }>
|
|
532
|
-
<ColorFilterIcon fontSize="inherit" />
|
|
533
|
-
{ __( 'Variables Manager', 'elementor' ) }
|
|
534
|
-
</PanelHeaderTitle>
|
|
535
|
-
</Stack>
|
|
536
|
-
<Stack direction="row" gap={ 0.5 } alignItems="center">
|
|
537
|
-
<VariableManagerCreateMenu
|
|
538
|
-
onCreate={ handleCreateVariable }
|
|
539
|
-
variables={ variables }
|
|
540
|
-
menuState={ createMenuState }
|
|
541
|
-
/>
|
|
542
|
-
<CloseButton
|
|
543
|
-
aria-label="Close"
|
|
544
|
-
slotProps={ { icon: { fontSize: SIZE } } }
|
|
545
|
-
onClick={ () => {
|
|
546
|
-
handleClosePanel();
|
|
547
|
-
} }
|
|
548
|
-
/>
|
|
549
|
-
</Stack>
|
|
550
|
-
</Stack>
|
|
551
|
-
<Stack width="100%" direction="row" gap={ 1 }>
|
|
552
|
-
{ searchField }
|
|
553
|
-
</Stack>
|
|
554
|
-
<Divider sx={ { width: '100%' } } />
|
|
555
|
-
</Stack>
|
|
556
|
-
</PanelHeader>
|
|
557
|
-
<PanelBody
|
|
558
|
-
sx={ {
|
|
559
|
-
display: 'flex',
|
|
560
|
-
flexDirection: 'column',
|
|
561
|
-
height: '100%',
|
|
562
|
-
} }
|
|
563
|
-
>
|
|
564
|
-
{ bodyInner }
|
|
565
|
-
</PanelBody>
|
|
566
|
-
{ saveFooter }
|
|
567
|
-
</Panel>
|
|
568
|
-
);
|
|
569
|
-
|
|
570
|
-
const core = (
|
|
571
|
-
<>
|
|
572
|
-
{ panelChrome }
|
|
573
|
-
{ dialogs }
|
|
574
|
-
</>
|
|
575
|
-
);
|
|
576
|
-
|
|
577
|
-
return embedded ? core : <ThemeProvider>{ core }</ThemeProvider>;
|
|
578
441
|
}
|
|
579
442
|
|
|
580
443
|
const usePreventUnload = ( isDirty: boolean ) => {
|
package/src/init.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { injectIntoLogic, injectIntoTop } from '@elementor/editor';
|
|
2
2
|
import { registerControlReplacement } from '@elementor/editor-controls';
|
|
3
3
|
import { getMCPByDomain } from '@elementor/editor-mcp';
|
|
4
|
-
import { __registerPanel as registerPanel } from '@elementor/editor-panels';
|
|
5
4
|
import { isTransformable, type PropValue } from '@elementor/editor-props';
|
|
6
|
-
import { isExperimentActive } from '@elementor/editor-v1-adapters';
|
|
7
5
|
import { controlActionsMenu } from '@elementor/menus';
|
|
8
6
|
|
|
9
7
|
import { GlobalStylesImportListener } from './components/global-styles-import-listener';
|
|
10
|
-
import { OpenPanelFromEvent } from './components/open-panel-from-event';
|
|
11
|
-
import { OpenPanelFromUrl } from './components/open-panel-from-url';
|
|
12
|
-
import { panel } from './components/variables-manager/variables-manager-panel';
|
|
13
8
|
import { VariableControl } from './controls/variable-control';
|
|
14
9
|
import { usePropVariableAction } from './hooks/use-prop-variable-action';
|
|
15
10
|
import { initMcp } from './mcp';
|
|
@@ -68,20 +63,6 @@ export function init() {
|
|
|
68
63
|
id: 'variables-import-listener',
|
|
69
64
|
component: GlobalStylesImportListener,
|
|
70
65
|
} );
|
|
71
|
-
|
|
72
|
-
if ( ! isExperimentActive( 'e_editor_design_system_panel' ) ) {
|
|
73
|
-
injectIntoLogic( {
|
|
74
|
-
id: 'variables-open-panel-from-url',
|
|
75
|
-
component: OpenPanelFromUrl,
|
|
76
|
-
} );
|
|
77
|
-
|
|
78
|
-
injectIntoLogic( {
|
|
79
|
-
id: 'variables-open-panel-from-event',
|
|
80
|
-
component: OpenPanelFromEvent,
|
|
81
|
-
} );
|
|
82
|
-
|
|
83
|
-
registerPanel( panel );
|
|
84
|
-
}
|
|
85
66
|
}
|
|
86
67
|
|
|
87
68
|
function hasVariableAssigned( value: PropValue ) {
|