@elementor/editor-interactions 4.0.0-609 → 4.0.0-621
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.d.mts +0 -5
- package/dist/index.d.ts +0 -5
- package/dist/index.js +154 -132
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +154 -132
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
- package/src/mcp/index.ts +65 -4
- package/src/mcp/resources/interactions-schema-resource.ts +6 -39
- package/src/mcp/tools/manage-element-interaction-tool.ts +44 -111
- package/src/mcp/tools/schema.ts +73 -0
- package/src/types.ts +0 -6
- package/src/utils/get-interactions-config.ts +0 -1
- package/src/utils/prop-value-utils.ts +11 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-interactions",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-621",
|
|
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-controls": "4.0.0-
|
|
43
|
-
"@elementor/editor-elements": "4.0.0-
|
|
44
|
-
"@elementor/editor-mcp": "4.0.0-
|
|
45
|
-
"@elementor/editor-props": "4.0.0-
|
|
46
|
-
"@elementor/editor-responsive": "4.0.0-
|
|
47
|
-
"@elementor/editor-ui": "4.0.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "4.0.0-
|
|
42
|
+
"@elementor/editor-controls": "4.0.0-621",
|
|
43
|
+
"@elementor/editor-elements": "4.0.0-621",
|
|
44
|
+
"@elementor/editor-mcp": "4.0.0-621",
|
|
45
|
+
"@elementor/editor-props": "4.0.0-621",
|
|
46
|
+
"@elementor/editor-responsive": "4.0.0-621",
|
|
47
|
+
"@elementor/editor-ui": "4.0.0-621",
|
|
48
|
+
"@elementor/editor-v1-adapters": "4.0.0-621",
|
|
49
49
|
"@elementor/icons": "^1.68.0",
|
|
50
|
-
"@elementor/schema": "4.0.0-
|
|
51
|
-
"@elementor/session": "4.0.0-
|
|
50
|
+
"@elementor/schema": "4.0.0-621",
|
|
51
|
+
"@elementor/session": "4.0.0-621",
|
|
52
52
|
"@elementor/ui": "1.36.17",
|
|
53
|
-
"@elementor/utils": "4.0.0-
|
|
53
|
+
"@elementor/utils": "4.0.0-621",
|
|
54
54
|
"@wordpress/i18n": "^5.13.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
package/src/mcp/index.ts
CHANGED
|
@@ -1,13 +1,74 @@
|
|
|
1
1
|
import { getMCPByDomain } from '@elementor/editor-mcp';
|
|
2
2
|
|
|
3
|
+
import { MAX_INTERACTIONS_PER_ELEMENT } from './constants';
|
|
3
4
|
import { initInteractionsSchemaResource } from './resources/interactions-schema-resource';
|
|
4
5
|
import { initManageElementInteractionTool } from './tools/manage-element-interaction-tool';
|
|
5
6
|
|
|
6
7
|
export const initMcpInteractions = () => {
|
|
7
8
|
const reg = getMCPByDomain( 'interactions', {
|
|
8
|
-
instructions:
|
|
9
|
-
|
|
9
|
+
instructions: `
|
|
10
|
+
MCP server for managing element interactions and animations. Use this to add, modify, or remove animations and motion effects triggered by user events such as page load or scroll-into-view.
|
|
11
|
+
** IMPORTANT **
|
|
12
|
+
Use the "interactions-schema" resource to get the schema of the interactions.
|
|
13
|
+
Actions:
|
|
14
|
+
- get: Read the current interactions on the element.
|
|
15
|
+
- add: Add a new interaction (max ${ MAX_INTERACTIONS_PER_ELEMENT } per element).
|
|
16
|
+
- update: Update an existing interaction by its interactionId.
|
|
17
|
+
- delete: Remove a specific interaction by its interactionId.
|
|
18
|
+
- clear: Remove all interactions from the element.
|
|
19
|
+
|
|
20
|
+
For add/update, provide: trigger, effect, effectType, direction (required for slide effect), duration, delay, easing.
|
|
21
|
+
Use excludedBreakpoints to disable the animation on specific responsive breakpoints (e.g. ["mobile", "tablet"]).
|
|
22
|
+
Example Get Request:
|
|
23
|
+
{
|
|
24
|
+
"elementId": "123",
|
|
25
|
+
"action": "get",
|
|
26
|
+
"interactionId": "123",
|
|
27
|
+
"animationData": {
|
|
28
|
+
"trigger": "click",
|
|
29
|
+
"effect": "fade",
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
Example Add Request:
|
|
33
|
+
{
|
|
34
|
+
"elementId": "123",
|
|
35
|
+
"action": "add",
|
|
36
|
+
"animationData": {
|
|
37
|
+
"effectType": "in",
|
|
38
|
+
"direction": "top",
|
|
39
|
+
"trigger": "click",
|
|
40
|
+
"effect": "fade",
|
|
41
|
+
"duration": 1000,
|
|
42
|
+
"delay": 0,
|
|
43
|
+
"easing": "easeIn",
|
|
44
|
+
"excludedBreakpoints": ["mobile", "tablet"],
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
Example Update Request:
|
|
48
|
+
{
|
|
49
|
+
"elementId": "123",
|
|
50
|
+
"action": "update",
|
|
51
|
+
"interactionId": "123",
|
|
52
|
+
"animationData": {
|
|
53
|
+
"trigger": "click",
|
|
54
|
+
"effect": "fade",
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
Example Delete Request:
|
|
58
|
+
{
|
|
59
|
+
"elementId": "123",
|
|
60
|
+
"action": "delete",
|
|
61
|
+
"interactionId": "123",
|
|
62
|
+
}
|
|
63
|
+
Example Clear Request:
|
|
64
|
+
{
|
|
65
|
+
"elementId": "123",
|
|
66
|
+
"action": "clear",
|
|
67
|
+
}
|
|
68
|
+
`,
|
|
69
|
+
} );
|
|
70
|
+
reg.waitForReady().then( () => {
|
|
71
|
+
initInteractionsSchemaResource( reg );
|
|
72
|
+
initManageElementInteractionTool( reg );
|
|
10
73
|
} );
|
|
11
|
-
initInteractionsSchemaResource( reg );
|
|
12
|
-
initManageElementInteractionTool( reg );
|
|
13
74
|
};
|
|
@@ -1,60 +1,27 @@
|
|
|
1
1
|
import { type MCPRegistryEntry } from '@elementor/editor-mcp';
|
|
2
|
+
import { isProActive } from '@elementor/utils';
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
-
import { BASE_TRIGGERS, TRIGGER_OPTIONS } from '../../components/controls/trigger';
|
|
5
|
-
import { MAX_INTERACTIONS_PER_ELEMENT } from '../constants';
|
|
4
|
+
import { baseSchema, proSchema } from '../tools/schema';
|
|
6
5
|
|
|
7
6
|
export const INTERACTIONS_SCHEMA_URI = 'elementor://interactions/schema';
|
|
8
7
|
|
|
9
|
-
const schema = {
|
|
10
|
-
triggers: BASE_TRIGGERS.map( ( key ) => ( {
|
|
11
|
-
value: key,
|
|
12
|
-
label: TRIGGER_OPTIONS[ key as keyof typeof TRIGGER_OPTIONS ] ?? key,
|
|
13
|
-
} ) ),
|
|
14
|
-
effects: [
|
|
15
|
-
{ value: 'fade', label: 'Fade' },
|
|
16
|
-
{ value: 'slide', label: 'Slide' },
|
|
17
|
-
{ value: 'scale', label: 'Scale' },
|
|
18
|
-
],
|
|
19
|
-
effectTypes: [
|
|
20
|
-
{ value: 'in', label: 'In' },
|
|
21
|
-
{ value: 'out', label: 'Out' },
|
|
22
|
-
],
|
|
23
|
-
directions: [
|
|
24
|
-
{ value: 'top', label: 'Top', note: '' },
|
|
25
|
-
{ value: 'bottom', label: 'Bottom', note: '' },
|
|
26
|
-
{ value: 'left', label: 'Left', note: '' },
|
|
27
|
-
{ value: 'right', label: 'Right', note: '' },
|
|
28
|
-
{ value: '', label: 'None', note: 'Slide animation must have a direction' },
|
|
29
|
-
],
|
|
30
|
-
easings: Object.entries( EASING_OPTIONS ).map( ( [ value, label ] ) => ( { value, label } ) ),
|
|
31
|
-
timing: {
|
|
32
|
-
duration: { min: 0, max: 10000, unit: 'ms', description: 'Animation duration in milliseconds' },
|
|
33
|
-
delay: { min: 0, max: 10000, unit: 'ms', description: 'Animation delay in milliseconds' },
|
|
34
|
-
},
|
|
35
|
-
excludedBreakpoints: {
|
|
36
|
-
type: 'string[]',
|
|
37
|
-
description: 'List of breakpoint IDs on which this interaction is disabled. Omit to enable on all breakpoints.',
|
|
38
|
-
},
|
|
39
|
-
maxInteractionsPerElement: MAX_INTERACTIONS_PER_ELEMENT,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
8
|
export const initInteractionsSchemaResource = ( reg: MCPRegistryEntry ) => {
|
|
43
9
|
const { resource } = reg;
|
|
10
|
+
const schema = isProActive() ? { ...baseSchema, ...proSchema } : baseSchema;
|
|
44
11
|
|
|
45
12
|
resource(
|
|
46
13
|
'interactions-schema',
|
|
47
14
|
INTERACTIONS_SCHEMA_URI,
|
|
48
15
|
{
|
|
49
|
-
description:
|
|
50
|
-
'Schema describing all available options for element interactions (triggers, effects, easings, timing, breakpoints, etc.).',
|
|
16
|
+
description: 'Schema describing all available options for element interactions.',
|
|
51
17
|
},
|
|
52
18
|
async () => {
|
|
53
19
|
return {
|
|
54
20
|
contents: [
|
|
55
21
|
{
|
|
56
22
|
uri: INTERACTIONS_SCHEMA_URI,
|
|
57
|
-
|
|
23
|
+
mimeType: 'application/json',
|
|
24
|
+
text: JSON.stringify( schema ),
|
|
58
25
|
},
|
|
59
26
|
],
|
|
60
27
|
};
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { updateElementInteractions } from '@elementor/editor-elements';
|
|
2
2
|
import { type MCPRegistryEntry } from '@elementor/editor-mcp';
|
|
3
3
|
import { z } from '@elementor/schema';
|
|
4
|
+
import { isProActive } from '@elementor/utils';
|
|
4
5
|
|
|
5
|
-
import { DEFAULT_VALUES } from '../../components/interaction-details';
|
|
6
6
|
import { interactionsRepository } from '../../interactions-repository';
|
|
7
7
|
import { type ElementInteractions } from '../../types';
|
|
8
|
-
import {
|
|
9
|
-
createInteractionItem,
|
|
10
|
-
extractExcludedBreakpoints,
|
|
11
|
-
extractSize,
|
|
12
|
-
extractString,
|
|
13
|
-
} from '../../utils/prop-value-utils';
|
|
8
|
+
import { createInteractionItem, extractString } from '../../utils/prop-value-utils';
|
|
14
9
|
import { generateTempInteractionId } from '../../utils/temp-id-utils';
|
|
15
10
|
import { MAX_INTERACTIONS_PER_ELEMENT } from '../constants';
|
|
16
11
|
import { INTERACTIONS_SCHEMA_URI } from '../resources/interactions-schema-resource';
|
|
12
|
+
import { baseSchema, proSchema } from './schema';
|
|
17
13
|
|
|
18
14
|
const EMPTY_INTERACTIONS: ElementInteractions = {
|
|
19
15
|
version: 1,
|
|
@@ -22,94 +18,56 @@ const EMPTY_INTERACTIONS: ElementInteractions = {
|
|
|
22
18
|
|
|
23
19
|
export const initManageElementInteractionTool = ( reg: MCPRegistryEntry ) => {
|
|
24
20
|
const { addTool } = reg;
|
|
21
|
+
const extendedSchema = isProActive() ? { ...baseSchema, ...proSchema } : baseSchema;
|
|
22
|
+
const schema = {
|
|
23
|
+
elementId: z.string().describe( 'The ID of the element to read or modify interactions on' ),
|
|
24
|
+
action: z
|
|
25
|
+
.enum( [ 'get', 'add', 'update', 'delete', 'clear' ] )
|
|
26
|
+
.describe( 'Operation to perform. Use "get" first to inspect existing interactions.' ),
|
|
27
|
+
interactionId: z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe( 'Interaction ID — required for update and delete. Obtain from a prior "get" call.' ),
|
|
31
|
+
...extendedSchema,
|
|
32
|
+
};
|
|
25
33
|
|
|
26
34
|
addTool( {
|
|
27
35
|
name: 'manage-element-interaction',
|
|
28
|
-
description: `
|
|
29
|
-
|
|
30
|
-
Actions:
|
|
31
|
-
- get: Read the current interactions on the element.
|
|
32
|
-
- add: Add a new interaction (max ${ MAX_INTERACTIONS_PER_ELEMENT } per element).
|
|
33
|
-
- update: Update an existing interaction by its interactionId.
|
|
34
|
-
- delete: Remove a specific interaction by its interactionId.
|
|
35
|
-
- clear: Remove all interactions from the element.
|
|
36
|
-
|
|
37
|
-
For add/update, provide: trigger, effect, effectType, direction (empty string for non-slide effects), duration, delay, easing.
|
|
38
|
-
Use excludedBreakpoints to disable the animation on specific responsive breakpoints (e.g. ["mobile", "tablet"]).`,
|
|
39
|
-
schema: {
|
|
40
|
-
elementId: z.string().describe( 'The ID of the element to read or modify interactions on' ),
|
|
41
|
-
action: z
|
|
42
|
-
.enum( [ 'get', 'add', 'update', 'delete', 'clear' ] )
|
|
43
|
-
.describe( 'Operation to perform. Use "get" first to inspect existing interactions.' ),
|
|
44
|
-
interactionId: z
|
|
45
|
-
.string()
|
|
46
|
-
.optional()
|
|
47
|
-
.describe( 'Interaction ID — required for update and delete. Obtain from a prior "get" call.' ),
|
|
48
|
-
trigger: z.enum( [ 'load', 'scrollIn' ] ).optional().describe( 'Event that triggers the animation' ),
|
|
49
|
-
effect: z.enum( [ 'fade', 'slide', 'scale' ] ).optional().describe( 'Animation effect type' ),
|
|
50
|
-
effectType: z.enum( [ 'in', 'out' ] ).optional().describe( 'Whether the animation plays in or out' ),
|
|
51
|
-
direction: z
|
|
52
|
-
.enum( [ 'top', 'bottom', 'left', 'right', '' ] )
|
|
53
|
-
.optional()
|
|
54
|
-
.describe( 'Direction for slide effect. Use empty string for fade/scale.' ),
|
|
55
|
-
duration: z.number().min( 0 ).max( 10000 ).optional().describe( 'Animation duration in milliseconds' ),
|
|
56
|
-
delay: z.number().min( 0 ).max( 10000 ).optional().describe( 'Animation delay in milliseconds' ),
|
|
57
|
-
easing: z.string().optional().describe( 'Easing function. See interactions schema for options.' ),
|
|
58
|
-
excludedBreakpoints: z
|
|
59
|
-
.array( z.string() )
|
|
60
|
-
.optional()
|
|
61
|
-
.describe(
|
|
62
|
-
'Breakpoint IDs on which this interaction is disabled (e.g. ["mobile", "tablet"]). Omit to enable on all breakpoints.'
|
|
63
|
-
),
|
|
64
|
-
},
|
|
36
|
+
description: `Manage the element interaction.`,
|
|
37
|
+
schema,
|
|
65
38
|
requiredResources: [
|
|
66
39
|
{ uri: INTERACTIONS_SCHEMA_URI, description: 'Interactions schema with all available options' },
|
|
67
40
|
],
|
|
68
41
|
isDestructive: true,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
42
|
+
outputSchema: {
|
|
43
|
+
success: z.boolean().describe( 'Whether the action was successful' ),
|
|
44
|
+
action: z
|
|
45
|
+
.enum( [ 'get', 'add', 'update', 'delete', 'clear' ] )
|
|
46
|
+
.describe( 'Operation to perform. Use "get" first to inspect existing interactions.' ),
|
|
47
|
+
elementId: z.string().optional().describe( 'The ID of the element to read or modify interactions on' ),
|
|
48
|
+
interactions: z.array( z.any() ).optional().describe( 'The interactions on the element' ),
|
|
49
|
+
count: z.number().optional().describe( 'The number of interactions on the element' ),
|
|
50
|
+
},
|
|
51
|
+
handler: ( input: {
|
|
52
|
+
elementId: string;
|
|
53
|
+
action: 'get' | 'add' | 'update' | 'delete' | 'clear';
|
|
54
|
+
interactionId?: string;
|
|
55
|
+
[ key: string ]: unknown;
|
|
56
|
+
} ) => {
|
|
57
|
+
const { elementId, action, interactionId, ...animationData } = input;
|
|
83
58
|
|
|
84
59
|
const allInteractions = interactionsRepository.all();
|
|
85
60
|
const elementData = allInteractions.find( ( data ) => data.elementId === elementId );
|
|
86
61
|
const currentInteractions: ElementInteractions = elementData?.interactions ?? EMPTY_INTERACTIONS;
|
|
87
62
|
|
|
88
63
|
if ( action === 'get' ) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const animValue = value.animation.value;
|
|
92
|
-
const timingValue = animValue.timing_config.value;
|
|
93
|
-
const configValue = animValue.config.value;
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
id: extractString( value.interaction_id ),
|
|
97
|
-
trigger: extractString( value.trigger ),
|
|
98
|
-
effect: extractString( animValue.effect ),
|
|
99
|
-
effectType: extractString( animValue.type ),
|
|
100
|
-
direction: extractString( animValue.direction ),
|
|
101
|
-
duration: extractSize( timingValue.duration ),
|
|
102
|
-
delay: extractSize( timingValue.delay ),
|
|
103
|
-
easing: extractString( configValue.easing ),
|
|
104
|
-
excludedBreakpoints: extractExcludedBreakpoints( value.breakpoints ),
|
|
105
|
-
};
|
|
106
|
-
} );
|
|
107
|
-
|
|
108
|
-
return JSON.stringify( {
|
|
64
|
+
return {
|
|
65
|
+
success: true,
|
|
109
66
|
elementId,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
67
|
+
action,
|
|
68
|
+
interactions: currentInteractions.items,
|
|
69
|
+
count: currentInteractions.items.length,
|
|
70
|
+
};
|
|
113
71
|
}
|
|
114
72
|
|
|
115
73
|
let updatedItems = [ ...currentInteractions.items ];
|
|
@@ -124,15 +82,7 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
|
|
|
124
82
|
|
|
125
83
|
const newItem = createInteractionItem( {
|
|
126
84
|
interactionId: generateTempInteractionId(),
|
|
127
|
-
|
|
128
|
-
effect: effect ?? DEFAULT_VALUES.effect,
|
|
129
|
-
type: effectType ?? DEFAULT_VALUES.type,
|
|
130
|
-
direction: direction ?? DEFAULT_VALUES.direction,
|
|
131
|
-
duration: duration ?? DEFAULT_VALUES.duration,
|
|
132
|
-
delay: delay ?? DEFAULT_VALUES.delay,
|
|
133
|
-
replay: DEFAULT_VALUES.replay,
|
|
134
|
-
easing: easing ?? DEFAULT_VALUES.easing,
|
|
135
|
-
excludedBreakpoints,
|
|
85
|
+
...animationData,
|
|
136
86
|
} );
|
|
137
87
|
|
|
138
88
|
updatedItems = [ ...updatedItems, newItem ];
|
|
@@ -154,26 +104,9 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
|
|
|
154
104
|
);
|
|
155
105
|
}
|
|
156
106
|
|
|
157
|
-
const existingItem = updatedItems[ itemIndex ];
|
|
158
|
-
const existingValue = existingItem.value;
|
|
159
|
-
const existingAnimation = existingValue.animation.value;
|
|
160
|
-
const existingTiming = existingAnimation.timing_config.value;
|
|
161
|
-
const existingConfig = existingAnimation.config.value;
|
|
162
|
-
const existingExcludedBreakpoints = extractExcludedBreakpoints( existingValue.breakpoints );
|
|
163
|
-
|
|
164
107
|
const updatedItem = createInteractionItem( {
|
|
165
108
|
interactionId,
|
|
166
|
-
|
|
167
|
-
effect: effect ?? extractString( existingAnimation.effect ),
|
|
168
|
-
type: effectType ?? extractString( existingAnimation.type ),
|
|
169
|
-
direction: direction !== undefined ? direction : extractString( existingAnimation.direction ),
|
|
170
|
-
duration:
|
|
171
|
-
duration !== undefined ? duration : ( extractSize( existingTiming.duration ) as number ),
|
|
172
|
-
delay: delay !== undefined ? delay : ( extractSize( existingTiming.delay ) as number ),
|
|
173
|
-
replay: existingConfig.replay?.value ?? DEFAULT_VALUES.replay,
|
|
174
|
-
easing: easing ?? extractString( existingConfig.easing ),
|
|
175
|
-
excludedBreakpoints:
|
|
176
|
-
excludedBreakpoints !== undefined ? excludedBreakpoints : existingExcludedBreakpoints,
|
|
109
|
+
...animationData,
|
|
177
110
|
} );
|
|
178
111
|
|
|
179
112
|
updatedItems = [
|
|
@@ -223,12 +156,12 @@ Use excludedBreakpoints to disable the animation on specific responsive breakpoi
|
|
|
223
156
|
);
|
|
224
157
|
}
|
|
225
158
|
|
|
226
|
-
return
|
|
159
|
+
return {
|
|
227
160
|
success: true,
|
|
228
161
|
action,
|
|
229
162
|
elementId,
|
|
230
|
-
|
|
231
|
-
}
|
|
163
|
+
count: updatedItems.length,
|
|
164
|
+
};
|
|
232
165
|
},
|
|
233
166
|
} );
|
|
234
167
|
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from '@elementor/schema';
|
|
2
|
+
|
|
3
|
+
export const baseSchema = {
|
|
4
|
+
trigger: z.enum( [ 'load', 'scrollIn' ] ).optional().describe( 'Event that triggers the animation' ),
|
|
5
|
+
effect: z.enum( [ 'fade', 'slide', 'scale' ] ).optional().describe( 'Animation effect type' ),
|
|
6
|
+
effectType: z.enum( [ 'in', 'out' ] ).optional().describe( 'Whether the animation plays in or out' ),
|
|
7
|
+
direction: z
|
|
8
|
+
.enum( [ 'top', 'bottom', 'left', 'right', '' ] )
|
|
9
|
+
.optional()
|
|
10
|
+
.describe( 'Direction for slide effect. Use empty string for fade/scale.' ),
|
|
11
|
+
duration: z.number().min( 0 ).max( 10000 ).optional().describe( 'Animation duration in milliseconds' ),
|
|
12
|
+
delay: z.number().min( 0 ).max( 10000 ).optional().describe( 'Animation delay in milliseconds' ),
|
|
13
|
+
easing: z.string().optional().describe( 'Easing function. See interactions schema for options.' ),
|
|
14
|
+
excludedBreakpoints: z
|
|
15
|
+
.array( z.string() )
|
|
16
|
+
.optional()
|
|
17
|
+
.describe(
|
|
18
|
+
'Breakpoint IDs on which this interaction is disabled (e.g. ["mobile", "tablet"]). Omit to enable on all breakpoints.'
|
|
19
|
+
),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const proSchema = {
|
|
23
|
+
trigger: z
|
|
24
|
+
.enum( [ 'load', 'scrollIn', 'scrollOut', 'scrollOn', 'hover', 'click' ] )
|
|
25
|
+
.optional()
|
|
26
|
+
.describe( 'Event that triggers the animation' ),
|
|
27
|
+
effect: z.enum( [ 'fade', 'slide', 'scale', 'custom' ] ).optional().describe( 'Animation effect type' ),
|
|
28
|
+
customEffect: z
|
|
29
|
+
.object( {
|
|
30
|
+
keyframes: z
|
|
31
|
+
.array(
|
|
32
|
+
z.object( {
|
|
33
|
+
stop: z.number().describe( 'The stop of the keyframe in percent, can be either 0 or 100' ),
|
|
34
|
+
value: z.object( {
|
|
35
|
+
opacity: z.number().min( 0 ).max( 1 ).describe( 'The opacity of the keyframe' ),
|
|
36
|
+
scale: z
|
|
37
|
+
.object( {
|
|
38
|
+
x: z.number().min( 0 ).max( 1 ).describe( 'The x scale of the keyframe' ),
|
|
39
|
+
y: z.number().min( 0 ).max( 1 ).describe( 'The y scale of the keyframe' ),
|
|
40
|
+
} )
|
|
41
|
+
.optional()
|
|
42
|
+
.describe( 'The scale of the keyframe' ),
|
|
43
|
+
rotate: z
|
|
44
|
+
.object( {
|
|
45
|
+
x: z.number().min( 0 ).max( 360 ).describe( 'The x rotate of the keyframe' ),
|
|
46
|
+
y: z.number().min( 0 ).max( 360 ).describe( 'The y rotate of the keyframe' ),
|
|
47
|
+
z: z.number().min( 0 ).max( 360 ).describe( 'The z rotate of the keyframe' ),
|
|
48
|
+
} )
|
|
49
|
+
.optional()
|
|
50
|
+
.describe( 'The rotate of the keyframe' ),
|
|
51
|
+
move: z
|
|
52
|
+
.object( {
|
|
53
|
+
x: z.number().min( 0 ).max( 1 ).describe( 'The x move of the keyframe' ),
|
|
54
|
+
y: z.number().min( 0 ).max( 1 ).describe( 'The y move of the keyframe' ),
|
|
55
|
+
z: z.number().min( 0 ).max( 1 ).describe( 'The z move of the keyframe' ),
|
|
56
|
+
} )
|
|
57
|
+
.optional()
|
|
58
|
+
.describe( 'The move of the keyframe' ),
|
|
59
|
+
skew: z
|
|
60
|
+
.object( {
|
|
61
|
+
x: z.number().min( 0 ).max( 360 ).describe( 'The x skew of the keyframe' ),
|
|
62
|
+
y: z.number().min( 0 ).max( 360 ).describe( 'The y skew of the keyframe' ),
|
|
63
|
+
} )
|
|
64
|
+
.optional()
|
|
65
|
+
.describe( 'The skew of the keyframe' ),
|
|
66
|
+
} ),
|
|
67
|
+
} )
|
|
68
|
+
)
|
|
69
|
+
.describe( 'The keyframes of the custom effect' ),
|
|
70
|
+
} )
|
|
71
|
+
.optional()
|
|
72
|
+
.describe( 'The custom effect to use for the animation' ),
|
|
73
|
+
};
|
package/src/types.ts
CHANGED
|
@@ -26,11 +26,6 @@ export type {
|
|
|
26
26
|
InteractionBreakpointsPropValue,
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export type AnimationOption = {
|
|
30
|
-
value: string;
|
|
31
|
-
label: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
29
|
export type InteractionConstants = {
|
|
35
30
|
defaultDuration: number;
|
|
36
31
|
defaultDelay: number;
|
|
@@ -41,7 +36,6 @@ export type InteractionConstants = {
|
|
|
41
36
|
|
|
42
37
|
export type InteractionsConfig = {
|
|
43
38
|
constants: InteractionConstants;
|
|
44
|
-
animationOptions: AnimationOption[];
|
|
45
39
|
};
|
|
46
40
|
|
|
47
41
|
export type FieldProps< T = string > = {
|
|
@@ -151,14 +151,14 @@ export const createInteractionItem = ( {
|
|
|
151
151
|
excludedBreakpoints,
|
|
152
152
|
customEffects,
|
|
153
153
|
}: {
|
|
154
|
-
trigger
|
|
155
|
-
effect
|
|
156
|
-
type
|
|
154
|
+
trigger?: string;
|
|
155
|
+
effect?: string;
|
|
156
|
+
type?: string;
|
|
157
157
|
direction?: string;
|
|
158
|
-
duration
|
|
159
|
-
delay
|
|
158
|
+
duration?: SizeStringValue;
|
|
159
|
+
delay?: SizeStringValue;
|
|
160
160
|
interactionId?: string;
|
|
161
|
-
replay
|
|
161
|
+
replay?: boolean;
|
|
162
162
|
easing?: string;
|
|
163
163
|
relativeTo?: string;
|
|
164
164
|
offsetTop?: number;
|
|
@@ -169,13 +169,13 @@ export const createInteractionItem = ( {
|
|
|
169
169
|
$$type: 'interaction-item',
|
|
170
170
|
value: {
|
|
171
171
|
...( interactionId && { interaction_id: createString( interactionId ) } ),
|
|
172
|
-
trigger: createString( trigger ),
|
|
172
|
+
trigger: createString( trigger ?? '' ),
|
|
173
173
|
animation: createAnimationPreset( {
|
|
174
|
-
effect,
|
|
175
|
-
type,
|
|
174
|
+
effect: effect ?? '',
|
|
175
|
+
type: type ?? '',
|
|
176
176
|
direction,
|
|
177
|
-
duration,
|
|
178
|
-
delay,
|
|
177
|
+
duration: duration ?? 0,
|
|
178
|
+
delay: delay ?? 0,
|
|
179
179
|
replay,
|
|
180
180
|
easing,
|
|
181
181
|
relativeTo,
|