@elementor/editor-responsive 0.10.4 → 0.10.6

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.
@@ -5,7 +5,7 @@ import { __createStore, __dispatch, __registerSlice, SliceState, Store } from '@
5
5
  import { selectActiveBreakpoint, selectEntities } from '../../store/selectors';
6
6
 
7
7
  describe( '@elementor/editor-responsive - Sync Store', () => {
8
- let store: Store<SliceState<typeof slice>>;
8
+ let store: Store< SliceState< typeof slice > >;
9
9
  let extendedWindow: ExtendedWindow;
10
10
 
11
11
  beforeEach( () => {
@@ -14,7 +14,7 @@ describe( '@elementor/editor-responsive - Sync Store', () => {
14
14
 
15
15
  syncStore();
16
16
 
17
- extendedWindow = ( window as unknown as ExtendedWindow );
17
+ extendedWindow = window as unknown as ExtendedWindow;
18
18
  } );
19
19
 
20
20
  it( 'should initialize the store when V1 is ready', () => {
@@ -58,13 +58,15 @@ describe( '@elementor/editor-responsive - Sync Store', () => {
58
58
  // Arrange.
59
59
  mockV1BreakpointsConfig();
60
60
 
61
- __dispatch( slice.actions.init( {
62
- entities: [
63
- { id: 'desktop', label: 'Desktop' },
64
- { id: 'mobile', label: 'Mobile Portrait', width: 767, type: 'max-width' },
65
- ],
66
- activeId: 'mobile',
67
- } ) );
61
+ __dispatch(
62
+ slice.actions.init( {
63
+ entities: [
64
+ { id: 'desktop', label: 'Desktop' },
65
+ { id: 'mobile', label: 'Mobile Portrait', width: 767, type: 'max-width' },
66
+ ],
67
+ activeId: 'mobile',
68
+ } )
69
+ );
68
70
 
69
71
  // Act - Mock a change.
70
72
  jest.mocked( extendedWindow.elementor.channels.deviceMode.request ).mockReturnValue( 'desktop' );
@@ -78,13 +80,15 @@ describe( '@elementor/editor-responsive - Sync Store', () => {
78
80
  // Arrange.
79
81
  mockV1BreakpointsConfig();
80
82
 
81
- __dispatch( slice.actions.init( {
82
- entities: [
83
- { id: 'desktop', label: 'Desktop' },
84
- { id: 'mobile', label: 'Mobile Portrait', width: 767, type: 'max-width' },
85
- ],
86
- activeId: 'desktop',
87
- } ) );
83
+ __dispatch(
84
+ slice.actions.init( {
85
+ entities: [
86
+ { id: 'desktop', label: 'Desktop' },
87
+ { id: 'mobile', label: 'Mobile Portrait', width: 767, type: 'max-width' },
88
+ ],
89
+ activeId: 'desktop',
90
+ } )
91
+ );
88
92
 
89
93
  // Act - Mock a change.
90
94
  jest.mocked( extendedWindow.elementor.channels.deviceMode.request ).mockReturnValue( '' as BreakpointId );
@@ -12,28 +12,24 @@ export default function syncStore() {
12
12
  function syncInitialization() {
13
13
  const { init } = slice.actions;
14
14
 
15
- listenTo(
16
- v1ReadyEvent(),
17
- () => {
18
- __dispatch( init( {
15
+ listenTo( v1ReadyEvent(), () => {
16
+ __dispatch(
17
+ init( {
19
18
  entities: getBreakpoints(),
20
19
  activeId: getActiveBreakpoint(),
21
- } ) );
22
- }
23
- );
20
+ } )
21
+ );
22
+ } );
24
23
  }
25
24
 
26
25
  function syncOnChange() {
27
26
  const { activateBreakpoint } = slice.actions;
28
27
 
29
- listenTo(
30
- deviceModeChangeEvent(),
31
- () => {
32
- const activeBreakpoint = getActiveBreakpoint();
28
+ listenTo( deviceModeChangeEvent(), () => {
29
+ const activeBreakpoint = getActiveBreakpoint();
33
30
 
34
- __dispatch( activateBreakpoint( activeBreakpoint ) );
35
- },
36
- );
31
+ __dispatch( activateBreakpoint( activeBreakpoint ) );
32
+ } );
37
33
  }
38
34
 
39
35
  function getBreakpoints() {
@@ -43,8 +39,7 @@ function getBreakpoints() {
43
39
  return [];
44
40
  }
45
41
 
46
- const entities = Object
47
- .entries( breakpoints )
42
+ const entities = Object.entries( breakpoints )
48
43
  .filter( ( [ , breakpoint ] ) => breakpoint.is_enabled )
49
44
  .map( ( [ id, { value, direction, label } ] ) => {
50
45
  return {
package/src/types.ts CHANGED
@@ -5,40 +5,43 @@ export type BreakpointSize = number;
5
5
  export type BreakpointLabel = string;
6
6
 
7
7
  export type Breakpoint = {
8
- id: BreakpointId,
9
- label: BreakpointLabel,
10
- width?: BreakpointSize,
11
- type?: 'min-width' | 'max-width',
12
- }
8
+ id: BreakpointId;
9
+ label: BreakpointLabel;
10
+ width?: BreakpointSize;
11
+ type?: 'min-width' | 'max-width';
12
+ };
13
13
 
14
14
  export type ExtendedWindow = Window & {
15
15
  elementor: {
16
16
  config: {
17
17
  responsive: {
18
- breakpoints: Record<Exclude<BreakpointId, 'desktop'>, {
19
- direction: 'min' | 'max',
20
- is_enabled: boolean,
21
- value: BreakpointSize,
22
- label: BreakpointLabel,
23
- }>
24
- }
25
- },
18
+ breakpoints: Record<
19
+ Exclude< BreakpointId, 'desktop' >,
20
+ {
21
+ direction: 'min' | 'max';
22
+ is_enabled: boolean;
23
+ value: BreakpointSize;
24
+ label: BreakpointLabel;
25
+ }
26
+ >;
27
+ };
28
+ };
26
29
  channels: {
27
30
  deviceMode: {
28
- request: ( request: 'currentMode' ) => BreakpointId,
29
- }
30
- },
31
+ request: ( request: 'currentMode' ) => BreakpointId;
32
+ };
33
+ };
31
34
  editorEvents: {
32
- dispatchEvent: ( name: string, data: Record<string, string> ) => void
35
+ dispatchEvent: ( name: string, data: Record< string, string > ) => void;
33
36
  config: {
34
- locations: Record<string, string>,
35
- secondaryLocations: Record<string, string>,
36
- triggers: Record<string, string>,
37
- elements: Record<string, string>
37
+ locations: Record< string, string >;
38
+ secondaryLocations: Record< string, string >;
39
+ triggers: Record< string, string >;
40
+ elements: Record< string, string >;
38
41
  names: {
39
- topBar: Record<string, string>
40
- }
41
- }
42
- }
43
- }
44
- }
42
+ topBar: Record< string, string >;
43
+ };
44
+ };
45
+ };
46
+ };
47
+ };