@elementor/editor-controls 4.1.0-750 → 4.1.0-752
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.d.mts
CHANGED
|
@@ -431,11 +431,12 @@ type PropContext<T extends PropValue, P extends PropType> = {
|
|
|
431
431
|
value: T | null;
|
|
432
432
|
propType: P;
|
|
433
433
|
placeholder?: T;
|
|
434
|
+
baseValue?: T;
|
|
434
435
|
isDisabled?: (propType: PropType) => boolean | undefined;
|
|
435
436
|
};
|
|
436
437
|
declare const PropContext: React$1.Context<PropContext<PropValue, PropType> | null>;
|
|
437
438
|
type PropProviderProps<T extends PropValue, P extends PropType> = React$1.PropsWithChildren<PropContext<T, P>>;
|
|
438
|
-
declare const PropProvider: <T extends PropValue, P extends PropType>({ children, value, setValue, propType, placeholder, isDisabled, }: PropProviderProps<T, P>) => React$1.JSX.Element;
|
|
439
|
+
declare const PropProvider: <T extends PropValue, P extends PropType>({ children, value, setValue, propType, placeholder, baseValue, isDisabled, }: PropProviderProps<T, P>) => React$1.JSX.Element;
|
|
439
440
|
|
|
440
441
|
type PropKeyContextValue<T, P> = {
|
|
441
442
|
bind: PropKey;
|
|
@@ -443,6 +444,7 @@ type PropKeyContextValue<T, P> = {
|
|
|
443
444
|
value: T;
|
|
444
445
|
propType: P;
|
|
445
446
|
placeholder?: T;
|
|
447
|
+
baseValue?: T;
|
|
446
448
|
path: PropKey[];
|
|
447
449
|
isDisabled?: (propType: PropType) => boolean | undefined;
|
|
448
450
|
disabled?: boolean;
|
|
@@ -458,6 +460,7 @@ type UseBoundProp<TValue extends PropValue> = {
|
|
|
458
460
|
value: TValue;
|
|
459
461
|
propType: PropType;
|
|
460
462
|
placeholder?: TValue;
|
|
463
|
+
baseValue?: TValue;
|
|
461
464
|
path: PropKey[];
|
|
462
465
|
restoreValue: () => void;
|
|
463
466
|
resetValue: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -431,11 +431,12 @@ type PropContext<T extends PropValue, P extends PropType> = {
|
|
|
431
431
|
value: T | null;
|
|
432
432
|
propType: P;
|
|
433
433
|
placeholder?: T;
|
|
434
|
+
baseValue?: T;
|
|
434
435
|
isDisabled?: (propType: PropType) => boolean | undefined;
|
|
435
436
|
};
|
|
436
437
|
declare const PropContext: React$1.Context<PropContext<PropValue, PropType> | null>;
|
|
437
438
|
type PropProviderProps<T extends PropValue, P extends PropType> = React$1.PropsWithChildren<PropContext<T, P>>;
|
|
438
|
-
declare const PropProvider: <T extends PropValue, P extends PropType>({ children, value, setValue, propType, placeholder, isDisabled, }: PropProviderProps<T, P>) => React$1.JSX.Element;
|
|
439
|
+
declare const PropProvider: <T extends PropValue, P extends PropType>({ children, value, setValue, propType, placeholder, baseValue, isDisabled, }: PropProviderProps<T, P>) => React$1.JSX.Element;
|
|
439
440
|
|
|
440
441
|
type PropKeyContextValue<T, P> = {
|
|
441
442
|
bind: PropKey;
|
|
@@ -443,6 +444,7 @@ type PropKeyContextValue<T, P> = {
|
|
|
443
444
|
value: T;
|
|
444
445
|
propType: P;
|
|
445
446
|
placeholder?: T;
|
|
447
|
+
baseValue?: T;
|
|
446
448
|
path: PropKey[];
|
|
447
449
|
isDisabled?: (propType: PropType) => boolean | undefined;
|
|
448
450
|
disabled?: boolean;
|
|
@@ -458,6 +460,7 @@ type UseBoundProp<TValue extends PropValue> = {
|
|
|
458
460
|
value: TValue;
|
|
459
461
|
propType: PropType;
|
|
460
462
|
placeholder?: TValue;
|
|
463
|
+
baseValue?: TValue;
|
|
461
464
|
path: PropKey[];
|
|
462
465
|
restoreValue: () => void;
|
|
463
466
|
resetValue: () => void;
|
package/dist/index.js
CHANGED
|
@@ -145,6 +145,7 @@ var PropProvider = ({
|
|
|
145
145
|
setValue,
|
|
146
146
|
propType,
|
|
147
147
|
placeholder,
|
|
148
|
+
baseValue,
|
|
148
149
|
isDisabled
|
|
149
150
|
}) => {
|
|
150
151
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -155,6 +156,7 @@ var PropProvider = ({
|
|
|
155
156
|
propType,
|
|
156
157
|
setValue,
|
|
157
158
|
placeholder,
|
|
159
|
+
baseValue,
|
|
158
160
|
isDisabled
|
|
159
161
|
}
|
|
160
162
|
},
|
|
@@ -196,18 +198,28 @@ var ObjectPropKeyProvider = ({ children, bind }) => {
|
|
|
196
198
|
const { path } = (0, import_react2.useContext)(PropKeyContext) ?? {};
|
|
197
199
|
const setValue = (value2, options, meta) => {
|
|
198
200
|
const newValue = {
|
|
199
|
-
...context.value,
|
|
201
|
+
...context.value ?? context.baseValue,
|
|
200
202
|
[bind]: value2
|
|
201
203
|
};
|
|
202
204
|
return context?.setValue(newValue, options, { ...meta, bind });
|
|
203
205
|
};
|
|
204
206
|
const value = context.value?.[bind];
|
|
205
207
|
const placeholder = context.placeholder?.[bind];
|
|
208
|
+
const baseValue = context.baseValue?.[bind];
|
|
206
209
|
const propType = context.propType.shape[bind];
|
|
207
210
|
return /* @__PURE__ */ React2.createElement(
|
|
208
211
|
PropKeyContext.Provider,
|
|
209
212
|
{
|
|
210
|
-
value: {
|
|
213
|
+
value: {
|
|
214
|
+
...context,
|
|
215
|
+
value,
|
|
216
|
+
setValue,
|
|
217
|
+
placeholder,
|
|
218
|
+
baseValue,
|
|
219
|
+
bind,
|
|
220
|
+
propType,
|
|
221
|
+
path: [...path ?? [], bind]
|
|
222
|
+
}
|
|
211
223
|
},
|
|
212
224
|
children
|
|
213
225
|
);
|
|
@@ -216,12 +228,13 @@ var ArrayPropKeyProvider = ({ children, bind }) => {
|
|
|
216
228
|
const context = usePropContext();
|
|
217
229
|
const { path } = (0, import_react2.useContext)(PropKeyContext) ?? {};
|
|
218
230
|
const setValue = (value2, options) => {
|
|
219
|
-
const newValue = [...context.value ?? []];
|
|
231
|
+
const newValue = [...context.value ?? context.baseValue ?? []];
|
|
220
232
|
newValue[Number(bind)] = value2;
|
|
221
233
|
return context?.setValue(newValue, options, { bind });
|
|
222
234
|
};
|
|
223
235
|
const value = context.value?.[Number(bind)];
|
|
224
236
|
const placeholder = context.placeholder?.[Number(bind)];
|
|
237
|
+
const baseValue = context.baseValue?.[Number(bind)];
|
|
225
238
|
const propType = context.propType.item_prop_type;
|
|
226
239
|
return /* @__PURE__ */ React2.createElement(
|
|
227
240
|
PropKeyContext.Provider,
|
|
@@ -233,7 +246,8 @@ var ArrayPropKeyProvider = ({ children, bind }) => {
|
|
|
233
246
|
bind,
|
|
234
247
|
propType,
|
|
235
248
|
path: [...path ?? [], bind],
|
|
236
|
-
placeholder: placeholder ?? void 0
|
|
249
|
+
placeholder: placeholder ?? void 0,
|
|
250
|
+
baseValue: baseValue ?? void 0
|
|
237
251
|
}
|
|
238
252
|
},
|
|
239
253
|
children
|
|
@@ -275,10 +289,11 @@ function useBoundProp(propTypeUtil) {
|
|
|
275
289
|
return propKeyContext?.setValue(propTypeUtil?.create(value2, options), {}, meta);
|
|
276
290
|
}
|
|
277
291
|
const propType = resolveUnionPropType(propKeyContext.propType, propTypeUtil.key);
|
|
278
|
-
const
|
|
279
|
-
const fallbackValue =
|
|
292
|
+
const hasBaseValue = propKeyContext.baseValue !== void 0 && propKeyContext.baseValue !== null;
|
|
293
|
+
const fallbackValue = hasBaseValue ? null : propType.default;
|
|
280
294
|
const value = propTypeUtil.extract(propKeyContext.value ?? fallbackValue ?? null);
|
|
281
|
-
const
|
|
295
|
+
const baseValue = propTypeUtil.extract(propKeyContext.baseValue ?? null);
|
|
296
|
+
const placeholder = propTypeUtil.extract(propKeyContext.placeholder ?? propKeyContext.baseValue ?? null);
|
|
282
297
|
return {
|
|
283
298
|
...propKeyContext,
|
|
284
299
|
propType,
|
|
@@ -286,6 +301,7 @@ function useBoundProp(propTypeUtil) {
|
|
|
286
301
|
value: isValid ? value : null,
|
|
287
302
|
restoreValue,
|
|
288
303
|
placeholder,
|
|
304
|
+
baseValue,
|
|
289
305
|
disabled,
|
|
290
306
|
resetValue
|
|
291
307
|
};
|