@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/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +23 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/bound-prop-context/prop-context.tsx +3 -0
- package/src/bound-prop-context/prop-key-context.tsx +16 -3
- package/src/bound-prop-context/use-bound-prop.ts +6 -3
package/dist/index.mjs
CHANGED
|
@@ -31,6 +31,7 @@ var PropProvider = ({
|
|
|
31
31
|
setValue,
|
|
32
32
|
propType,
|
|
33
33
|
placeholder,
|
|
34
|
+
baseValue,
|
|
34
35
|
isDisabled
|
|
35
36
|
}) => {
|
|
36
37
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -41,6 +42,7 @@ var PropProvider = ({
|
|
|
41
42
|
propType,
|
|
42
43
|
setValue,
|
|
43
44
|
placeholder,
|
|
45
|
+
baseValue,
|
|
44
46
|
isDisabled
|
|
45
47
|
}
|
|
46
48
|
},
|
|
@@ -82,18 +84,28 @@ var ObjectPropKeyProvider = ({ children, bind }) => {
|
|
|
82
84
|
const { path } = useContext2(PropKeyContext) ?? {};
|
|
83
85
|
const setValue = (value2, options, meta) => {
|
|
84
86
|
const newValue = {
|
|
85
|
-
...context.value,
|
|
87
|
+
...context.value ?? context.baseValue,
|
|
86
88
|
[bind]: value2
|
|
87
89
|
};
|
|
88
90
|
return context?.setValue(newValue, options, { ...meta, bind });
|
|
89
91
|
};
|
|
90
92
|
const value = context.value?.[bind];
|
|
91
93
|
const placeholder = context.placeholder?.[bind];
|
|
94
|
+
const baseValue = context.baseValue?.[bind];
|
|
92
95
|
const propType = context.propType.shape[bind];
|
|
93
96
|
return /* @__PURE__ */ React2.createElement(
|
|
94
97
|
PropKeyContext.Provider,
|
|
95
98
|
{
|
|
96
|
-
value: {
|
|
99
|
+
value: {
|
|
100
|
+
...context,
|
|
101
|
+
value,
|
|
102
|
+
setValue,
|
|
103
|
+
placeholder,
|
|
104
|
+
baseValue,
|
|
105
|
+
bind,
|
|
106
|
+
propType,
|
|
107
|
+
path: [...path ?? [], bind]
|
|
108
|
+
}
|
|
97
109
|
},
|
|
98
110
|
children
|
|
99
111
|
);
|
|
@@ -102,12 +114,13 @@ var ArrayPropKeyProvider = ({ children, bind }) => {
|
|
|
102
114
|
const context = usePropContext();
|
|
103
115
|
const { path } = useContext2(PropKeyContext) ?? {};
|
|
104
116
|
const setValue = (value2, options) => {
|
|
105
|
-
const newValue = [...context.value ?? []];
|
|
117
|
+
const newValue = [...context.value ?? context.baseValue ?? []];
|
|
106
118
|
newValue[Number(bind)] = value2;
|
|
107
119
|
return context?.setValue(newValue, options, { bind });
|
|
108
120
|
};
|
|
109
121
|
const value = context.value?.[Number(bind)];
|
|
110
122
|
const placeholder = context.placeholder?.[Number(bind)];
|
|
123
|
+
const baseValue = context.baseValue?.[Number(bind)];
|
|
111
124
|
const propType = context.propType.item_prop_type;
|
|
112
125
|
return /* @__PURE__ */ React2.createElement(
|
|
113
126
|
PropKeyContext.Provider,
|
|
@@ -119,7 +132,8 @@ var ArrayPropKeyProvider = ({ children, bind }) => {
|
|
|
119
132
|
bind,
|
|
120
133
|
propType,
|
|
121
134
|
path: [...path ?? [], bind],
|
|
122
|
-
placeholder: placeholder ?? void 0
|
|
135
|
+
placeholder: placeholder ?? void 0,
|
|
136
|
+
baseValue: baseValue ?? void 0
|
|
123
137
|
}
|
|
124
138
|
},
|
|
125
139
|
children
|
|
@@ -161,10 +175,11 @@ function useBoundProp(propTypeUtil) {
|
|
|
161
175
|
return propKeyContext?.setValue(propTypeUtil?.create(value2, options), {}, meta);
|
|
162
176
|
}
|
|
163
177
|
const propType = resolveUnionPropType(propKeyContext.propType, propTypeUtil.key);
|
|
164
|
-
const
|
|
165
|
-
const fallbackValue =
|
|
178
|
+
const hasBaseValue = propKeyContext.baseValue !== void 0 && propKeyContext.baseValue !== null;
|
|
179
|
+
const fallbackValue = hasBaseValue ? null : propType.default;
|
|
166
180
|
const value = propTypeUtil.extract(propKeyContext.value ?? fallbackValue ?? null);
|
|
167
|
-
const
|
|
181
|
+
const baseValue = propTypeUtil.extract(propKeyContext.baseValue ?? null);
|
|
182
|
+
const placeholder = propTypeUtil.extract(propKeyContext.placeholder ?? propKeyContext.baseValue ?? null);
|
|
168
183
|
return {
|
|
169
184
|
...propKeyContext,
|
|
170
185
|
propType,
|
|
@@ -172,6 +187,7 @@ function useBoundProp(propTypeUtil) {
|
|
|
172
187
|
value: isValid ? value : null,
|
|
173
188
|
restoreValue,
|
|
174
189
|
placeholder,
|
|
190
|
+
baseValue,
|
|
175
191
|
disabled,
|
|
176
192
|
resetValue
|
|
177
193
|
};
|