@elementor/editor-variables 3.33.0-161 → 3.33.0-163

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-161",
3
+ "version": "3.33.0-163",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,20 +39,20 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "3.33.0-161",
43
- "@elementor/editor-canvas": "3.33.0-161",
44
- "@elementor/editor-controls": "3.33.0-161",
45
- "@elementor/editor-current-user": "3.33.0-161",
46
- "@elementor/editor-editing-panel": "3.33.0-161",
47
- "@elementor/editor-mcp": "3.33.0-161",
48
- "@elementor/editor-panels": "3.33.0-161",
49
- "@elementor/editor-props": "3.33.0-161",
50
- "@elementor/editor-ui": "3.33.0-161",
51
- "@elementor/editor-v1-adapters": "3.33.0-161",
52
- "@elementor/http-client": "3.33.0-161",
42
+ "@elementor/editor": "3.33.0-163",
43
+ "@elementor/editor-canvas": "3.33.0-163",
44
+ "@elementor/editor-controls": "3.33.0-163",
45
+ "@elementor/editor-current-user": "3.33.0-163",
46
+ "@elementor/editor-editing-panel": "3.33.0-163",
47
+ "@elementor/editor-mcp": "3.33.0-163",
48
+ "@elementor/editor-panels": "3.33.0-163",
49
+ "@elementor/editor-props": "3.33.0-163",
50
+ "@elementor/editor-ui": "3.33.0-163",
51
+ "@elementor/editor-v1-adapters": "3.33.0-163",
52
+ "@elementor/http-client": "3.33.0-163",
53
53
  "@elementor/icons": "1.53.0",
54
- "@elementor/mixpanel": "3.33.0-161",
55
- "@elementor/schema": "3.33.0-161",
54
+ "@elementor/mixpanel": "3.33.0-163",
55
+ "@elementor/schema": "3.33.0-163",
56
56
  "@elementor/ui": "1.36.14",
57
57
  "@wordpress/i18n": "^5.13.0"
58
58
  },
@@ -18,10 +18,10 @@ export const EmptyState = ( { icon, title, message, onAdd }: Props ) => {
18
18
  <Stack
19
19
  gap={ 1 }
20
20
  alignItems="center"
21
- justifyContent="center"
21
+ justifyContent="flex-start"
22
22
  height="100%"
23
23
  color="text.secondary"
24
- sx={ { p: 2.5, pb: 5.5 } }
24
+ sx={ { p: 2.5, pt: 8, pb: 5.5 } }
25
25
  >
26
26
  { icon }
27
27
 
@@ -16,7 +16,7 @@ export const NoSearchResults = ( { searchValue, onClear, icon }: Props ) => {
16
16
  justifyContent="center"
17
17
  p={ 2.5 }
18
18
  color="text.secondary"
19
- sx={ { pb: 3.5, pt: 5 } }
19
+ sx={ { pb: 3.5, pt: 8 } }
20
20
  >
21
21
  { icon }
22
22
  <Typography align="center" variant="subtitle2">
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
- import { createElement } from 'react';
2
+ import { createElement, useRef } from 'react';
3
3
  import { PlusIcon } from '@elementor/icons';
4
- import { bindMenu, bindTrigger, IconButton, Menu, MenuItem, Typography, usePopupState } from '@elementor/ui';
4
+ import { bindMenu, bindTrigger, IconButton, Menu, MenuItem, type PopupState, Typography } from '@elementor/ui';
5
5
  import { __ } from '@wordpress/i18n';
6
6
 
7
7
  import { type TVariablesList } from '../../storage';
@@ -13,12 +13,16 @@ type VariableManagerCreateMenuProps = {
13
13
  variables: TVariablesList;
14
14
  onCreate: ( type: string, defaultName: string, defaultValue: string ) => void;
15
15
  disabled?: boolean;
16
+ menuState: PopupState;
16
17
  };
17
18
 
18
- export const VariableManagerCreateMenu = ( { variables, onCreate, disabled }: VariableManagerCreateMenuProps ) => {
19
- const menuState = usePopupState( {
20
- variant: 'popover',
21
- } );
19
+ export const VariableManagerCreateMenu = ( {
20
+ variables,
21
+ onCreate,
22
+ disabled,
23
+ menuState,
24
+ }: VariableManagerCreateMenuProps ) => {
25
+ const buttonRef = useRef< HTMLButtonElement >( null );
22
26
 
23
27
  const variableTypes = getVariableTypes();
24
28
 
@@ -40,6 +44,7 @@ export const VariableManagerCreateMenu = ( { variables, onCreate, disabled }: Va
40
44
  <>
41
45
  <IconButton
42
46
  { ...bindTrigger( menuState ) }
47
+ ref={ buttonRef }
43
48
  disabled={ disabled }
44
49
  size={ SIZE }
45
50
  aria-label={ __( 'Add variable', 'elementor' ) }
@@ -56,7 +61,7 @@ export const VariableManagerCreateMenu = ( { variables, onCreate, disabled }: Va
56
61
  elevation: 6,
57
62
  } }
58
63
  { ...bindMenu( menuState ) }
59
- anchorEl={ menuState.anchorEl }
64
+ anchorEl={ buttonRef.current }
60
65
  anchorOrigin={ {
61
66
  vertical: 'bottom',
62
67
  horizontal: 'right',
@@ -65,8 +70,7 @@ export const VariableManagerCreateMenu = ( { variables, onCreate, disabled }: Va
65
70
  vertical: 'top',
66
71
  horizontal: 'right',
67
72
  } }
68
- open={ menuState.isOpen }
69
- onClose={ menuState.close }
73
+ data-testid="variable-manager-create-menu"
70
74
  >
71
75
  { menuOptions.map( ( option ) => (
72
76
  <MenuItem
@@ -11,10 +11,11 @@ import {
11
11
  import { SaveChangesDialog, SearchField, ThemeProvider, useDialog } from '@elementor/editor-ui';
12
12
  import { changeEditMode } from '@elementor/editor-v1-adapters';
13
13
  import { ColorFilterIcon, TrashIcon } from '@elementor/icons';
14
- import { Alert, Box, Button, CloseButton, Divider, ErrorBoundary, Stack } from '@elementor/ui';
14
+ import { Alert, Box, Button, CloseButton, Divider, ErrorBoundary, Stack, usePopupState } from '@elementor/ui';
15
15
  import { __ } from '@wordpress/i18n';
16
16
 
17
17
  import { DeleteConfirmationDialog } from '../ui/delete-confirmation-dialog';
18
+ import { EmptyState } from '../ui/empty-state';
18
19
  import { NoSearchResults } from '../ui/no-search-results';
19
20
  import { useAutoEdit } from './hooks/use-auto-edit';
20
21
  import { useVariablesManagerState } from './hooks/use-variables-manager-state';
@@ -39,6 +40,10 @@ export function VariablesManagerPanel() {
39
40
  const { close: closePanel } = usePanelActions();
40
41
  const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
41
42
 
43
+ const createMenuState = usePopupState( {
44
+ variant: 'popover',
45
+ } );
46
+
42
47
  const {
43
48
  variables,
44
49
  isDirty,
@@ -99,7 +104,7 @@ export function VariablesManagerPanel() {
99
104
  },
100
105
  ];
101
106
 
102
- const hasVariables = Object.keys( variables ).length !== 0;
107
+ const hasVariables = Object.values( variables ).some( ( variable ) => ! variable.deleted );
103
108
 
104
109
  return (
105
110
  <ThemeProvider>
@@ -118,6 +123,7 @@ export function VariablesManagerPanel() {
118
123
  <VariableManagerCreateMenu
119
124
  onCreate={ handleCreateVariable }
120
125
  variables={ variables }
126
+ menuState={ createMenuState }
121
127
  />
122
128
  <CloseButton
123
129
  aria-label="Close"
@@ -143,6 +149,7 @@ export function VariablesManagerPanel() {
143
149
  onSearch={ handleSearch }
144
150
  />
145
151
  <Divider sx={ { width: '100%' } } />
152
+
146
153
  { hasVariables && (
147
154
  <VariablesManagerTable
148
155
  menuActions={ menuActions }
@@ -154,13 +161,25 @@ export function VariablesManagerPanel() {
154
161
  />
155
162
  ) }
156
163
 
157
- { ! hasVariables && (
164
+ { ! hasVariables && searchValue && (
158
165
  <NoSearchResults
159
166
  searchValue={ searchValue }
160
167
  onClear={ () => handleSearch( '' ) }
161
168
  icon={ <ColorFilterIcon fontSize="large" /> }
162
169
  />
163
170
  ) }
171
+
172
+ { ! hasVariables && ! searchValue && (
173
+ <EmptyState
174
+ title={ __( 'Create your first variable', 'elementor' ) }
175
+ message={ __(
176
+ 'Variables are saved attributes that you can apply anywhere on your site.',
177
+ 'elementor'
178
+ ) }
179
+ icon={ <ColorFilterIcon fontSize="large" /> }
180
+ onAdd={ createMenuState.open }
181
+ />
182
+ ) }
164
183
  </PanelBody>
165
184
 
166
185
  <PanelFooter>
@@ -20,8 +20,8 @@ import { __ } from '@wordpress/i18n';
20
20
  import { type TVariablesList } from '../../storage';
21
21
  import { getVariableType } from '../../variables-registry/variable-type-registry';
22
22
  import { LabelField } from '../fields/label-field';
23
- import { VariableEditMenu, type VariableManagerMenuAction } from './utils/variable-edit-menu';
24
- import { VariableTableCell } from './utils/variable-table-cell';
23
+ import { VariableEditMenu, type VariableManagerMenuAction } from './ui/variable-edit-menu';
24
+ import { VariableTableCell } from './ui/variable-table-cell';
25
25
  import { VariableEditableCell } from './variable-editable-cell';
26
26
 
27
27
  type Props = {