@elementor/editor-interactions 4.0.0-660 → 4.0.0-662

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-660",
3
+ "version": "4.0.0-662",
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-660",
43
- "@elementor/editor-elements": "4.0.0-660",
44
- "@elementor/editor-mcp": "4.0.0-660",
45
- "@elementor/editor-props": "4.0.0-660",
46
- "@elementor/editor-responsive": "4.0.0-660",
47
- "@elementor/editor-ui": "4.0.0-660",
48
- "@elementor/editor-v1-adapters": "4.0.0-660",
42
+ "@elementor/editor-controls": "4.0.0-662",
43
+ "@elementor/editor-elements": "4.0.0-662",
44
+ "@elementor/editor-mcp": "4.0.0-662",
45
+ "@elementor/editor-props": "4.0.0-662",
46
+ "@elementor/editor-responsive": "4.0.0-662",
47
+ "@elementor/editor-ui": "4.0.0-662",
48
+ "@elementor/editor-v1-adapters": "4.0.0-662",
49
49
  "@elementor/icons": "^1.68.0",
50
- "@elementor/schema": "4.0.0-660",
51
- "@elementor/session": "4.0.0-660",
50
+ "@elementor/schema": "4.0.0-662",
51
+ "@elementor/session": "4.0.0-662",
52
52
  "@elementor/ui": "1.36.17",
53
- "@elementor/utils": "4.0.0-660",
53
+ "@elementor/utils": "4.0.0-662",
54
54
  "@wordpress/i18n": "^5.13.0"
55
55
  },
56
56
  "peerDependencies": {
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { useCallback, useState } from 'react';
3
- import { useElementInteractions } from '@elementor/editor-elements';
4
3
  import { SessionStorageProvider } from '@elementor/session';
5
4
  import { Stack } from '@elementor/ui';
6
5
 
7
6
  import { InteractionsProvider, useInteractionsContext } from '../contexts/interactions-context';
8
7
  import { PopupStateProvider } from '../contexts/popup-state-context';
8
+ import { useElementInteractions } from '../hooks/use-element-interactions';
9
9
  import type { ElementInteractions } from '../types';
10
10
  import { EmptyState } from './empty-state';
11
11
  import { InteractionsList } from './interactions-list';
@@ -4,9 +4,10 @@ import {
4
4
  type ElementInteractions,
5
5
  playElementInteractions,
6
6
  updateElementInteractions,
7
- useElementInteractions,
8
7
  } from '@elementor/editor-elements';
9
8
 
9
+ import { useElementInteractions } from '../hooks/use-element-interactions';
10
+
10
11
  type InteractionsContextValue = {
11
12
  interactions: ElementInteractions;
12
13
  setInteractions: ( value: ElementInteractions | undefined ) => void;
@@ -0,0 +1,22 @@
1
+ import { useState } from 'react';
2
+ import { type ElementID, type ElementInteractions, getElementInteractions } from '@elementor/editor-elements';
3
+ import { __privateUseListenTo as useListenTo, windowEvent } from '@elementor/editor-v1-adapters';
4
+
5
+ export const useElementInteractions = ( elementId: ElementID ) => {
6
+ const [ interactions, setInteractions ] = useState< ElementInteractions >( () => {
7
+ const initial = getElementInteractions( elementId );
8
+
9
+ return initial ?? { version: 1, items: [] };
10
+ } );
11
+
12
+ useListenTo(
13
+ windowEvent( 'elementor/element/update_interactions' ),
14
+ () => {
15
+ const newInteractions = getElementInteractions( elementId );
16
+ setInteractions( newInteractions ?? { version: 1, items: [] } );
17
+ },
18
+ [ elementId ]
19
+ );
20
+
21
+ return interactions;
22
+ };
package/src/index.ts CHANGED
@@ -40,3 +40,4 @@ export { generateTempInteractionId, isTempId } from './utils/temp-id-utils';
40
40
  export { resolveDirection } from './utils/resolve-direction';
41
41
  export { convertTimeUnit } from './utils/time-conversion';
42
42
  export { parseSizeValue, formatSizeValue } from './utils/size-transform-utils';
43
+ export { useElementInteractions } from './hooks/use-element-interactions';