@elementor/editor-variables 0.16.0 → 0.18.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.
- package/CHANGELOG.md +50 -0
- package/dist/index.js +392 -136
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +400 -144
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/components/color-variable-creation.tsx +30 -10
- package/src/components/color-variable-edit.tsx +29 -10
- package/src/components/color-variables-selection.tsx +32 -34
- package/src/components/font-variable-creation.tsx +30 -10
- package/src/components/font-variable-edit.tsx +29 -10
- package/src/components/font-variables-selection.tsx +32 -34
- package/src/components/ui/delete-confirmation-dialog.tsx +4 -7
- package/src/components/ui/deleted-variable-alert.tsx +47 -0
- package/src/components/ui/tags/assigned-tag.tsx +21 -19
- package/src/components/ui/tags/deleted-tag.tsx +29 -18
- package/src/components/ui/variable/deleted-variable.tsx +63 -7
- package/src/controls/color-variable-control.tsx +7 -1
- package/src/controls/font-variable-control.tsx +7 -1
- package/src/create-style-variables-repository.ts +44 -5
- package/src/hooks/use-prop-variables.ts +6 -0
- package/src/renderers/style-variables-renderer.tsx +10 -4
- package/src/service.ts +23 -2
- package/src/sync/enqueue-font.ts +7 -0
- package/src/sync/types.ts +5 -0
- package/src/transformers/variable-transformer.ts +21 -3
- package/src/types.ts +1 -1
- package/src/utils/validations.ts +5 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-variables",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
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": "0.21.
|
|
43
|
-
"@elementor/editor-editing-panel": "1.
|
|
44
|
-
"@elementor/editor-canvas": "0.
|
|
45
|
-
"@elementor/editor-props": "0.
|
|
42
|
+
"@elementor/editor": "0.21.1",
|
|
43
|
+
"@elementor/editor-editing-panel": "1.50.0",
|
|
44
|
+
"@elementor/editor-canvas": "0.28.0",
|
|
45
|
+
"@elementor/editor-props": "0.18.0",
|
|
46
46
|
"@elementor/schema": "0.1.2",
|
|
47
|
-
"@elementor/editor-controls": "1.
|
|
47
|
+
"@elementor/editor-controls": "1.5.0",
|
|
48
48
|
"@elementor/icons": "1.46.0",
|
|
49
49
|
"@wordpress/i18n": "^5.13.0",
|
|
50
50
|
"@elementor/ui": "1.36.0",
|
|
51
51
|
"@elementor/editor-v1-adapters": "0.12.1",
|
|
52
52
|
"@elementor/http-client": "0.3.0",
|
|
53
|
-
"@elementor/editor-ui": "0.14.
|
|
53
|
+
"@elementor/editor-ui": "0.14.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": "^18.3.1",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { PopoverContent, useBoundProp } from '@elementor/editor-controls';
|
|
4
|
-
import {
|
|
4
|
+
import { PopoverBody } from '@elementor/editor-editing-panel';
|
|
5
5
|
import { PopoverHeader } from '@elementor/editor-ui';
|
|
6
6
|
import { ArrowLeftIcon, BrushIcon } from '@elementor/icons';
|
|
7
|
-
import { Button, CardActions, Divider, IconButton } from '@elementor/ui';
|
|
7
|
+
import { Button, CardActions, Divider, FormHelperText, IconButton } from '@elementor/ui';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
|
|
10
10
|
import { createVariable } from '../hooks/use-prop-variables';
|
|
@@ -24,10 +24,12 @@ export const ColorVariableCreation = ( { onGoBack, onClose }: Props ) => {
|
|
|
24
24
|
|
|
25
25
|
const [ color, setColor ] = useState( '' );
|
|
26
26
|
const [ label, setLabel ] = useState( '' );
|
|
27
|
+
const [ errorMessage, setErrorMessage ] = useState( '' );
|
|
27
28
|
|
|
28
29
|
const resetFields = () => {
|
|
29
30
|
setColor( '' );
|
|
30
31
|
setLabel( '' );
|
|
32
|
+
setErrorMessage( '' );
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
const closePopover = () => {
|
|
@@ -40,10 +42,14 @@ export const ColorVariableCreation = ( { onGoBack, onClose }: Props ) => {
|
|
|
40
42
|
value: color,
|
|
41
43
|
label,
|
|
42
44
|
type: colorVariablePropTypeUtil.key,
|
|
43
|
-
} )
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
} )
|
|
46
|
+
.then( ( key ) => {
|
|
47
|
+
setVariable( key );
|
|
48
|
+
closePopover();
|
|
49
|
+
} )
|
|
50
|
+
.catch( ( error ) => {
|
|
51
|
+
setErrorMessage( error.message );
|
|
52
|
+
} );
|
|
47
53
|
};
|
|
48
54
|
|
|
49
55
|
const hasEmptyValue = () => {
|
|
@@ -53,7 +59,7 @@ export const ColorVariableCreation = ( { onGoBack, onClose }: Props ) => {
|
|
|
53
59
|
const isSubmitDisabled = hasEmptyValue();
|
|
54
60
|
|
|
55
61
|
return (
|
|
56
|
-
<
|
|
62
|
+
<PopoverBody height="auto">
|
|
57
63
|
<PopoverHeader
|
|
58
64
|
icon={
|
|
59
65
|
<>
|
|
@@ -72,8 +78,22 @@ export const ColorVariableCreation = ( { onGoBack, onClose }: Props ) => {
|
|
|
72
78
|
<Divider />
|
|
73
79
|
|
|
74
80
|
<PopoverContent p={ 2 }>
|
|
75
|
-
<LabelField
|
|
76
|
-
|
|
81
|
+
<LabelField
|
|
82
|
+
value={ label }
|
|
83
|
+
onChange={ ( value ) => {
|
|
84
|
+
setLabel( value );
|
|
85
|
+
setErrorMessage( '' );
|
|
86
|
+
} }
|
|
87
|
+
/>
|
|
88
|
+
<ColorField
|
|
89
|
+
value={ color }
|
|
90
|
+
onChange={ ( value ) => {
|
|
91
|
+
setColor( value );
|
|
92
|
+
setErrorMessage( '' );
|
|
93
|
+
} }
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
{ errorMessage && <FormHelperText error>{ errorMessage }</FormHelperText> }
|
|
77
97
|
</PopoverContent>
|
|
78
98
|
|
|
79
99
|
<CardActions sx={ { pt: 0.5, pb: 1 } }>
|
|
@@ -81,6 +101,6 @@ export const ColorVariableCreation = ( { onGoBack, onClose }: Props ) => {
|
|
|
81
101
|
{ __( 'Create', 'elementor' ) }
|
|
82
102
|
</Button>
|
|
83
103
|
</CardActions>
|
|
84
|
-
</
|
|
104
|
+
</PopoverBody>
|
|
85
105
|
);
|
|
86
106
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { PopoverContent, useBoundProp } from '@elementor/editor-controls';
|
|
4
|
-
import {
|
|
4
|
+
import { PopoverBody } from '@elementor/editor-editing-panel';
|
|
5
5
|
import { PopoverHeader } from '@elementor/editor-ui';
|
|
6
6
|
import { ArrowLeftIcon, BrushIcon, TrashIcon } from '@elementor/icons';
|
|
7
|
-
import { Button, CardActions, Divider, IconButton } from '@elementor/ui';
|
|
7
|
+
import { Button, CardActions, Divider, FormHelperText, IconButton } from '@elementor/ui';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
|
|
10
10
|
import { deleteVariable, updateVariable, useVariable } from '../hooks/use-prop-variables';
|
|
@@ -25,6 +25,7 @@ type Props = {
|
|
|
25
25
|
export const ColorVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Props ) => {
|
|
26
26
|
const { setValue: notifyBoundPropChange, value: assignedValue } = useBoundProp( colorVariablePropTypeUtil );
|
|
27
27
|
const [ deleteConfirmation, setDeleteConfirmation ] = useState( false );
|
|
28
|
+
const [ errorMessage, setErrorMessage ] = useState( '' );
|
|
28
29
|
|
|
29
30
|
const variable = useVariable( editId );
|
|
30
31
|
if ( ! variable ) {
|
|
@@ -38,10 +39,14 @@ export const ColorVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Prop
|
|
|
38
39
|
updateVariable( editId, {
|
|
39
40
|
value: color,
|
|
40
41
|
label,
|
|
41
|
-
} )
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
} )
|
|
43
|
+
.then( () => {
|
|
44
|
+
maybeTriggerBoundPropChange();
|
|
45
|
+
onSubmit?.();
|
|
46
|
+
} )
|
|
47
|
+
.catch( ( error ) => {
|
|
48
|
+
setErrorMessage( error.message );
|
|
49
|
+
} );
|
|
45
50
|
};
|
|
46
51
|
|
|
47
52
|
const handleDelete = () => {
|
|
@@ -90,7 +95,7 @@ export const ColorVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Prop
|
|
|
90
95
|
|
|
91
96
|
return (
|
|
92
97
|
<>
|
|
93
|
-
<
|
|
98
|
+
<PopoverBody height="auto">
|
|
94
99
|
<PopoverHeader
|
|
95
100
|
title={ __( 'Edit variable', 'elementor' ) }
|
|
96
101
|
onClose={ onClose }
|
|
@@ -114,8 +119,22 @@ export const ColorVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Prop
|
|
|
114
119
|
<Divider />
|
|
115
120
|
|
|
116
121
|
<PopoverContent p={ 2 }>
|
|
117
|
-
<LabelField
|
|
118
|
-
|
|
122
|
+
<LabelField
|
|
123
|
+
value={ label }
|
|
124
|
+
onChange={ ( value ) => {
|
|
125
|
+
setLabel( value );
|
|
126
|
+
setErrorMessage( '' );
|
|
127
|
+
} }
|
|
128
|
+
/>
|
|
129
|
+
<ColorField
|
|
130
|
+
value={ color }
|
|
131
|
+
onChange={ ( value ) => {
|
|
132
|
+
setColor( value );
|
|
133
|
+
setErrorMessage( '' );
|
|
134
|
+
} }
|
|
135
|
+
/>
|
|
136
|
+
|
|
137
|
+
{ errorMessage && <FormHelperText error>{ errorMessage }</FormHelperText> }
|
|
119
138
|
</PopoverContent>
|
|
120
139
|
|
|
121
140
|
<CardActions sx={ { pt: 0.5, pb: 1 } }>
|
|
@@ -123,7 +142,7 @@ export const ColorVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Prop
|
|
|
123
142
|
{ __( 'Save', 'elementor' ) }
|
|
124
143
|
</Button>
|
|
125
144
|
</CardActions>
|
|
126
|
-
</
|
|
145
|
+
</PopoverBody>
|
|
127
146
|
|
|
128
147
|
{ deleteConfirmation && (
|
|
129
148
|
<DeleteConfirmationDialog
|
|
@@ -1,7 +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 {
|
|
4
|
+
import { PopoverBody } from '@elementor/editor-editing-panel';
|
|
5
5
|
import { PopoverHeader, PopoverMenuList, PopoverSearch, type VirtualizedItem } from '@elementor/editor-ui';
|
|
6
6
|
import { BrushIcon, ColorFilterIcon, PlusIcon, SettingsIcon } from '@elementor/icons';
|
|
7
7
|
import { Divider, IconButton } from '@elementor/ui';
|
|
@@ -76,7 +76,7 @@ export const ColorVariablesSelection = ( { closePopover, onAdd, onEdit, onSettin
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
return (
|
|
79
|
-
|
|
79
|
+
<PopoverBody>
|
|
80
80
|
<PopoverHeader
|
|
81
81
|
title={ __( 'Variables', 'elementor' ) }
|
|
82
82
|
icon={ <ColorFilterIcon fontSize={ SIZE } /> }
|
|
@@ -94,37 +94,35 @@ export const ColorVariablesSelection = ( { closePopover, onAdd, onEdit, onSettin
|
|
|
94
94
|
|
|
95
95
|
<Divider />
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
</PopoverScrollableContent>
|
|
128
|
-
</>
|
|
97
|
+
{ hasVariables && hasSearchResults && (
|
|
98
|
+
<PopoverMenuList
|
|
99
|
+
items={ items }
|
|
100
|
+
onSelect={ handleSetColorVariable }
|
|
101
|
+
onClose={ () => {} }
|
|
102
|
+
selectedValue={ variable }
|
|
103
|
+
data-testid="color-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={ <BrushIcon fontSize="large" /> }
|
|
116
|
+
/>
|
|
117
|
+
) }
|
|
118
|
+
|
|
119
|
+
{ ! hasVariables && (
|
|
120
|
+
<NoVariables
|
|
121
|
+
title={ __( 'Create your first color variable', 'elementor' ) }
|
|
122
|
+
icon={ <BrushIcon fontSize="large" /> }
|
|
123
|
+
onAdd={ onAdd }
|
|
124
|
+
/>
|
|
125
|
+
) }
|
|
126
|
+
</PopoverBody>
|
|
129
127
|
);
|
|
130
128
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { PopoverContent, useBoundProp } from '@elementor/editor-controls';
|
|
4
|
-
import {
|
|
4
|
+
import { PopoverBody } from '@elementor/editor-editing-panel';
|
|
5
5
|
import { PopoverHeader } from '@elementor/editor-ui';
|
|
6
6
|
import { ArrowLeftIcon, TextIcon } from '@elementor/icons';
|
|
7
|
-
import { Button, CardActions, Divider, IconButton } from '@elementor/ui';
|
|
7
|
+
import { Button, CardActions, Divider, FormHelperText, IconButton } from '@elementor/ui';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
|
|
10
10
|
import { createVariable } from '../hooks/use-prop-variables';
|
|
@@ -24,10 +24,12 @@ export const FontVariableCreation = ( { onClose, onGoBack }: Props ) => {
|
|
|
24
24
|
|
|
25
25
|
const [ fontFamily, setFontFamily ] = useState( '' );
|
|
26
26
|
const [ label, setLabel ] = useState( '' );
|
|
27
|
+
const [ errorMessage, setErrorMessage ] = useState( '' );
|
|
27
28
|
|
|
28
29
|
const resetFields = () => {
|
|
29
30
|
setFontFamily( '' );
|
|
30
31
|
setLabel( '' );
|
|
32
|
+
setErrorMessage( '' );
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
const closePopover = () => {
|
|
@@ -40,10 +42,14 @@ export const FontVariableCreation = ( { onClose, onGoBack }: Props ) => {
|
|
|
40
42
|
value: fontFamily,
|
|
41
43
|
label,
|
|
42
44
|
type: fontVariablePropTypeUtil.key,
|
|
43
|
-
} )
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
} )
|
|
46
|
+
.then( ( key ) => {
|
|
47
|
+
setVariable( key );
|
|
48
|
+
closePopover();
|
|
49
|
+
} )
|
|
50
|
+
.catch( ( error ) => {
|
|
51
|
+
setErrorMessage( error.message );
|
|
52
|
+
} );
|
|
47
53
|
};
|
|
48
54
|
|
|
49
55
|
const hasEmptyValue = () => {
|
|
@@ -53,7 +59,7 @@ export const FontVariableCreation = ( { onClose, onGoBack }: Props ) => {
|
|
|
53
59
|
const isSubmitDisabled = hasEmptyValue();
|
|
54
60
|
|
|
55
61
|
return (
|
|
56
|
-
<
|
|
62
|
+
<PopoverBody height="auto">
|
|
57
63
|
<PopoverHeader
|
|
58
64
|
icon={
|
|
59
65
|
<>
|
|
@@ -72,8 +78,22 @@ export const FontVariableCreation = ( { onClose, onGoBack }: Props ) => {
|
|
|
72
78
|
<Divider />
|
|
73
79
|
|
|
74
80
|
<PopoverContent p={ 2 }>
|
|
75
|
-
<LabelField
|
|
76
|
-
|
|
81
|
+
<LabelField
|
|
82
|
+
value={ label }
|
|
83
|
+
onChange={ ( value ) => {
|
|
84
|
+
setLabel( value );
|
|
85
|
+
setErrorMessage( '' );
|
|
86
|
+
} }
|
|
87
|
+
/>
|
|
88
|
+
<FontField
|
|
89
|
+
value={ fontFamily }
|
|
90
|
+
onChange={ ( value ) => {
|
|
91
|
+
setFontFamily( value );
|
|
92
|
+
setErrorMessage( '' );
|
|
93
|
+
} }
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
{ errorMessage && <FormHelperText error>{ errorMessage }</FormHelperText> }
|
|
77
97
|
</PopoverContent>
|
|
78
98
|
|
|
79
99
|
<CardActions sx={ { pt: 0.5, pb: 1 } }>
|
|
@@ -81,6 +101,6 @@ export const FontVariableCreation = ( { onClose, onGoBack }: Props ) => {
|
|
|
81
101
|
{ __( 'Create', 'elementor' ) }
|
|
82
102
|
</Button>
|
|
83
103
|
</CardActions>
|
|
84
|
-
</
|
|
104
|
+
</PopoverBody>
|
|
85
105
|
);
|
|
86
106
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { PopoverContent, useBoundProp } from '@elementor/editor-controls';
|
|
4
|
-
import {
|
|
4
|
+
import { PopoverBody } from '@elementor/editor-editing-panel';
|
|
5
5
|
import { PopoverHeader } from '@elementor/editor-ui';
|
|
6
6
|
import { ArrowLeftIcon, TextIcon, TrashIcon } from '@elementor/icons';
|
|
7
|
-
import { Button, CardActions, Divider, IconButton } from '@elementor/ui';
|
|
7
|
+
import { Button, CardActions, Divider, FormHelperText, IconButton } from '@elementor/ui';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
|
|
10
10
|
import { deleteVariable, updateVariable, useVariable } from '../hooks/use-prop-variables';
|
|
@@ -25,6 +25,7 @@ type Props = {
|
|
|
25
25
|
export const FontVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Props ) => {
|
|
26
26
|
const { setValue: notifyBoundPropChange, value: assignedValue } = useBoundProp( fontVariablePropTypeUtil );
|
|
27
27
|
const [ deleteConfirmation, setDeleteConfirmation ] = useState( false );
|
|
28
|
+
const [ errorMessage, setErrorMessage ] = useState( '' );
|
|
28
29
|
|
|
29
30
|
const variable = useVariable( editId );
|
|
30
31
|
if ( ! variable ) {
|
|
@@ -38,10 +39,14 @@ export const FontVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Props
|
|
|
38
39
|
updateVariable( editId, {
|
|
39
40
|
value: fontFamily,
|
|
40
41
|
label,
|
|
41
|
-
} )
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
} )
|
|
43
|
+
.then( () => {
|
|
44
|
+
maybeTriggerBoundPropChange();
|
|
45
|
+
onSubmit?.();
|
|
46
|
+
} )
|
|
47
|
+
.catch( ( error ) => {
|
|
48
|
+
setErrorMessage( error.message );
|
|
49
|
+
} );
|
|
45
50
|
};
|
|
46
51
|
|
|
47
52
|
const handleDelete = () => {
|
|
@@ -90,7 +95,7 @@ export const FontVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Props
|
|
|
90
95
|
|
|
91
96
|
return (
|
|
92
97
|
<>
|
|
93
|
-
<
|
|
98
|
+
<PopoverBody height="auto">
|
|
94
99
|
<PopoverHeader
|
|
95
100
|
icon={
|
|
96
101
|
<>
|
|
@@ -114,8 +119,22 @@ export const FontVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Props
|
|
|
114
119
|
<Divider />
|
|
115
120
|
|
|
116
121
|
<PopoverContent p={ 2 }>
|
|
117
|
-
<LabelField
|
|
118
|
-
|
|
122
|
+
<LabelField
|
|
123
|
+
value={ label }
|
|
124
|
+
onChange={ ( value ) => {
|
|
125
|
+
setLabel( value );
|
|
126
|
+
setErrorMessage( '' );
|
|
127
|
+
} }
|
|
128
|
+
/>
|
|
129
|
+
<FontField
|
|
130
|
+
value={ fontFamily }
|
|
131
|
+
onChange={ ( value ) => {
|
|
132
|
+
setFontFamily( value );
|
|
133
|
+
setErrorMessage( '' );
|
|
134
|
+
} }
|
|
135
|
+
/>
|
|
136
|
+
|
|
137
|
+
{ errorMessage && <FormHelperText error>{ errorMessage }</FormHelperText> }
|
|
119
138
|
</PopoverContent>
|
|
120
139
|
|
|
121
140
|
<CardActions sx={ { pt: 0.5, pb: 1 } }>
|
|
@@ -123,7 +142,7 @@ export const FontVariableEdit = ( { onClose, onGoBack, onSubmit, editId }: Props
|
|
|
123
142
|
{ __( 'Save', 'elementor' ) }
|
|
124
143
|
</Button>
|
|
125
144
|
</CardActions>
|
|
126
|
-
</
|
|
145
|
+
</PopoverBody>
|
|
127
146
|
|
|
128
147
|
{ deleteConfirmation && (
|
|
129
148
|
<DeleteConfirmationDialog
|
|
@@ -1,7 +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 {
|
|
4
|
+
import { PopoverBody } from '@elementor/editor-editing-panel';
|
|
5
5
|
import { PopoverHeader, PopoverMenuList, PopoverSearch, type VirtualizedItem } from '@elementor/editor-ui';
|
|
6
6
|
import { ColorFilterIcon, PlusIcon, SettingsIcon, TextIcon } from '@elementor/icons';
|
|
7
7
|
import { Divider, IconButton } from '@elementor/ui';
|
|
@@ -75,7 +75,7 @@ export const FontVariablesSelection = ( { closePopover, onAdd, onEdit, onSetting
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
return (
|
|
78
|
-
|
|
78
|
+
<PopoverBody>
|
|
79
79
|
<PopoverHeader
|
|
80
80
|
title={ __( 'Variables', 'elementor' ) }
|
|
81
81
|
onClose={ closePopover }
|
|
@@ -93,37 +93,35 @@ export const FontVariablesSelection = ( { closePopover, onAdd, onEdit, onSetting
|
|
|
93
93
|
|
|
94
94
|
<Divider />
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
</PopoverScrollableContent>
|
|
127
|
-
</>
|
|
96
|
+
{ hasVariables && hasSearchResults && (
|
|
97
|
+
<PopoverMenuList
|
|
98
|
+
items={ items }
|
|
99
|
+
onSelect={ handleSetVariable }
|
|
100
|
+
onClose={ () => {} }
|
|
101
|
+
selectedValue={ variable }
|
|
102
|
+
data-testid="font-variables-list"
|
|
103
|
+
menuListTemplate={ VariablesStyledMenuList }
|
|
104
|
+
menuItemContentTemplate={ ( item: VirtualizedItem< 'item', string > ) => (
|
|
105
|
+
<MenuItemContent item={ item } />
|
|
106
|
+
) }
|
|
107
|
+
/>
|
|
108
|
+
) }
|
|
109
|
+
|
|
110
|
+
{ ! hasSearchResults && hasVariables && (
|
|
111
|
+
<NoSearchResults
|
|
112
|
+
searchValue={ searchValue }
|
|
113
|
+
onClear={ handleClearSearch }
|
|
114
|
+
icon={ <TextIcon fontSize="large" /> }
|
|
115
|
+
/>
|
|
116
|
+
) }
|
|
117
|
+
|
|
118
|
+
{ ! hasVariables && (
|
|
119
|
+
<NoVariables
|
|
120
|
+
title={ __( 'Create your first font variable', 'elementor' ) }
|
|
121
|
+
icon={ <TextIcon fontSize="large" /> }
|
|
122
|
+
onAdd={ onAdd }
|
|
123
|
+
/>
|
|
124
|
+
) }
|
|
125
|
+
</PopoverBody>
|
|
128
126
|
);
|
|
129
127
|
};
|
|
@@ -28,23 +28,20 @@ export const DeleteConfirmationDialog = ( {
|
|
|
28
28
|
<Dialog open={ open } onClose={ closeDialog } aria-labelledby={ TITLE_ID } maxWidth="xs">
|
|
29
29
|
<DialogTitle id={ TITLE_ID } display="flex" alignItems="center" gap={ 1 } sx={ { lineHeight: 1 } }>
|
|
30
30
|
<AlertOctagonFilledIcon color="error" />
|
|
31
|
-
{ __( 'Delete
|
|
31
|
+
{ __( 'Delete this variable?', 'elementor' ) }
|
|
32
32
|
</DialogTitle>
|
|
33
33
|
<DialogContent>
|
|
34
34
|
<DialogContentText variant="body2" color="textPrimary">
|
|
35
|
-
{ __( '
|
|
35
|
+
{ __( 'All elements using', 'elementor' ) }
|
|
36
36
|
<Typography variant="subtitle2" component="span">
|
|
37
37
|
{ label }
|
|
38
38
|
</Typography>
|
|
39
|
-
{ __(
|
|
40
|
-
'Variable. Note that its value is still being used anywhere on your site where it was connected to the variable.',
|
|
41
|
-
'elementor'
|
|
42
|
-
) }
|
|
39
|
+
{ __( 'will keep their current values, but the variable itself will be removed.', 'elementor' ) }
|
|
43
40
|
</DialogContentText>
|
|
44
41
|
</DialogContent>
|
|
45
42
|
<DialogActions>
|
|
46
43
|
<Button color="secondary" onClick={ closeDialog }>
|
|
47
|
-
{ __( '
|
|
44
|
+
{ __( 'Not now', 'elementor' ) }
|
|
48
45
|
</Button>
|
|
49
46
|
<Button variant="contained" color="error" onClick={ onConfirm }>
|
|
50
47
|
{ __( 'Delete', 'elementor' ) }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useSectionWidth } from '@elementor/editor-editing-panel';
|
|
3
|
+
import { Alert, AlertAction, AlertTitle, ClickAwayListener } from '@elementor/ui';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
type DeletedVariableAlertProps = {
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
onUnlink?: () => void;
|
|
9
|
+
onRestore?: () => void;
|
|
10
|
+
label: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const DeletedVariableAlert = ( { onClose, onUnlink, onRestore, label }: DeletedVariableAlertProps ) => {
|
|
14
|
+
const sectionWidth = useSectionWidth();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<ClickAwayListener onClickAway={ onClose }>
|
|
18
|
+
<Alert
|
|
19
|
+
variant="standard"
|
|
20
|
+
severity="warning"
|
|
21
|
+
onClose={ onClose }
|
|
22
|
+
action={
|
|
23
|
+
<>
|
|
24
|
+
{ onUnlink && (
|
|
25
|
+
<AlertAction variant="contained" onClick={ onUnlink }>
|
|
26
|
+
{ __( 'Unlink', 'elementor' ) }
|
|
27
|
+
</AlertAction>
|
|
28
|
+
) }
|
|
29
|
+
{ onRestore && (
|
|
30
|
+
<AlertAction variant="outlined" onClick={ onRestore }>
|
|
31
|
+
{ __( 'Restore', 'elementor' ) }
|
|
32
|
+
</AlertAction>
|
|
33
|
+
) }
|
|
34
|
+
</>
|
|
35
|
+
}
|
|
36
|
+
sx={ { width: sectionWidth } }
|
|
37
|
+
>
|
|
38
|
+
<AlertTitle>{ __( 'Deleted variable', 'elementor' ) }</AlertTitle>
|
|
39
|
+
{ __( 'The variable', 'elementor' ) } '{ label }'{ ' ' }
|
|
40
|
+
{ __(
|
|
41
|
+
'has been deleted, but it is still referenced in this location. You may restore the variable or unlink it to assign a different value.',
|
|
42
|
+
'elementor'
|
|
43
|
+
) }
|
|
44
|
+
</Alert>
|
|
45
|
+
</ClickAwayListener>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DetachIcon } from '@elementor/icons';
|
|
3
|
-
import { Box, IconButton, Stack, Typography, UnstableTag as Tag, type UnstableTagProps } from '@elementor/ui';
|
|
3
|
+
import { Box, IconButton, Stack, Tooltip, Typography, UnstableTag as Tag, type UnstableTagProps } from '@elementor/ui';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
|
|
6
6
|
export const SIZE = 'tiny';
|
|
@@ -21,23 +21,25 @@ export const AssignedTag = ( { startIcon, label, onUnlink, ...props }: VariableT
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
24
|
+
<Tooltip title={ label } placement="top">
|
|
25
|
+
<Tag
|
|
26
|
+
fullWidth
|
|
27
|
+
showActionsOnHover
|
|
28
|
+
startIcon={
|
|
29
|
+
<Stack gap={ 0.5 } direction="row" alignItems="center">
|
|
30
|
+
{ startIcon }
|
|
31
|
+
</Stack>
|
|
32
|
+
}
|
|
33
|
+
label={
|
|
34
|
+
<Box sx={ { display: 'inline-grid', minWidth: 0 } }>
|
|
35
|
+
<Typography sx={ { lineHeight: 1.34 } } variant="caption" noWrap>
|
|
36
|
+
{ label }
|
|
37
|
+
</Typography>
|
|
38
|
+
</Box>
|
|
39
|
+
}
|
|
40
|
+
actions={ actions }
|
|
41
|
+
{ ...props }
|
|
42
|
+
/>
|
|
43
|
+
</Tooltip>
|
|
42
44
|
);
|
|
43
45
|
};
|