@elementor/editor-interactions 4.0.0-679 → 4.0.0-680

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-interactions",
3
- "version": "4.0.0-679",
3
+ "version": "4.0.0-680",
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.0.0-679",
43
- "@elementor/editor-elements": "4.0.0-679",
44
- "@elementor/editor-mcp": "4.0.0-679",
45
- "@elementor/editor-props": "4.0.0-679",
46
- "@elementor/editor-responsive": "4.0.0-679",
47
- "@elementor/editor-ui": "4.0.0-679",
48
- "@elementor/editor-v1-adapters": "4.0.0-679",
42
+ "@elementor/editor-controls": "4.0.0-680",
43
+ "@elementor/editor-elements": "4.0.0-680",
44
+ "@elementor/editor-mcp": "4.0.0-680",
45
+ "@elementor/editor-props": "4.0.0-680",
46
+ "@elementor/editor-responsive": "4.0.0-680",
47
+ "@elementor/editor-ui": "4.0.0-680",
48
+ "@elementor/editor-v1-adapters": "4.0.0-680",
49
49
  "@elementor/icons": "^1.68.0",
50
- "@elementor/schema": "4.0.0-679",
51
- "@elementor/session": "4.0.0-679",
50
+ "@elementor/schema": "4.0.0-680",
51
+ "@elementor/session": "4.0.0-680",
52
52
  "@elementor/ui": "1.36.17",
53
- "@elementor/utils": "4.0.0-679",
54
- "@elementor/events": "4.0.0-679",
53
+ "@elementor/utils": "4.0.0-680",
54
+ "@elementor/events": "4.0.0-680",
55
55
  "@wordpress/i18n": "^5.13.0"
56
56
  },
57
57
  "peerDependencies": {
@@ -2,18 +2,22 @@ import { useState } from 'react';
2
2
  import { type ElementID, type ElementInteractions, getElementInteractions } from '@elementor/editor-elements';
3
3
  import { __privateUseListenTo as useListenTo, windowEvent } from '@elementor/editor-v1-adapters';
4
4
 
5
+ import { filterInteractions } from '../utils/filter-interactions';
6
+
5
7
  export const useElementInteractions = ( elementId: ElementID ) => {
6
8
  const [ interactions, setInteractions ] = useState< ElementInteractions >( () => {
7
9
  const initial = getElementInteractions( elementId );
10
+ const filteredInteractions = filterInteractions( initial?.items ?? [] );
8
11
 
9
- return initial ?? { version: 1, items: [] };
12
+ return { version: initial?.version ?? 1, items: filteredInteractions };
10
13
  } );
11
14
 
12
15
  useListenTo(
13
16
  windowEvent( 'elementor/element/update_interactions' ),
14
17
  () => {
15
18
  const newInteractions = getElementInteractions( elementId );
16
- setInteractions( newInteractions ?? { version: 1, items: [] } );
19
+ const filteredInteractions = filterInteractions( newInteractions?.items ?? [] );
20
+ setInteractions( { version: newInteractions?.version ?? 1, items: filteredInteractions } );
17
21
  },
18
22
  [ elementId ]
19
23
  );
package/src/init.ts CHANGED
@@ -33,7 +33,7 @@ export function init() {
33
33
  registerInteractionsControl( {
34
34
  type: 'replay',
35
35
  component: Replay,
36
- options: [ 'true', 'false' ],
36
+ options: [ 'no' ],
37
37
  } );
38
38
 
39
39
  registerInteractionsControl( {
@@ -9,7 +9,7 @@ import {
9
9
  type TimesFieldProps,
10
10
  } from './types';
11
11
 
12
- type InteractionsControlType =
12
+ export type InteractionsControlType =
13
13
  | 'trigger'
14
14
  | 'effect'
15
15
  | 'effectType'
@@ -0,0 +1,9 @@
1
+ import { type InteractionItemPropValue } from '@elementor/editor-elements';
2
+
3
+ import { isSupportedInteractionItem } from './is-supported-interaction-item';
4
+
5
+ export const filterInteractions = ( interactions: InteractionItemPropValue[] ) => {
6
+ return interactions.filter( ( interaction ) => {
7
+ return isSupportedInteractionItem( interaction );
8
+ } );
9
+ };
@@ -0,0 +1,39 @@
1
+ import { getInteractionsControlOptions, type InteractionsControlType } from '../interactions-controls-registry';
2
+ import { type InteractionItemPropValue } from '../types';
3
+ import { extractBoolean, extractString } from '../utils/prop-value-utils';
4
+
5
+ export function isSupportedInteractionItem( interaction: InteractionItemPropValue ): boolean {
6
+ const value = interaction.value;
7
+
8
+ const replay = extractBoolean( value.animation.value.config?.value.replay );
9
+ if ( true === replay ) {
10
+ return hasSupport( 'replay', 'yes' );
11
+ }
12
+
13
+ const trigger = extractString( value.trigger );
14
+ const easing = extractString( value.animation.value.config?.value.easing );
15
+ const effect = extractString( value.animation.value.effect );
16
+
17
+ const checks: Array< [ string, string ] > = [
18
+ [ 'trigger', trigger ],
19
+ [ 'easing', easing ],
20
+ [ 'effect', effect ],
21
+ ];
22
+
23
+ return checks.every( ( [ controlType, controlValue ] ) => {
24
+ if ( controlValue === '' || controlValue === null ) {
25
+ return true;
26
+ }
27
+ return hasSupport( controlType, controlValue );
28
+ } );
29
+ }
30
+
31
+ function hasSupport( controlType: string, controlValue: string ) {
32
+ const supportedOptions = getInteractionsControlOptions( controlType as InteractionsControlType );
33
+
34
+ if ( 1 > supportedOptions.length ) {
35
+ return true;
36
+ }
37
+
38
+ return supportedOptions.includes( controlValue );
39
+ }