@elementor/editor-controls 4.1.0-760 → 4.1.0-761

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-controls",
3
3
  "description": "This package contains the controls model and utils for the Elementor editor",
4
- "version": "4.1.0-760",
4
+ "version": "4.1.0-761",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,22 +40,22 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor-current-user": "4.1.0-760",
44
- "@elementor/editor-elements": "4.1.0-760",
45
- "@elementor/editor-props": "4.1.0-760",
46
- "@elementor/editor-responsive": "4.1.0-760",
47
- "@elementor/editor-ui": "4.1.0-760",
48
- "@elementor/editor-v1-adapters": "4.1.0-760",
49
- "@elementor/env": "4.1.0-760",
50
- "@elementor/http-client": "4.1.0-760",
43
+ "@elementor/editor-current-user": "4.1.0-761",
44
+ "@elementor/editor-elements": "4.1.0-761",
45
+ "@elementor/editor-props": "4.1.0-761",
46
+ "@elementor/editor-responsive": "4.1.0-761",
47
+ "@elementor/editor-ui": "4.1.0-761",
48
+ "@elementor/editor-v1-adapters": "4.1.0-761",
49
+ "@elementor/env": "4.1.0-761",
50
+ "@elementor/http-client": "4.1.0-761",
51
51
  "@elementor/icons": "^1.68.0",
52
- "@elementor/locations": "4.1.0-760",
53
- "@elementor/events": "4.1.0-760",
54
- "@elementor/query": "4.1.0-760",
55
- "@elementor/session": "4.1.0-760",
52
+ "@elementor/locations": "4.1.0-761",
53
+ "@elementor/events": "4.1.0-761",
54
+ "@elementor/query": "4.1.0-761",
55
+ "@elementor/session": "4.1.0-761",
56
56
  "@elementor/ui": "1.36.17",
57
- "@elementor/utils": "4.1.0-760",
58
- "@elementor/wp-media": "4.1.0-760",
57
+ "@elementor/utils": "4.1.0-761",
58
+ "@elementor/wp-media": "4.1.0-761",
59
59
  "@wordpress/i18n": "^5.13.0",
60
60
  "@monaco-editor/react": "^4.7.0",
61
61
  "dayjs": "^1.11.18",
@@ -1,11 +1,15 @@
1
1
  import { useEffect, useState } from 'react';
2
2
 
3
+ import { EXTENDED_UNITS } from '../utils/resolve-size-value';
4
+
3
5
  type UseUnitSyncProps< U > = {
4
6
  unit: U;
5
7
  setUnit: ( unit: U ) => void;
6
8
  persistWhen: () => boolean;
7
9
  };
8
10
 
11
+ type ExtendedUnit = ( typeof EXTENDED_UNITS )[ keyof typeof EXTENDED_UNITS ];
12
+
9
13
  export const useUnitSync = < U >( { unit, setUnit, persistWhen }: UseUnitSyncProps< U > ) => {
10
14
  const [ state, setState ] = useState( unit );
11
15
 
@@ -16,10 +20,14 @@ export const useUnitSync = < U >( { unit, setUnit, persistWhen }: UseUnitSyncPro
16
20
  // eslint-disable-next-line react-hooks/exhaustive-deps
17
21
  }, [ unit ] );
18
22
 
23
+ const isExtendedUnit = ( value: U ): value is ExtendedUnit & U => {
24
+ return Object.values( EXTENDED_UNITS ).includes( value as ExtendedUnit );
25
+ };
26
+
19
27
  const setInternalValue = ( newUnit: U ) => {
20
28
  setState( newUnit );
21
29
 
22
- if ( persistWhen() ) {
30
+ if ( isExtendedUnit( newUnit ) || persistWhen() ) {
23
31
  setUnit( newUnit );
24
32
  }
25
33
  };
@@ -19,10 +19,11 @@ export const resolveBoundPropValue = < T extends SizeValue >(
19
19
  ] );
20
20
 
21
21
  const placeholderSource = propPlaceholder ?? boundPropPlaceholder;
22
+ const hasValue = Boolean( value );
22
23
 
23
24
  return {
24
25
  sizeValue,
25
- placeholder: resolvePlaceholder( placeholderSource ),
26
+ placeholder: hasValue ? undefined : resolvePlaceholder( placeholderSource ),
26
27
  };
27
28
  };
28
29