@elementor/editor-controls 4.1.0-751 → 4.1.0-753

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-751",
4
+ "version": "4.1.0-753",
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-751",
44
- "@elementor/editor-elements": "4.1.0-751",
45
- "@elementor/editor-props": "4.1.0-751",
46
- "@elementor/editor-responsive": "4.1.0-751",
47
- "@elementor/editor-ui": "4.1.0-751",
48
- "@elementor/editor-v1-adapters": "4.1.0-751",
49
- "@elementor/env": "4.1.0-751",
50
- "@elementor/http-client": "4.1.0-751",
43
+ "@elementor/editor-current-user": "4.1.0-753",
44
+ "@elementor/editor-elements": "4.1.0-753",
45
+ "@elementor/editor-props": "4.1.0-753",
46
+ "@elementor/editor-responsive": "4.1.0-753",
47
+ "@elementor/editor-ui": "4.1.0-753",
48
+ "@elementor/editor-v1-adapters": "4.1.0-753",
49
+ "@elementor/env": "4.1.0-753",
50
+ "@elementor/http-client": "4.1.0-753",
51
51
  "@elementor/icons": "^1.68.0",
52
- "@elementor/locations": "4.1.0-751",
53
- "@elementor/events": "4.1.0-751",
54
- "@elementor/query": "4.1.0-751",
55
- "@elementor/session": "4.1.0-751",
52
+ "@elementor/locations": "4.1.0-753",
53
+ "@elementor/events": "4.1.0-753",
54
+ "@elementor/query": "4.1.0-753",
55
+ "@elementor/session": "4.1.0-753",
56
56
  "@elementor/ui": "1.36.17",
57
- "@elementor/utils": "4.1.0-751",
58
- "@elementor/wp-media": "4.1.0-751",
57
+ "@elementor/utils": "4.1.0-753",
58
+ "@elementor/wp-media": "4.1.0-753",
59
59
  "@wordpress/i18n": "^5.13.0",
60
60
  "@monaco-editor/react": "^4.7.0",
61
61
  "dayjs": "^1.11.18",
@@ -23,6 +23,7 @@ type PropContext< T extends PropValue, P extends PropType > = {
23
23
  value: T | null;
24
24
  propType: P;
25
25
  placeholder?: T;
26
+ baseValue?: T;
26
27
  isDisabled?: ( propType: PropType ) => boolean | undefined;
27
28
  };
28
29
 
@@ -38,6 +39,7 @@ export const PropProvider = < T extends PropValue, P extends PropType >( {
38
39
  setValue,
39
40
  propType,
40
41
  placeholder,
42
+ baseValue,
41
43
  isDisabled,
42
44
  }: PropProviderProps< T, P > ) => {
43
45
  return (
@@ -47,6 +49,7 @@ export const PropProvider = < T extends PropValue, P extends PropType >( {
47
49
  propType,
48
50
  setValue: setValue as SetValue< PropValue >,
49
51
  placeholder,
52
+ baseValue,
50
53
  isDisabled,
51
54
  } }
52
55
  >
@@ -20,6 +20,7 @@ export type PropKeyContextValue< T, P > = {
20
20
  value: T;
21
21
  propType: P;
22
22
  placeholder?: T;
23
+ baseValue?: T;
23
24
  path: PropKey[];
24
25
  isDisabled?: ( propType: PropType ) => boolean | undefined;
25
26
  disabled?: boolean;
@@ -55,7 +56,7 @@ const ObjectPropKeyProvider = ( { children, bind }: PropKeyProviderProps ) => {
55
56
 
56
57
  const setValue: SetValue< PropValue > = ( value, options, meta ) => {
57
58
  const newValue = {
58
- ...context.value,
59
+ ...( context.value ?? context.baseValue ),
59
60
  [ bind ]: value,
60
61
  };
61
62
 
@@ -64,12 +65,22 @@ const ObjectPropKeyProvider = ( { children, bind }: PropKeyProviderProps ) => {
64
65
 
65
66
  const value = context.value?.[ bind ];
66
67
  const placeholder = context.placeholder?.[ bind ];
68
+ const baseValue = context.baseValue?.[ bind ];
67
69
 
68
70
  const propType = context.propType.shape[ bind ];
69
71
 
70
72
  return (
71
73
  <PropKeyContext.Provider
72
- value={ { ...context, value, setValue, placeholder, bind, propType, path: [ ...( path ?? [] ), bind ] } }
74
+ value={ {
75
+ ...context,
76
+ value,
77
+ setValue,
78
+ placeholder,
79
+ baseValue,
80
+ bind,
81
+ propType,
82
+ path: [ ...( path ?? [] ), bind ],
83
+ } }
73
84
  >
74
85
  { children }
75
86
  </PropKeyContext.Provider>
@@ -81,7 +92,7 @@ const ArrayPropKeyProvider = ( { children, bind }: PropKeyProviderProps ) => {
81
92
  const { path } = useContext( PropKeyContext ) ?? {};
82
93
 
83
94
  const setValue = ( value: PropValue, options?: CreateOptions ) => {
84
- const newValue = [ ...( context.value ?? [] ) ];
95
+ const newValue = [ ...( context.value ?? context.baseValue ?? [] ) ];
85
96
 
86
97
  newValue[ Number( bind ) ] = value;
87
98
 
@@ -90,6 +101,7 @@ const ArrayPropKeyProvider = ( { children, bind }: PropKeyProviderProps ) => {
90
101
 
91
102
  const value = context.value?.[ Number( bind ) ];
92
103
  const placeholder = context.placeholder?.[ Number( bind ) ];
104
+ const baseValue = context.baseValue?.[ Number( bind ) ];
93
105
 
94
106
  const propType = context.propType.item_prop_type;
95
107
 
@@ -103,6 +115,7 @@ const ArrayPropKeyProvider = ( { children, bind }: PropKeyProviderProps ) => {
103
115
  propType,
104
116
  path: [ ...( path ?? [] ), bind ],
105
117
  placeholder: placeholder ?? undefined,
118
+ baseValue: baseValue ?? undefined,
106
119
  } }
107
120
  >
108
121
  { children }
@@ -17,6 +17,7 @@ type UseBoundProp< TValue extends PropValue > = {
17
17
  value: TValue;
18
18
  propType: PropType;
19
19
  placeholder?: TValue;
20
+ baseValue?: TValue;
20
21
  path: PropKey[];
21
22
  restoreValue: () => void;
22
23
  resetValue: () => void;
@@ -73,11 +74,12 @@ export function useBoundProp< TKey extends string, TValue extends PropValue >(
73
74
 
74
75
  const propType = resolveUnionPropType( propKeyContext.propType, propTypeUtil.key );
75
76
 
76
- const hasPlaceholder = propKeyContext.placeholder !== undefined && propKeyContext.placeholder !== null;
77
- const fallbackValue = hasPlaceholder ? null : propType.default;
77
+ const hasBaseValue = propKeyContext.baseValue !== undefined && propKeyContext.baseValue !== null;
78
+ const fallbackValue = hasBaseValue ? null : propType.default;
78
79
 
79
80
  const value = propTypeUtil.extract( propKeyContext.value ?? fallbackValue ?? null );
80
- const placeholder = propTypeUtil.extract( propKeyContext.placeholder ?? null );
81
+ const baseValue = propTypeUtil.extract( propKeyContext.baseValue ?? null );
82
+ const placeholder = propTypeUtil.extract( propKeyContext.placeholder ?? propKeyContext.baseValue ?? null );
81
83
 
82
84
  return {
83
85
  ...propKeyContext,
@@ -86,6 +88,7 @@ export function useBoundProp< TKey extends string, TValue extends PropValue >(
86
88
  value: isValid ? value : null,
87
89
  restoreValue,
88
90
  placeholder,
91
+ baseValue,
89
92
  disabled,
90
93
  resetValue,
91
94
  };