@elementor/editor-variables 3.33.0-110 → 3.33.0-112

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-variables",
3
- "version": "3.33.0-110",
3
+ "version": "3.33.0-112",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,18 +39,18 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "3.33.0-110",
43
- "@elementor/editor-canvas": "3.33.0-110",
44
- "@elementor/editor-controls": "3.33.0-110",
45
- "@elementor/editor-current-user": "3.33.0-110",
46
- "@elementor/editor-editing-panel": "3.33.0-110",
47
- "@elementor/editor-panels": "3.33.0-110",
48
- "@elementor/editor-props": "3.33.0-110",
49
- "@elementor/editor-ui": "3.33.0-110",
50
- "@elementor/editor-v1-adapters": "3.33.0-110",
51
- "@elementor/http-client": "3.33.0-110",
42
+ "@elementor/editor": "3.33.0-112",
43
+ "@elementor/editor-canvas": "3.33.0-112",
44
+ "@elementor/editor-controls": "3.33.0-112",
45
+ "@elementor/editor-current-user": "3.33.0-112",
46
+ "@elementor/editor-editing-panel": "3.33.0-112",
47
+ "@elementor/editor-panels": "3.33.0-112",
48
+ "@elementor/editor-props": "3.33.0-112",
49
+ "@elementor/editor-ui": "3.33.0-112",
50
+ "@elementor/editor-v1-adapters": "3.33.0-112",
51
+ "@elementor/http-client": "3.33.0-112",
52
52
  "@elementor/icons": "1.46.0",
53
- "@elementor/schema": "3.33.0-110",
53
+ "@elementor/schema": "3.33.0-112",
54
54
  "@elementor/ui": "1.36.12",
55
55
  "@wordpress/i18n": "^5.13.0"
56
56
  },
@@ -17,6 +17,7 @@ import { __ } from '@wordpress/i18n';
17
17
  import { getVariables } from '../../hooks/use-prop-variables';
18
18
  import { service } from '../../service';
19
19
  import { type TVariablesList } from '../../storage';
20
+ import { DeleteConfirmationDialog } from '../ui/delete-confirmation-dialog';
20
21
  import { VariablesManagerTable } from './variables-manager-table';
21
22
 
22
23
  const id = 'variables-manager';
@@ -36,10 +37,11 @@ export const { panel, usePanelActions } = createPanel( {
36
37
  export function VariablesManagerPanel() {
37
38
  const { close: closePanel } = usePanelActions();
38
39
 
39
- const [ isDirty, setIsDirty ] = useState( false );
40
40
  const [ variables, setVariables ] = useState( getVariables( false ) );
41
41
  const [ deletedVariables, setDeletedVariables ] = useState< string[] >( [] );
42
+ const [ deleteConfirmation, setDeleteConfirmation ] = useState< { id: string; label: string } | null >( null );
42
43
 
44
+ const [ isDirty, setIsDirty ] = useState( false );
43
45
  const [ isSaving, setIsSaving ] = useState( false );
44
46
 
45
47
  usePreventUnload( isDirty );
@@ -68,13 +70,20 @@ export function VariablesManagerPanel() {
68
70
  icon: TrashIcon,
69
71
  color: 'error.main',
70
72
  onClick: ( itemId: string ) => {
71
- setDeletedVariables( [ ...deletedVariables, itemId ] );
72
- setVariables( { ...variables, [ itemId ]: { ...variables[ itemId ], deleted: true } } );
73
- setIsDirty( true );
73
+ if ( variables[ itemId ] ) {
74
+ setDeleteConfirmation( { id: itemId, label: variables[ itemId ].label } );
75
+ }
74
76
  },
75
77
  },
76
78
  ];
77
79
 
80
+ const handleDeleteVariable = ( itemId: string ) => {
81
+ setDeletedVariables( [ ...deletedVariables, itemId ] );
82
+ setVariables( { ...variables, [ itemId ]: { ...variables[ itemId ], deleted: true } } );
83
+ setIsDirty( true );
84
+ setDeleteConfirmation( null );
85
+ };
86
+
78
87
  const handleOnChange = ( newVariables: TVariablesList ) => {
79
88
  setVariables( newVariables );
80
89
  setIsDirty( true );
@@ -130,6 +139,15 @@ export function VariablesManagerPanel() {
130
139
  </Button>
131
140
  </PanelFooter>
132
141
  </Panel>
142
+
143
+ { deleteConfirmation && (
144
+ <DeleteConfirmationDialog
145
+ open
146
+ label={ deleteConfirmation.label }
147
+ onConfirm={ () => handleDeleteVariable( deleteConfirmation.id ) }
148
+ closeDialog={ () => setDeleteConfirmation( null ) }
149
+ />
150
+ ) }
133
151
  </ErrorBoundary>
134
152
  </ThemeProvider>
135
153
  );