Fixed #4342 - Rename merge and useMergeProps options with mergeSections and mergeProps options on usePassThrough method

pull/4353/head
mertsincan 2023-08-28 22:00:10 +01:00
parent ed62934411
commit c57faf3db1
3 changed files with 10 additions and 10 deletions

View File

@ -508,7 +508,7 @@ export default {
const fn = (value) => callback(value, key, params);
if (pt?.hasOwnProperty('_usept')) {
const { merge, useMergeProps } = pt['_usept'];
const { mergeSections, mergeProps: useMergeProps } = pt['_usept'];
const originalValue = fn(pt.originalValue);
const value = fn(pt.value);
@ -516,7 +516,7 @@ export default {
else if (ObjectUtils.isString(value)) return value;
else if (ObjectUtils.isString(originalValue)) return originalValue;
return merge ? (useMergeProps ? mergeProps(originalValue, value) : { ...originalValue, ...value }) : value;
return mergeSections || (!mergeSections && value) ? (useMergeProps ? mergeProps(originalValue, value) : { ...originalValue, ...value }) : value;
}
return fn(pt);

View File

@ -52,7 +52,7 @@ const BaseDirective = {
const fn = (value) => callback(value, key, params);
if (pt?.hasOwnProperty('_usept')) {
const { merge, useMergeProps } = pt['_usept'];
const { mergeSections, mergeProps: useMergeProps } = pt['_usept'];
const originalValue = fn(pt.originalValue);
const value = fn(pt.value);
@ -60,7 +60,7 @@ const BaseDirective = {
else if (ObjectUtils.isString(value)) return value;
else if (ObjectUtils.isString(originalValue)) return originalValue;
return merge ? (useMergeProps ? mergeProps(originalValue, value) : { ...originalValue, ...value }) : value;
return mergeSections || (!mergeSections && value) ? (useMergeProps ? mergeProps(originalValue, value) : { ...originalValue, ...value }) : value;
}
return fn(pt);

View File

@ -2,16 +2,16 @@
* @todo: Add dynamic params support;
*
* Exp;
* usePassThrough(pt1, pt2, pt3, pt*, { merge: true });
* usePassThrough(pt1, { merge: true });
* usePassThrough(pt1, pt2, pt3, pt*, { mergeSections: true });
* usePassThrough(pt1, { mergeSections: true });
*/
export const usePassThrough = (pt1 = {}, pt2 = {}, { merge = true, useMergeProps = true } = {}) => {
export const usePassThrough = (pt1 = {}, pt2 = {}, { mergeSections = true, mergeProps = false } = {}) => {
return {
_usept: {
merge,
useMergeProps
mergeSections,
mergeProps
},
originalValue: pt1,
value: pt2
value: { ...pt1, ...pt2 }
};
};