@elementor/editor-variables 4.0.0-538 → 4.0.0-540
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.js +41 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/ui/menu-item-content.tsx +12 -6
- package/src/components/ui/styled-menu-list.tsx +7 -5
- package/src/components/variables-selection.tsx +35 -14
- package/src/hooks/use-quota-permissions.ts +10 -11
- package/src/sync/license-info.ts +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-variables",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-540",
|
|
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.0.0-
|
|
43
|
-
"@elementor/editor-canvas": "4.0.0-
|
|
44
|
-
"@elementor/editor-controls": "4.0.0-
|
|
45
|
-
"@elementor/editor-current-user": "4.0.0-
|
|
46
|
-
"@elementor/editor-mcp": "4.0.0-
|
|
47
|
-
"@elementor/editor-panels": "4.0.0-
|
|
48
|
-
"@elementor/editor-props": "4.0.0-
|
|
49
|
-
"@elementor/editor-ui": "4.0.0-
|
|
50
|
-
"@elementor/editor-v1-adapters": "4.0.0-
|
|
51
|
-
"@elementor/menus": "4.0.0-
|
|
52
|
-
"@elementor/http-client": "4.0.0-
|
|
42
|
+
"@elementor/editor": "4.0.0-540",
|
|
43
|
+
"@elementor/editor-canvas": "4.0.0-540",
|
|
44
|
+
"@elementor/editor-controls": "4.0.0-540",
|
|
45
|
+
"@elementor/editor-current-user": "4.0.0-540",
|
|
46
|
+
"@elementor/editor-mcp": "4.0.0-540",
|
|
47
|
+
"@elementor/editor-panels": "4.0.0-540",
|
|
48
|
+
"@elementor/editor-props": "4.0.0-540",
|
|
49
|
+
"@elementor/editor-ui": "4.0.0-540",
|
|
50
|
+
"@elementor/editor-v1-adapters": "4.0.0-540",
|
|
51
|
+
"@elementor/menus": "4.0.0-540",
|
|
52
|
+
"@elementor/http-client": "4.0.0-540",
|
|
53
53
|
"@elementor/icons": "^1.63.0",
|
|
54
|
-
"@elementor/mixpanel": "4.0.0-
|
|
55
|
-
"@elementor/schema": "4.0.0-
|
|
54
|
+
"@elementor/mixpanel": "4.0.0-540",
|
|
55
|
+
"@elementor/schema": "4.0.0-540",
|
|
56
56
|
"@elementor/ui": "1.37.2",
|
|
57
|
-
"@elementor/utils": "4.0.0-
|
|
57
|
+
"@elementor/utils": "4.0.0-540",
|
|
58
58
|
"@wordpress/i18n": "^5.13.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type MouseEvent } from 'react';
|
|
2
3
|
import { EllipsisWithTooltip, type VirtualizedItem } from '@elementor/editor-ui';
|
|
3
4
|
import { EditIcon } from '@elementor/icons';
|
|
4
5
|
import { Box, IconButton, ListItemIcon, Tooltip, Typography } from '@elementor/ui';
|
|
@@ -7,12 +8,17 @@ import { __ } from '@wordpress/i18n';
|
|
|
7
8
|
const SIZE = 'tiny';
|
|
8
9
|
const EDIT_LABEL = __( 'Edit variable', 'elementor' );
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
type MenuItemContentProps< T, V extends string > = {
|
|
12
|
+
item: VirtualizedItem< T, V >;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const MenuItemContent = < T, V extends string >( { item, disabled = false }: MenuItemContentProps< T, V > ) => {
|
|
11
17
|
const onEdit = item.onEdit as ( ( value: V ) => void ) | undefined;
|
|
12
18
|
|
|
13
19
|
return (
|
|
14
20
|
<>
|
|
15
|
-
<ListItemIcon>{ item.icon }</ListItemIcon>
|
|
21
|
+
<ListItemIcon sx={ { color: disabled ? 'text.disabled' : 'inherit' } }>{ item.icon }</ListItemIcon>
|
|
16
22
|
<Box
|
|
17
23
|
sx={ {
|
|
18
24
|
flex: 1,
|
|
@@ -26,7 +32,7 @@ export const MenuItemContent = < T, V extends string >( { item }: { item: Virtua
|
|
|
26
32
|
title={ item.label || item.value }
|
|
27
33
|
as={ Typography }
|
|
28
34
|
variant="caption"
|
|
29
|
-
color=
|
|
35
|
+
color={ disabled ? 'text.disabled' : 'text.primary' }
|
|
30
36
|
sx={ { marginTop: '1px', lineHeight: '2' } }
|
|
31
37
|
maxWidth="50%"
|
|
32
38
|
/>
|
|
@@ -35,17 +41,17 @@ export const MenuItemContent = < T, V extends string >( { item }: { item: Virtua
|
|
|
35
41
|
title={ item.secondaryText }
|
|
36
42
|
as={ Typography }
|
|
37
43
|
variant="caption"
|
|
38
|
-
color=
|
|
44
|
+
color={ disabled ? 'text.disabled' : 'text.tertiary' }
|
|
39
45
|
sx={ { marginTop: '1px', lineHeight: '1' } }
|
|
40
46
|
maxWidth="50%"
|
|
41
47
|
/>
|
|
42
48
|
) }
|
|
43
49
|
</Box>
|
|
44
|
-
{ !! onEdit && (
|
|
50
|
+
{ !! onEdit && ! disabled && (
|
|
45
51
|
<Tooltip placement="top" title={ EDIT_LABEL }>
|
|
46
52
|
<IconButton
|
|
47
53
|
sx={ { mx: 1, opacity: '0' } }
|
|
48
|
-
onClick={ ( e:
|
|
54
|
+
onClick={ ( e: MouseEvent< HTMLButtonElement > ) => {
|
|
49
55
|
e.stopPropagation();
|
|
50
56
|
onEdit( item.value );
|
|
51
57
|
} }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MenuList, styled } from '@elementor/ui';
|
|
2
2
|
|
|
3
|
-
export const VariablesStyledMenuList = styled( MenuList )( ( { theme } ) => ( {
|
|
3
|
+
export const VariablesStyledMenuList = styled( MenuList )< { disabled?: boolean } >( ( { theme, disabled } ) => ( {
|
|
4
4
|
'& > li': {
|
|
5
5
|
height: 32,
|
|
6
6
|
width: '100%',
|
|
@@ -11,13 +11,15 @@ export const VariablesStyledMenuList = styled( MenuList )( ( { theme } ) => ( {
|
|
|
11
11
|
...theme.typography.caption,
|
|
12
12
|
lineHeight: 'inherit',
|
|
13
13
|
padding: theme.spacing( 0.5, 1, 0.5, 2 ),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
...( ! disabled && {
|
|
15
|
+
'&:hover, &:focus': {
|
|
16
|
+
backgroundColor: theme.palette.action.hover,
|
|
17
|
+
},
|
|
18
|
+
cursor: 'pointer',
|
|
19
|
+
} ),
|
|
17
20
|
'&[aria-selected="true"]': {
|
|
18
21
|
backgroundColor: theme.palette.action.selected,
|
|
19
22
|
},
|
|
20
|
-
cursor: 'pointer',
|
|
21
23
|
textOverflow: 'ellipsis',
|
|
22
24
|
position: 'absolute',
|
|
23
25
|
top: 0,
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { useState } from 'react';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import {
|
|
4
|
+
PopoverHeader,
|
|
5
|
+
PopoverMenuList,
|
|
6
|
+
SearchField,
|
|
7
|
+
SectionPopoverBody,
|
|
8
|
+
type VirtualizedItem,
|
|
9
|
+
} from '@elementor/editor-ui';
|
|
10
|
+
import { PromotionAlert } from '@elementor/editor-ui';
|
|
5
11
|
import { ColorFilterIcon, PlusIcon, SettingsIcon } from '@elementor/icons';
|
|
6
12
|
import { Divider, IconButton, Tooltip } from '@elementor/ui';
|
|
7
13
|
import { __, sprintf } from '@wordpress/i18n';
|
|
@@ -20,6 +26,9 @@ const SIZE = 'tiny';
|
|
|
20
26
|
const CREATE_LABEL = __( 'Create variable', 'elementor' );
|
|
21
27
|
const MANAGER_LABEL = __( 'Variables Manager', 'elementor' );
|
|
22
28
|
|
|
29
|
+
const getProUpgradeUrl = ( variableType: string ) =>
|
|
30
|
+
`https://go.elementor.com/go-pro-panel-${ variableType }-variable/`;
|
|
31
|
+
|
|
23
32
|
type Props = {
|
|
24
33
|
closePopover: () => void;
|
|
25
34
|
onAdd?: () => void;
|
|
@@ -143,17 +152,29 @@ export const VariablesSelection = ( { closePopover, onAdd, onEdit, onSettings, d
|
|
|
143
152
|
<Divider />
|
|
144
153
|
|
|
145
154
|
{ hasVariables && hasSearchResults && (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
<>
|
|
156
|
+
<PopoverMenuList
|
|
157
|
+
items={ items }
|
|
158
|
+
onSelect={ disabled ? () => {} : handleSetVariable }
|
|
159
|
+
onClose={ () => {} }
|
|
160
|
+
selectedValue={ variable }
|
|
161
|
+
data-testid={ `${ variableType }-variables-list` }
|
|
162
|
+
menuListTemplate={ ( props ) => <VariablesStyledMenuList { ...props } disabled={ disabled } /> }
|
|
163
|
+
menuItemContentTemplate={ ( item: VirtualizedItem< 'item', string > ) => (
|
|
164
|
+
<MenuItemContent item={ item } disabled={ disabled } />
|
|
165
|
+
) }
|
|
166
|
+
/>
|
|
167
|
+
{ disabled && (
|
|
168
|
+
<PromotionAlert
|
|
169
|
+
message={ sprintf(
|
|
170
|
+
/* translators: %s: Variable Type. */
|
|
171
|
+
__( 'Upgrade to continue creating and editing %s variables.', 'elementor' ),
|
|
172
|
+
variableType
|
|
173
|
+
) }
|
|
174
|
+
upgradeUrl={ getProUpgradeUrl( variableType ) }
|
|
175
|
+
/>
|
|
155
176
|
) }
|
|
156
|
-
|
|
177
|
+
</>
|
|
157
178
|
) }
|
|
158
179
|
|
|
159
180
|
{ ! hasSearchResults && hasVariables && (
|
|
@@ -164,7 +185,7 @@ export const VariablesSelection = ( { closePopover, onAdd, onEdit, onSettings, d
|
|
|
164
185
|
/>
|
|
165
186
|
) }
|
|
166
187
|
|
|
167
|
-
{ disabled && (
|
|
188
|
+
{ disabled && ! hasVariables && (
|
|
168
189
|
<EmptyState
|
|
169
190
|
title={ sprintf(
|
|
170
191
|
/* translators: %s: Variable Type. */
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
export const useQuotaPermissions = ( variableType: string ) => {
|
|
2
|
+
const quotaConfig = {
|
|
3
|
+
...( window.ElementorVariablesQuotaConfig || {} ),
|
|
4
|
+
...( window.ElementorVariablesQuotaConfigExtended || {} ),
|
|
5
|
+
};
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
ElementorVariablesQuotaConfig: Record< string, number >;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
7
|
+
// BC: Remove when 4.01 is released
|
|
8
|
+
const hasLegacySupport = quotaConfig[ variableType ] === undefined && window.elementorPro;
|
|
8
9
|
|
|
9
|
-
export const useQuotaPermissions = ( variableType: string ) => {
|
|
10
|
-
const quotaConfig = window.ElementorVariablesQuotaConfig || {};
|
|
11
10
|
const limit = quotaConfig[ variableType ] || 0;
|
|
12
|
-
const
|
|
11
|
+
const hasPermission = hasLegacySupport || limit > 0;
|
|
13
12
|
|
|
14
13
|
return {
|
|
15
|
-
canAdd: () =>
|
|
16
|
-
canEdit: () =>
|
|
14
|
+
canAdd: () => hasPermission,
|
|
15
|
+
canEdit: () => hasPermission,
|
|
17
16
|
};
|
|
18
17
|
};
|