@elementor/editor-responsive 0.10.6 → 0.11.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.
@@ -1,70 +0,0 @@
1
- import { slice } from '../store';
2
- import { __dispatch } from '@elementor/store';
3
- import { Breakpoint, ExtendedWindow } from '../types';
4
- import { __privateListenTo as listenTo, v1ReadyEvent, windowEvent } from '@elementor/editor-v1-adapters';
5
- import { __ } from '@wordpress/i18n';
6
-
7
- export default function syncStore() {
8
- syncInitialization();
9
- syncOnChange();
10
- }
11
-
12
- function syncInitialization() {
13
- const { init } = slice.actions;
14
-
15
- listenTo( v1ReadyEvent(), () => {
16
- __dispatch(
17
- init( {
18
- entities: getBreakpoints(),
19
- activeId: getActiveBreakpoint(),
20
- } )
21
- );
22
- } );
23
- }
24
-
25
- function syncOnChange() {
26
- const { activateBreakpoint } = slice.actions;
27
-
28
- listenTo( deviceModeChangeEvent(), () => {
29
- const activeBreakpoint = getActiveBreakpoint();
30
-
31
- __dispatch( activateBreakpoint( activeBreakpoint ) );
32
- } );
33
- }
34
-
35
- function getBreakpoints() {
36
- const { breakpoints } = ( window as unknown as ExtendedWindow ).elementor?.config?.responsive || {};
37
-
38
- if ( ! breakpoints ) {
39
- return [];
40
- }
41
-
42
- const entities = Object.entries( breakpoints )
43
- .filter( ( [ , breakpoint ] ) => breakpoint.is_enabled )
44
- .map( ( [ id, { value, direction, label } ] ) => {
45
- return {
46
- id,
47
- label,
48
- width: value,
49
- type: direction === 'min' ? 'min-width' : 'max-width',
50
- } as Breakpoint;
51
- } );
52
-
53
- // Desktop breakpoint is not included in V1 config.
54
- entities.push( {
55
- id: 'desktop',
56
- label: __( 'Desktop', 'elementor' ),
57
- } );
58
-
59
- return entities;
60
- }
61
-
62
- function getActiveBreakpoint() {
63
- const extendedWindow = window as unknown as ExtendedWindow;
64
-
65
- return extendedWindow.elementor?.channels?.deviceMode?.request?.( 'currentMode' ) || null;
66
- }
67
-
68
- function deviceModeChangeEvent() {
69
- return windowEvent( 'elementor/device-mode/change' );
70
- }