@elementor/editor-interactions 4.1.0-712 → 4.1.0-713
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 +80 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/src/components/controls/direction.tsx +78 -26
- package/src/mcp/tools/schema.ts +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-interactions",
|
|
3
|
-
"version": "4.1.0-
|
|
3
|
+
"version": "4.1.0-713",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,19 +39,19 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor-controls": "4.1.0-
|
|
43
|
-
"@elementor/editor-elements": "4.1.0-
|
|
44
|
-
"@elementor/editor-mcp": "4.1.0-
|
|
45
|
-
"@elementor/editor-props": "4.1.0-
|
|
46
|
-
"@elementor/editor-responsive": "4.1.0-
|
|
47
|
-
"@elementor/editor-ui": "4.1.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "4.1.0-
|
|
42
|
+
"@elementor/editor-controls": "4.1.0-713",
|
|
43
|
+
"@elementor/editor-elements": "4.1.0-713",
|
|
44
|
+
"@elementor/editor-mcp": "4.1.0-713",
|
|
45
|
+
"@elementor/editor-props": "4.1.0-713",
|
|
46
|
+
"@elementor/editor-responsive": "4.1.0-713",
|
|
47
|
+
"@elementor/editor-ui": "4.1.0-713",
|
|
48
|
+
"@elementor/editor-v1-adapters": "4.1.0-713",
|
|
49
49
|
"@elementor/icons": "^1.68.0",
|
|
50
|
-
"@elementor/schema": "4.1.0-
|
|
51
|
-
"@elementor/session": "4.1.0-
|
|
50
|
+
"@elementor/schema": "4.1.0-713",
|
|
51
|
+
"@elementor/session": "4.1.0-713",
|
|
52
52
|
"@elementor/ui": "1.36.17",
|
|
53
|
-
"@elementor/utils": "4.1.0-
|
|
54
|
-
"@elementor/events": "4.1.0-
|
|
53
|
+
"@elementor/utils": "4.1.0-713",
|
|
54
|
+
"@elementor/events": "4.1.0-713",
|
|
55
55
|
"@wordpress/i18n": "^5.13.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
@@ -1,48 +1,100 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { StyledToggleButton, StyledToggleButtonGroup } from '@elementor/editor-controls';
|
|
4
4
|
import { ArrowDownSmallIcon, ArrowLeftIcon, ArrowRightIcon, ArrowUpSmallIcon } from '@elementor/icons';
|
|
5
|
+
import { Tooltip } from '@elementor/ui';
|
|
5
6
|
import { __ } from '@wordpress/i18n';
|
|
6
7
|
|
|
7
8
|
import { type DirectionFieldProps } from '../../types';
|
|
8
9
|
|
|
9
10
|
type Direction = 'top' | 'bottom' | 'left' | 'right';
|
|
10
11
|
|
|
12
|
+
const AXIS: Record< Direction, 'vertical' | 'horizontal' > = {
|
|
13
|
+
top: 'vertical',
|
|
14
|
+
bottom: 'vertical',
|
|
15
|
+
left: 'horizontal',
|
|
16
|
+
right: 'horizontal',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function parseValue( value: string ): Direction[] {
|
|
20
|
+
return value.split( '-' ).filter( Boolean ) as Direction[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function serializeValue( directions: Direction[] ): string {
|
|
24
|
+
const vertical = directions.find( ( d ) => d === 'top' || d === 'bottom' );
|
|
25
|
+
const horizontal = directions.find( ( d ) => d === 'left' || d === 'right' );
|
|
26
|
+
if ( vertical && horizontal ) {
|
|
27
|
+
return `${ vertical }-${ horizontal }`;
|
|
28
|
+
}
|
|
29
|
+
return directions[ 0 ] ?? '';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function toggleDirection( current: Direction[], clicked: Direction ): Direction[] {
|
|
33
|
+
if ( current.includes( clicked ) ) {
|
|
34
|
+
return current.filter( ( d ) => d !== clicked );
|
|
35
|
+
}
|
|
36
|
+
const filtered = current.filter( ( d ) => AXIS[ d ] !== AXIS[ clicked ] );
|
|
37
|
+
return [ ...filtered, clicked ];
|
|
38
|
+
}
|
|
39
|
+
|
|
11
40
|
export function Direction( { value, onChange, interactionType }: DirectionFieldProps ) {
|
|
12
|
-
const
|
|
13
|
-
const isIn = interactionType === 'in';
|
|
41
|
+
const isIn = interactionType === 'in';
|
|
14
42
|
|
|
15
|
-
|
|
43
|
+
const options = useMemo(
|
|
44
|
+
() => [
|
|
16
45
|
{
|
|
17
|
-
|
|
46
|
+
dir: 'top' as Direction,
|
|
18
47
|
label: isIn ? __( 'From top', 'elementor' ) : __( 'To top', 'elementor' ),
|
|
19
|
-
|
|
20
|
-
isIn ? <ArrowDownSmallIcon fontSize={ size } /> : <ArrowUpSmallIcon fontSize={ size } />,
|
|
21
|
-
showTooltip: true,
|
|
48
|
+
Icon: isIn ? ArrowDownSmallIcon : ArrowUpSmallIcon,
|
|
22
49
|
},
|
|
23
50
|
{
|
|
24
|
-
|
|
25
|
-
label:
|
|
26
|
-
|
|
27
|
-
isIn ? <ArrowUpSmallIcon fontSize={ size } /> : <ArrowDownSmallIcon fontSize={ size } />,
|
|
28
|
-
showTooltip: true,
|
|
51
|
+
dir: 'bottom' as Direction,
|
|
52
|
+
label: isIn ? __( 'From bottom', 'elementor' ) : __( 'To bottom', 'elementor' ),
|
|
53
|
+
Icon: isIn ? ArrowUpSmallIcon : ArrowDownSmallIcon,
|
|
29
54
|
},
|
|
30
55
|
{
|
|
31
|
-
|
|
32
|
-
label:
|
|
33
|
-
|
|
34
|
-
isIn ? <ArrowRightIcon fontSize={ size } /> : <ArrowLeftIcon fontSize={ size } />,
|
|
35
|
-
showTooltip: true,
|
|
56
|
+
dir: 'left' as Direction,
|
|
57
|
+
label: isIn ? __( 'From left', 'elementor' ) : __( 'To left', 'elementor' ),
|
|
58
|
+
Icon: isIn ? ArrowRightIcon : ArrowLeftIcon,
|
|
36
59
|
},
|
|
37
60
|
{
|
|
38
|
-
|
|
39
|
-
label:
|
|
40
|
-
|
|
41
|
-
isIn ? <ArrowLeftIcon fontSize={ size } /> : <ArrowRightIcon fontSize={ size } />,
|
|
42
|
-
showTooltip: true,
|
|
61
|
+
dir: 'right' as Direction,
|
|
62
|
+
label: isIn ? __( 'From right', 'elementor' ) : __( 'To right', 'elementor' ),
|
|
63
|
+
Icon: isIn ? ArrowLeftIcon : ArrowRightIcon,
|
|
43
64
|
},
|
|
44
|
-
]
|
|
45
|
-
|
|
65
|
+
],
|
|
66
|
+
[ isIn ]
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const selectedDirections = useMemo( () => parseValue( value ), [ value ] );
|
|
46
70
|
|
|
47
|
-
return
|
|
71
|
+
return (
|
|
72
|
+
<StyledToggleButtonGroup
|
|
73
|
+
size="tiny"
|
|
74
|
+
justify="end"
|
|
75
|
+
sx={ {
|
|
76
|
+
display: 'grid',
|
|
77
|
+
gridTemplateColumns: 'repeat(4, minmax(0, 25%))',
|
|
78
|
+
width: '100%',
|
|
79
|
+
} }
|
|
80
|
+
>
|
|
81
|
+
{ options.map( ( { dir, label, Icon } ) => (
|
|
82
|
+
<Tooltip key={ dir } title={ label } disableFocusListener placement="top">
|
|
83
|
+
<StyledToggleButton
|
|
84
|
+
value={ dir }
|
|
85
|
+
selected={ selectedDirections.includes( dir ) }
|
|
86
|
+
aria-label={ label }
|
|
87
|
+
size="tiny"
|
|
88
|
+
isPlaceholder={ false }
|
|
89
|
+
onChange={ () => {
|
|
90
|
+
const next = toggleDirection( selectedDirections, dir );
|
|
91
|
+
onChange( serializeValue( next ) );
|
|
92
|
+
} }
|
|
93
|
+
>
|
|
94
|
+
<Icon fontSize="tiny" />
|
|
95
|
+
</StyledToggleButton>
|
|
96
|
+
</Tooltip>
|
|
97
|
+
) ) }
|
|
98
|
+
</StyledToggleButtonGroup>
|
|
99
|
+
);
|
|
48
100
|
}
|
package/src/mcp/tools/schema.ts
CHANGED
|
@@ -5,9 +5,11 @@ export const baseSchema = {
|
|
|
5
5
|
effect: z.enum( [ 'fade', 'slide', 'scale' ] ).optional().describe( 'Animation effect type' ),
|
|
6
6
|
effectType: z.enum( [ 'in', 'out' ] ).optional().describe( 'Whether the animation plays in or out' ),
|
|
7
7
|
direction: z
|
|
8
|
-
.enum( [ 'top', 'bottom', 'left', 'right', '' ] )
|
|
8
|
+
.enum( [ 'top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right' ] )
|
|
9
9
|
.optional()
|
|
10
|
-
.describe(
|
|
10
|
+
.describe(
|
|
11
|
+
'Direction of the Animation. Can be one of the following or empty if not needed. At slide effect, this is required field.'
|
|
12
|
+
),
|
|
11
13
|
duration: z.number().min( 0 ).max( 10000 ).optional().describe( 'Animation duration in milliseconds' ),
|
|
12
14
|
delay: z.number().min( 0 ).max( 10000 ).optional().describe( 'Animation delay in milliseconds' ),
|
|
13
15
|
easing: z.string().optional().describe( 'Easing function. See interactions schema for options.' ),
|