@elementor/editor-variables 0.14.0 → 0.15.0

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.
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useRef, useState } from 'react';
3
- import { useBoundProp } from '@elementor/editor-controls';
3
+ import { PopoverContent, useBoundProp } from '@elementor/editor-controls';
4
+ import { PopoverScrollableContent } from '@elementor/editor-editing-panel';
4
5
  import { PopoverHeader } from '@elementor/editor-ui';
5
6
  import { ArrowLeftIcon, BrushIcon } from '@elementor/icons';
6
7
  import {
@@ -10,7 +11,6 @@ import {
10
11
  FormLabel,
11
12
  Grid,
12
13
  IconButton,
13
- Stack,
14
14
  TextField,
15
15
  UnstableColorField,
16
16
  } from '@elementor/ui';
@@ -18,6 +18,7 @@ import { __ } from '@wordpress/i18n';
18
18
 
19
19
  import { createVariable } from '../hooks/use-prop-variables';
20
20
  import { colorVariablePropTypeUtil } from '../prop-types/color-variable-prop-type';
21
+ import { usePopoverContentRef } from './variable-selection-popover.context';
21
22
 
22
23
  const SIZE = 'tiny';
23
24
 
@@ -32,7 +33,8 @@ export const ColorVariableCreation = ( { onGoBack, onClose }: Props ) => {
32
33
  const [ color, setColor ] = useState( '' );
33
34
  const [ label, setLabel ] = useState( '' );
34
35
 
35
- const anchorRef = useRef< HTMLDivElement >( null );
36
+ const defaultRef = useRef< HTMLDivElement >( null );
37
+ const anchorRef = usePopoverContentRef() ?? defaultRef;
36
38
 
37
39
  const resetFields = () => {
38
40
  setColor( '' );
@@ -60,7 +62,7 @@ export const ColorVariableCreation = ( { onGoBack, onClose }: Props ) => {
60
62
  };
61
63
 
62
64
  return (
63
- <>
65
+ <PopoverScrollableContent height="auto">
64
66
  <PopoverHeader
65
67
  icon={
66
68
  <>
@@ -78,10 +80,10 @@ export const ColorVariableCreation = ( { onGoBack, onClose }: Props ) => {
78
80
 
79
81
  <Divider />
80
82
 
81
- <Stack p={ 1.5 } gap={ 1.5 }>
83
+ <PopoverContent p={ 2 }>
82
84
  <Grid container gap={ 0.75 } alignItems="center">
83
85
  <Grid item xs={ 12 }>
84
- <FormLabel size="small">{ __( 'Name', 'elementor' ) }</FormLabel>
86
+ <FormLabel size="tiny">{ __( 'Name', 'elementor' ) }</FormLabel>
85
87
  </Grid>
86
88
  <Grid item xs={ 12 }>
87
89
  <TextField
@@ -95,7 +97,7 @@ export const ColorVariableCreation = ( { onGoBack, onClose }: Props ) => {
95
97
 
96
98
  <Grid container gap={ 0.75 } alignItems="center">
97
99
  <Grid item xs={ 12 }>
98
- <FormLabel size="small">{ __( 'Value', 'elementor' ) }</FormLabel>
100
+ <FormLabel size="tiny">{ __( 'Value', 'elementor' ) }</FormLabel>
99
101
  </Grid>
100
102
  <Grid item xs={ 12 }>
101
103
  <UnstableColorField
@@ -113,13 +115,13 @@ export const ColorVariableCreation = ( { onGoBack, onClose }: Props ) => {
113
115
  />
114
116
  </Grid>
115
117
  </Grid>
116
- </Stack>
118
+ </PopoverContent>
117
119
 
118
- <CardActions>
120
+ <CardActions sx={ { pt: 0.5, pb: 1 } }>
119
121
  <Button size="small" variant="contained" disabled={ isFormInvalid() } onClick={ handleCreate }>
120
122
  { __( 'Create', 'elementor' ) }
121
123
  </Button>
122
124
  </CardActions>
123
- </>
125
+ </PopoverScrollableContent>
124
126
  );
125
127
  };
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { useRef, useState } from 'react';
3
- import { PopoverHeader } from '@elementor/editor-ui';
4
- import { ArrowLeftIcon, BrushIcon } from '@elementor/icons';
3
+ import { PopoverContent } from '@elementor/editor-controls';
4
+ import { PopoverHeader, PopoverScrollableContent } from '@elementor/editor-ui';
5
+ import { ArrowLeftIcon, BrushIcon, TrashIcon } from '@elementor/icons';
5
6
  import {
6
7
  Button,
7
8
  CardActions,
@@ -9,13 +10,13 @@ import {
9
10
  FormLabel,
10
11
  Grid,
11
12
  IconButton,
12
- Stack,
13
13
  TextField,
14
14
  UnstableColorField,
15
15
  } from '@elementor/ui';
16
16
  import { __ } from '@wordpress/i18n';
17
17
 
18
- import { updateVariable, useVariable } from '../hooks/use-prop-variables';
18
+ import { deleteVariable, updateVariable, useVariable } from '../hooks/use-prop-variables';
19
+ import { usePopoverContentRef } from './variable-selection-popover.context';
19
20
 
20
21
  const SIZE = 'tiny';
21
22
 
@@ -28,12 +29,12 @@ type Props = {
28
29
 
29
30
  export const ColorVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Props ) => {
30
31
  const variable = useVariable( editId );
31
-
32
32
  if ( ! variable ) {
33
33
  throw new Error( `Global color variable not found` );
34
34
  }
35
35
 
36
- const anchorRef = useRef< HTMLDivElement >( null );
36
+ const defaultRef = useRef< HTMLDivElement >( null );
37
+ const anchorRef = usePopoverContentRef() ?? defaultRef;
37
38
 
38
39
  const [ color, setColor ] = useState( variable.value );
39
40
  const [ label, setLabel ] = useState( variable.label );
@@ -47,12 +48,26 @@ export const ColorVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Prop
47
48
  } );
48
49
  };
49
50
 
51
+ const handleDelete = () => {
52
+ deleteVariable( editId ).then( () => {
53
+ onSubmit?.();
54
+ } );
55
+ };
56
+
50
57
  const noValueChanged = () => color === variable.value && label === variable.label;
51
58
  const hasEmptyValue = () => '' === color.trim() || '' === label.trim();
52
59
  const isSaveDisabled = () => noValueChanged() || hasEmptyValue();
53
60
 
61
+ const actions = [];
62
+
63
+ actions.push(
64
+ <IconButton key="delete" size={ SIZE } aria-label={ __( 'Delete', 'elementor' ) } onClick={ handleDelete }>
65
+ <TrashIcon fontSize={ SIZE } />
66
+ </IconButton>
67
+ );
68
+
54
69
  return (
55
- <>
70
+ <PopoverScrollableContent height="auto">
56
71
  <PopoverHeader
57
72
  title={ __( 'Edit variable', 'elementor' ) }
58
73
  onClose={ onClose }
@@ -66,14 +81,15 @@ export const ColorVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Prop
66
81
  <BrushIcon fontSize={ SIZE } />
67
82
  </>
68
83
  }
84
+ actions={ actions }
69
85
  />
70
86
 
71
87
  <Divider />
72
88
 
73
- <Stack p={ 1.5 } gap={ 1.5 }>
89
+ <PopoverContent p={ 2 }>
74
90
  <Grid container gap={ 0.75 } alignItems="center">
75
91
  <Grid item xs={ 12 }>
76
- <FormLabel size="small">{ __( 'Name', 'elementor' ) }</FormLabel>
92
+ <FormLabel size="tiny">{ __( 'Name', 'elementor' ) }</FormLabel>
77
93
  </Grid>
78
94
  <Grid item xs={ 12 }>
79
95
  <TextField
@@ -87,7 +103,7 @@ export const ColorVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Prop
87
103
 
88
104
  <Grid container gap={ 0.75 } alignItems="center">
89
105
  <Grid item xs={ 12 }>
90
- <FormLabel size="small">{ __( 'Value', 'elementor' ) }</FormLabel>
106
+ <FormLabel size="tiny">{ __( 'Value', 'elementor' ) }</FormLabel>
91
107
  </Grid>
92
108
  <Grid item xs={ 12 }>
93
109
  <UnstableColorField
@@ -105,13 +121,13 @@ export const ColorVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Prop
105
121
  />
106
122
  </Grid>
107
123
  </Grid>
108
- </Stack>
124
+ </PopoverContent>
109
125
 
110
- <CardActions>
126
+ <CardActions sx={ { pt: 0.5, pb: 1 } }>
111
127
  <Button size="small" variant="contained" disabled={ isSaveDisabled() } onClick={ handleUpdate }>
112
128
  { __( 'Save', 'elementor' ) }
113
129
  </Button>
114
130
  </CardActions>
115
- </>
131
+ </PopoverScrollableContent>
116
132
  );
117
133
  };
@@ -1,8 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { useState } from 'react';
3
3
  import { useBoundProp } from '@elementor/editor-controls';
4
+ import { PopoverScrollableContent } from '@elementor/editor-editing-panel';
4
5
  import { PopoverHeader, PopoverMenuList, PopoverSearch, type VirtualizedItem } from '@elementor/editor-ui';
5
- import { ColorFilterIcon, PlusIcon, SettingsIcon } from '@elementor/icons';
6
+ import { BrushIcon, ColorFilterIcon, PlusIcon, SettingsIcon } from '@elementor/icons';
6
7
  import { Divider, IconButton } from '@elementor/ui';
7
8
  import { __ } from '@wordpress/i18n';
8
9
 
@@ -93,25 +94,37 @@ export const ColorVariablesSelection = ( { closePopover, onAdd, onEdit, onSettin
93
94
 
94
95
  <Divider />
95
96
 
96
- { hasVariables && hasSearchResults && (
97
- <PopoverMenuList< 'item', string >
98
- items={ items }
99
- onSelect={ handleSetColorVariable }
100
- onClose={ () => {} }
101
- selectedValue={ variable }
102
- data-testid="color-variables-list"
103
- menuListTemplate={ VariablesStyledMenuList }
104
- menuItemContentTemplate={ ( item: VirtualizedItem< 'item', string > ) => (
105
- <MenuItemContent item={ item } />
106
- ) }
107
- />
108
- ) }
109
-
110
- { ! hasSearchResults && hasVariables && (
111
- <NoSearchResults searchValue={ searchValue } onClear={ handleClearSearch } />
112
- ) }
113
-
114
- { ! hasVariables && <NoVariables icon={ <ColorFilterIcon fontSize="large" /> } onAdd={ onAdd } /> }
97
+ <PopoverScrollableContent>
98
+ { hasVariables && hasSearchResults && (
99
+ <PopoverMenuList
100
+ items={ items }
101
+ onSelect={ handleSetColorVariable }
102
+ onClose={ () => {} }
103
+ selectedValue={ variable }
104
+ data-testid="color-variables-list"
105
+ menuListTemplate={ VariablesStyledMenuList }
106
+ menuItemContentTemplate={ ( item: VirtualizedItem< 'item', string > ) => (
107
+ <MenuItemContent item={ item } />
108
+ ) }
109
+ />
110
+ ) }
111
+
112
+ { ! hasSearchResults && hasVariables && (
113
+ <NoSearchResults
114
+ searchValue={ searchValue }
115
+ onClear={ handleClearSearch }
116
+ icon={ <BrushIcon fontSize="large" /> }
117
+ />
118
+ ) }
119
+
120
+ { ! hasVariables && (
121
+ <NoVariables
122
+ title={ __( 'Create your first color variable', 'elementor' ) }
123
+ icon={ <BrushIcon fontSize="large" /> }
124
+ onAdd={ onAdd }
125
+ />
126
+ ) }
127
+ </PopoverScrollableContent>
115
128
  </>
116
129
  );
117
130
  };
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useRef, useState } from 'react';
3
- import { FontFamilySelector, useBoundProp } from '@elementor/editor-controls';
4
- import { useFontFamilies } from '@elementor/editor-editing-panel';
3
+ import { FontFamilySelector, PopoverContent, useBoundProp } from '@elementor/editor-controls';
4
+ import { PopoverScrollableContent, useFontFamilies, useSectionWidth } from '@elementor/editor-editing-panel';
5
5
  import { PopoverHeader } from '@elementor/editor-ui';
6
6
  import { ArrowLeftIcon, ChevronDownIcon, TextIcon } from '@elementor/icons';
7
7
  import {
@@ -14,7 +14,6 @@ import {
14
14
  Grid,
15
15
  IconButton,
16
16
  Popover,
17
- Stack,
18
17
  TextField,
19
18
  UnstableTag,
20
19
  usePopupState,
@@ -66,8 +65,10 @@ export const FontVariableCreation = ( { onClose, onGoBack }: Props ) => {
66
65
  return ! fontFamily?.trim() || ! label?.trim();
67
66
  };
68
67
 
68
+ const sectionWidth = useSectionWidth();
69
+
69
70
  return (
70
- <>
71
+ <PopoverScrollableContent height="auto">
71
72
  <PopoverHeader
72
73
  icon={
73
74
  <>
@@ -85,10 +86,10 @@ export const FontVariableCreation = ( { onClose, onGoBack }: Props ) => {
85
86
 
86
87
  <Divider />
87
88
 
88
- <Stack p={ 1.5 } gap={ 1.5 }>
89
+ <PopoverContent p={ 2 }>
89
90
  <Grid container gap={ 0.75 } alignItems="center">
90
91
  <Grid item xs={ 12 }>
91
- <FormLabel size="small">{ __( 'Name', 'elementor' ) }</FormLabel>
92
+ <FormLabel size="tiny">{ __( 'Name', 'elementor' ) }</FormLabel>
92
93
  </Grid>
93
94
  <Grid item xs={ 12 }>
94
95
  <TextField
@@ -102,7 +103,7 @@ export const FontVariableCreation = ( { onClose, onGoBack }: Props ) => {
102
103
 
103
104
  <Grid container gap={ 0.75 } alignItems="center">
104
105
  <Grid item xs={ 12 }>
105
- <FormLabel size="small">{ __( 'Value', 'elementor' ) }</FormLabel>
106
+ <FormLabel size="tiny">{ __( 'Value', 'elementor' ) }</FormLabel>
106
107
  </Grid>
107
108
  <Grid item xs={ 12 }>
108
109
  <>
@@ -126,18 +127,19 @@ export const FontVariableCreation = ( { onClose, onGoBack }: Props ) => {
126
127
  fontFamily={ fontFamily }
127
128
  onFontFamilyChange={ setFontFamily }
128
129
  onClose={ fontPopoverState.close }
130
+ sectionWidth={ sectionWidth }
129
131
  />
130
132
  </Popover>
131
133
  </>
132
134
  </Grid>
133
135
  </Grid>
134
- </Stack>
136
+ </PopoverContent>
135
137
 
136
- <CardActions>
138
+ <CardActions sx={ { pt: 0.5, pb: 1 } }>
137
139
  <Button size="small" variant="contained" disabled={ isFormInvalid() } onClick={ handleCreate }>
138
140
  { __( 'Create', 'elementor' ) }
139
141
  </Button>
140
142
  </CardActions>
141
- </>
143
+ </PopoverScrollableContent>
142
144
  );
143
145
  };
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { useId, useRef, useState } from 'react';
3
- import { FontFamilySelector } from '@elementor/editor-controls';
4
- import { useFontFamilies } from '@elementor/editor-editing-panel';
5
- import { PopoverHeader } from '@elementor/editor-ui';
6
- import { ArrowLeftIcon, ChevronDownIcon, TextIcon } from '@elementor/icons';
3
+ import { FontFamilySelector, PopoverContent } from '@elementor/editor-controls';
4
+ import { useFontFamilies, useSectionWidth } from '@elementor/editor-editing-panel';
5
+ import { PopoverHeader, PopoverScrollableContent } from '@elementor/editor-ui';
6
+ import { ArrowLeftIcon, ChevronDownIcon, TextIcon, TrashIcon } from '@elementor/icons';
7
7
  import {
8
8
  bindPopover,
9
9
  bindTrigger,
@@ -14,14 +14,13 @@ import {
14
14
  Grid,
15
15
  IconButton,
16
16
  Popover,
17
- Stack,
18
17
  TextField,
19
18
  UnstableTag,
20
19
  usePopupState,
21
20
  } from '@elementor/ui';
22
21
  import { __ } from '@wordpress/i18n';
23
22
 
24
- import { updateVariable, useVariable } from '../hooks/use-prop-variables';
23
+ import { deleteVariable, updateVariable, useVariable } from '../hooks/use-prop-variables';
25
24
 
26
25
  const SIZE = 'tiny';
27
26
 
@@ -59,12 +58,28 @@ export const FontVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Props
59
58
  } );
60
59
  };
61
60
 
61
+ const handleDelete = () => {
62
+ deleteVariable( editId ).then( () => {
63
+ onSubmit?.();
64
+ } );
65
+ };
66
+
62
67
  const noValueChanged = () => fontFamily === variable.value && label === variable.label;
63
68
  const hasEmptyValue = () => '' === fontFamily.trim() || '' === label.trim();
64
69
  const isSaveDisabled = () => noValueChanged() || hasEmptyValue();
65
70
 
71
+ const sectionWidth = useSectionWidth();
72
+
73
+ const actions = [];
74
+
75
+ actions.push(
76
+ <IconButton key="delete" size={ SIZE } aria-label={ __( 'Delete', 'elementor' ) } onClick={ handleDelete }>
77
+ <TrashIcon fontSize={ SIZE } />
78
+ </IconButton>
79
+ );
80
+
66
81
  return (
67
- <>
82
+ <PopoverScrollableContent height="auto">
68
83
  <PopoverHeader
69
84
  icon={
70
85
  <>
@@ -78,14 +93,15 @@ export const FontVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Props
78
93
  }
79
94
  title={ __( 'Edit variable', 'elementor' ) }
80
95
  onClose={ onClose }
96
+ actions={ actions }
81
97
  />
82
98
 
83
99
  <Divider />
84
100
 
85
- <Stack p={ 1.5 } gap={ 1.5 }>
101
+ <PopoverContent p={ 2 }>
86
102
  <Grid container gap={ 0.75 } alignItems="center">
87
103
  <Grid item xs={ 12 }>
88
- <FormLabel htmlFor={ variableNameId } size="small">
104
+ <FormLabel htmlFor={ variableNameId } size="tiny">
89
105
  { __( 'Name', 'elementor' ) }
90
106
  </FormLabel>
91
107
  </Grid>
@@ -102,7 +118,7 @@ export const FontVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Props
102
118
 
103
119
  <Grid container gap={ 0.75 } alignItems="center">
104
120
  <Grid item xs={ 12 }>
105
- <FormLabel htmlFor={ variableValueId } size="small">
121
+ <FormLabel htmlFor={ variableValueId } size="tiny">
106
122
  { __( 'Value', 'elementor' ) }
107
123
  </FormLabel>
108
124
  </Grid>
@@ -129,18 +145,19 @@ export const FontVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Props
129
145
  fontFamily={ fontFamily }
130
146
  onFontFamilyChange={ setFontFamily }
131
147
  onClose={ fontPopoverState.close }
148
+ sectionWidth={ sectionWidth }
132
149
  />
133
150
  </Popover>
134
151
  </>
135
152
  </Grid>
136
153
  </Grid>
137
- </Stack>
154
+ </PopoverContent>
138
155
 
139
- <CardActions>
156
+ <CardActions sx={ { pt: 0.5, pb: 1 } }>
140
157
  <Button size="small" variant="contained" disabled={ isSaveDisabled() } onClick={ handleUpdate }>
141
158
  { __( 'Save', 'elementor' ) }
142
159
  </Button>
143
160
  </CardActions>
144
- </>
161
+ </PopoverScrollableContent>
145
162
  );
146
163
  };
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useState } from 'react';
3
3
  import { useBoundProp } from '@elementor/editor-controls';
4
+ import { PopoverScrollableContent } from '@elementor/editor-editing-panel';
4
5
  import { PopoverHeader, PopoverMenuList, PopoverSearch, type VirtualizedItem } from '@elementor/editor-ui';
5
6
  import { ColorFilterIcon, PlusIcon, SettingsIcon, TextIcon } from '@elementor/icons';
6
7
  import { Divider, IconButton } from '@elementor/ui';
@@ -60,7 +61,7 @@ export const FontVariablesSelection = ( { closePopover, onAdd, onEdit, onSetting
60
61
  type: 'item' as const,
61
62
  value: key,
62
63
  label,
63
- icon: <TextIcon />,
64
+ icon: <TextIcon fontSize={ SIZE } />,
64
65
  secondaryText: value,
65
66
  onEdit: () => onEdit?.( key ),
66
67
  } ) );
@@ -92,25 +93,37 @@ export const FontVariablesSelection = ( { closePopover, onAdd, onEdit, onSetting
92
93
 
93
94
  <Divider />
94
95
 
95
- { hasVariables && hasSearchResults && (
96
- <PopoverMenuList
97
- items={ items }
98
- onSelect={ handleSetVariable }
99
- onClose={ () => {} }
100
- selectedValue={ variable }
101
- data-testid="font-variables-list"
102
- menuListTemplate={ VariablesStyledMenuList }
103
- menuItemContentTemplate={ ( item: VirtualizedItem< 'item', string > ) => (
104
- <MenuItemContent item={ item } />
105
- ) }
106
- />
107
- ) }
108
-
109
- { ! hasSearchResults && hasVariables && (
110
- <NoSearchResults searchValue={ searchValue } onClear={ handleClearSearch } />
111
- ) }
112
-
113
- { ! hasVariables && <NoVariables icon={ <TextIcon fontSize="large" /> } onAdd={ onAdd } /> }
96
+ <PopoverScrollableContent>
97
+ { hasVariables && hasSearchResults && (
98
+ <PopoverMenuList
99
+ items={ items }
100
+ onSelect={ handleSetVariable }
101
+ onClose={ () => {} }
102
+ selectedValue={ variable }
103
+ data-testid="font-variables-list"
104
+ menuListTemplate={ VariablesStyledMenuList }
105
+ menuItemContentTemplate={ ( item: VirtualizedItem< 'item', string > ) => (
106
+ <MenuItemContent item={ item } />
107
+ ) }
108
+ />
109
+ ) }
110
+
111
+ { ! hasSearchResults && hasVariables && (
112
+ <NoSearchResults
113
+ searchValue={ searchValue }
114
+ onClear={ handleClearSearch }
115
+ icon={ <TextIcon fontSize="large" /> }
116
+ />
117
+ ) }
118
+
119
+ { ! hasVariables && (
120
+ <NoVariables
121
+ title={ __( 'Create your first font variable', 'elementor' ) }
122
+ icon={ <TextIcon fontSize="large" /> }
123
+ onAdd={ onAdd }
124
+ />
125
+ ) }
126
+ </PopoverScrollableContent>
114
127
  </>
115
128
  );
116
129
  };
@@ -2,4 +2,5 @@ import { styled, UnstableColorIndicator } from '@elementor/ui';
2
2
 
3
3
  export const ColorIndicator = styled( UnstableColorIndicator )( ( { theme } ) => ( {
4
4
  borderRadius: `${ theme.shape.borderRadius / 2 }px`,
5
+ marginRight: theme.spacing( 0.25 ),
5
6
  } ) );
@@ -1,39 +1,48 @@
1
1
  import * as React from 'react';
2
- import type { VirtualizedItem } from '@elementor/editor-ui';
2
+ import { EllipsisWithTooltip, type VirtualizedItem } from '@elementor/editor-ui';
3
+ import { isExperimentActive } from '@elementor/editor-v1-adapters';
3
4
  import { EditIcon } from '@elementor/icons';
4
- import { IconButton, ListItemIcon, ListItemText } from '@elementor/ui';
5
+ import { Box, IconButton, ListItemIcon, Typography } from '@elementor/ui';
5
6
  import { __ } from '@wordpress/i18n';
6
7
 
7
8
  const SIZE = 'tiny';
8
9
 
10
+ const isVersion330Active = isExperimentActive( 'e_v_3_30' );
11
+
9
12
  export const MenuItemContent = < T, V extends string >( { item }: { item: VirtualizedItem< T, V > } ) => {
10
13
  const onEdit = item.onEdit as ( ( value: V ) => void ) | undefined;
11
14
 
12
15
  return (
13
16
  <>
14
17
  <ListItemIcon>{ item.icon }</ListItemIcon>
15
- <ListItemText
16
- primary={ item.label || item.value }
17
- secondary={ item.secondaryText }
18
- primaryTypographyProps={ {
19
- variant: 'body2',
20
- color: 'text.secondary',
21
- style: {
22
- lineHeight: 2,
23
- display: 'inline-block',
24
- overflow: 'hidden',
25
- textOverflow: 'ellipsis',
26
- whiteSpace: 'nowrap',
27
- maxWidth: '81px',
28
- },
29
- } }
30
- secondaryTypographyProps={ {
31
- variant: 'caption',
32
- color: 'text.tertiary',
33
- style: { marginTop: '1px', lineHeight: '1' },
18
+ <Box
19
+ sx={ {
20
+ flex: 1,
21
+ minWidth: 0,
22
+ display: 'flex',
23
+ alignItems: 'center',
24
+ gap: 1,
34
25
  } }
35
- sx={ { display: 'flex', alignItems: 'center', gap: 1 } }
36
- />
26
+ >
27
+ <EllipsisWithTooltip
28
+ title={ item.label || item.value }
29
+ as={ Typography }
30
+ variant={ isVersion330Active ? 'caption' : 'body2' }
31
+ color={ isVersion330Active ? 'text.primary' : 'text.secondary' }
32
+ sx={ { marginTop: '1px', lineHeight: '2' } }
33
+ maxWidth="50%"
34
+ />
35
+ { item.secondaryText && (
36
+ <EllipsisWithTooltip
37
+ title={ item.secondaryText }
38
+ as={ Typography }
39
+ variant="caption"
40
+ color="text.tertiary"
41
+ sx={ { marginTop: '1px', lineHeight: '1' } }
42
+ maxWidth="50%"
43
+ />
44
+ ) }
45
+ </Box>
37
46
  { !! onEdit && (
38
47
  <IconButton
39
48
  sx={ { mx: 1, opacity: '0' } }
@@ -1,34 +1,32 @@
1
1
  import * as React from 'react';
2
- import { ColorFilterIcon } from '@elementor/icons';
3
2
  import { Link, Stack, Typography } from '@elementor/ui';
4
3
  import { __ } from '@wordpress/i18n';
5
4
 
6
5
  type Props = {
7
6
  searchValue: string;
8
7
  onClear?: () => void;
8
+ icon?: React.ReactNode;
9
9
  };
10
10
 
11
- export const NoSearchResults = ( { searchValue, onClear }: Props ) => {
11
+ export const NoSearchResults = ( { searchValue, onClear, icon }: Props ) => {
12
12
  return (
13
13
  <Stack
14
14
  gap={ 1 }
15
15
  alignItems="center"
16
16
  justifyContent="center"
17
17
  height="100%"
18
+ p={ 2.5 }
18
19
  color="text.secondary"
19
- sx={ { p: 2.5, pb: 5.5 } }
20
+ sx={ { pb: 3.5 } }
20
21
  >
21
- <ColorFilterIcon fontSize="large" />
22
-
22
+ { icon }
23
23
  <Typography align="center" variant="subtitle2">
24
24
  { __( 'Sorry, nothing matched', 'elementor' ) }
25
25
  <br />
26
26
  &ldquo;{ searchValue }&rdquo;.
27
27
  </Typography>
28
-
29
- <Typography align="center" variant="caption">
28
+ <Typography align="center" variant="caption" sx={ { display: 'flex', flexDirection: 'column' } }>
30
29
  { __( 'Try something else.', 'elementor' ) }
31
- <br />
32
30
  <Link color="text.secondary" variant="caption" component="button" onClick={ onClear }>
33
31
  { __( 'Clear & try again', 'elementor' ) }
34
32
  </Link>
@@ -4,10 +4,11 @@ import { __ } from '@wordpress/i18n';
4
4
 
5
5
  type Props = {
6
6
  icon?: React.ReactNode;
7
+ title?: string;
7
8
  onAdd?: () => void;
8
9
  };
9
10
 
10
- export const NoVariables = ( { icon, onAdd }: Props ) => (
11
+ export const NoVariables = ( { icon, title, onAdd }: Props ) => (
11
12
  <Stack
12
13
  gap={ 1 }
13
14
  alignItems="center"
@@ -19,7 +20,7 @@ export const NoVariables = ( { icon, onAdd }: Props ) => (
19
20
  { icon }
20
21
 
21
22
  <Typography align="center" variant="subtitle2">
22
- { __( 'Create your first variable', 'elementor' ) }
23
+ { title }
23
24
  </Typography>
24
25
 
25
26
  <Typography align="center" variant="caption" maxWidth="180px">