@elementor/editor-global-classes 3.32.0-39 → 3.32.0-41

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-global-classes",
3
- "version": "3.32.0-39",
3
+ "version": "3.32.0-41",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,22 +39,22 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "3.32.0-39",
43
- "@elementor/editor-current-user": "3.32.0-39",
44
- "@elementor/editor-documents": "3.32.0-39",
45
- "@elementor/editor-editing-panel": "3.32.0-39",
46
- "@elementor/editor-panels": "3.32.0-39",
47
- "@elementor/editor-props": "3.32.0-39",
48
- "@elementor/editor-styles": "3.32.0-39",
49
- "@elementor/editor-styles-repository": "3.32.0-39",
50
- "@elementor/editor-ui": "3.32.0-39",
51
- "@elementor/editor-v1-adapters": "3.32.0-39",
52
- "@elementor/http-client": "3.32.0-39",
42
+ "@elementor/editor": "3.32.0-41",
43
+ "@elementor/editor-current-user": "3.32.0-41",
44
+ "@elementor/editor-documents": "3.32.0-41",
45
+ "@elementor/editor-editing-panel": "3.32.0-41",
46
+ "@elementor/editor-panels": "3.32.0-41",
47
+ "@elementor/editor-props": "3.32.0-41",
48
+ "@elementor/editor-styles": "3.32.0-41",
49
+ "@elementor/editor-styles-repository": "3.32.0-41",
50
+ "@elementor/editor-ui": "3.32.0-41",
51
+ "@elementor/editor-v1-adapters": "3.32.0-41",
52
+ "@elementor/http-client": "3.32.0-41",
53
53
  "@elementor/icons": "1.46.0",
54
- "@elementor/query": "3.32.0-39",
55
- "@elementor/store": "3.32.0-39",
54
+ "@elementor/query": "3.32.0-41",
55
+ "@elementor/store": "3.32.0-41",
56
56
  "@elementor/ui": "1.36.8",
57
- "@elementor/utils": "3.32.0-39",
57
+ "@elementor/utils": "3.32.0-41",
58
58
  "@wordpress/i18n": "^5.13.0"
59
59
  },
60
60
  "peerDependencies": {
@@ -1,4 +1,4 @@
1
- import { generateId, type StyleDefinitionVariant } from '@elementor/editor-styles';
1
+ import { generateId, type StyleDefinition, type StyleDefinitionVariant } from '@elementor/editor-styles';
2
2
  import { createStylesProvider } from '@elementor/editor-styles-repository';
3
3
  import {
4
4
  __dispatch as dispatch,
@@ -9,7 +9,14 @@ import { __ } from '@wordpress/i18n';
9
9
 
10
10
  import { getCapabilities } from './capabilities';
11
11
  import { GlobalClassLabelAlreadyExistsError } from './errors';
12
- import { selectClass, selectGlobalClasses, selectOrderedClasses, slice, type StateWithGlobalClasses } from './store';
12
+ import {
13
+ selectClass,
14
+ selectData,
15
+ selectGlobalClasses,
16
+ selectOrderedClasses,
17
+ slice,
18
+ type StateWithGlobalClasses,
19
+ } from './store';
13
20
 
14
21
  const MAX_CLASSES = 50;
15
22
 
@@ -23,7 +30,7 @@ export const globalClassesStylesProvider = createStylesProvider( {
23
30
  singular: __( 'class', 'elementor' ),
24
31
  plural: __( 'classes', 'elementor' ),
25
32
  },
26
- subscribe: ( cb ) => subscribeWithSelector( ( state: StateWithGlobalClasses ) => state.globalClasses, cb ),
33
+ subscribe: ( cb ) => subscribeWithStates( cb ),
27
34
  capabilities: getCapabilities(),
28
35
  actions: {
29
36
  all: () => selectOrderedClasses( getState() ),
@@ -85,3 +92,17 @@ export const globalClassesStylesProvider = createStylesProvider( {
85
92
  },
86
93
  },
87
94
  } );
95
+
96
+ const subscribeWithStates = (
97
+ cb: ( previous: Record< string, StyleDefinition >, current: Record< string, StyleDefinition > ) => void
98
+ ) => {
99
+ let previousState = selectData( getState() );
100
+
101
+ return subscribeWithSelector(
102
+ ( state: StateWithGlobalClasses ) => state.globalClasses,
103
+ ( currentState ) => {
104
+ cb( previousState.items, currentState.data.items );
105
+ previousState = currentState.data;
106
+ }
107
+ );
108
+ };
@@ -1,4 +1,5 @@
1
1
  import { __dispatch as dispatch, __getState as getState } from '@elementor/store';
2
+ import { hash } from '@elementor/utils';
2
3
 
3
4
  import { apiClient, type ApiContext } from './api';
4
5
  import { type GlobalClasses, selectData, selectFrontendInitialData, selectPreviewInitialData, slice } from './store';
@@ -39,25 +40,3 @@ function calculateChanges( state: GlobalClasses, initialData: GlobalClasses ) {
39
40
  } ),
40
41
  };
41
42
  }
42
-
43
- type UnknownObject = Record< string, unknown >;
44
-
45
- // Inspired by:
46
- // https://github.com/TanStack/query/blob/66ea5f2fc/packages/query-core/src/utils.ts#L212
47
- function hash( obj: UnknownObject ): string {
48
- return JSON.stringify( obj, ( _, value ) =>
49
- isPlainObject( value )
50
- ? Object.keys( value )
51
- .sort()
52
- .reduce< UnknownObject >( ( result, key ) => {
53
- result[ key ] = value[ key ];
54
-
55
- return result;
56
- }, {} )
57
- : value
58
- );
59
- }
60
-
61
- function isPlainObject( value: unknown ): value is UnknownObject {
62
- return !! value && typeof value === 'object' && ! Array.isArray( value );
63
- }