Fixed #4473 - Add ptOptions option to PrimeVue config

pull/4476/head
mertsincan 2023-09-20 12:25:33 +01:00
parent 234c9a48d2
commit 31c3bdf566
5 changed files with 12 additions and 9 deletions

View File

@ -471,7 +471,7 @@ export default {
_getPTValue(obj = {}, key = '', params = {}, searchInDefaultPT = true) {
const datasetPrefix = 'data-pc-';
const searchOut = /./g.test(key) && !!params[key.split('.')[0]];
const { mergeSections = true, mergeProps: useMergeProps = false } = this._getPropValue('ptOptions') || {};
const { mergeSections = true, mergeProps: useMergeProps = false } = this._getPropValue('ptOptions') || this.$config?.ptOptions || {};
const global = searchInDefaultPT ? (searchOut ? this._useGlobalPT(this._getPTClassValue, key, params) : this._useDefaultPT(this._getPTClassValue, key, params)) : undefined;
const self = searchOut ? undefined : this._usePT(this._getPT(obj, this.$name), this._getPTClassValue, key, { ...params, global: global || {} });
const datasets = key !== 'transition' && {
@ -509,7 +509,7 @@ export default {
const fn = (value) => callback(value, key, params);
if (pt?.hasOwnProperty('_usept')) {
const { mergeSections = true, mergeProps: useMergeProps = false } = pt['_usept'] || {};
const { mergeSections = true, mergeProps: useMergeProps = false } = pt['_usept'] || this.$config?.ptOptions || {};
const originalValue = fn(pt.originalValue);
const value = fn(pt.value);

View File

@ -22,7 +22,7 @@ const BaseDirective = {
};
const datasetPrefix = 'data-pc-';
const { mergeSections = true, mergeProps: useMergeProps = false } = instance.binding?.value?.ptOptions || {};
const { mergeSections = true, mergeProps: useMergeProps = false } = instance.binding?.value?.ptOptions || instance.$config?.ptOptions || {};
const global = searchInDefaultPT ? BaseDirective._useDefaultPT(instance, instance.defaultPT, getValue, key, params) : undefined;
const self = BaseDirective._usePT(instance, BaseDirective._getPT(obj, instance.$name), getValue, key, { ...params, global: global || {} });
const datasets = {
@ -54,7 +54,7 @@ const BaseDirective = {
const fn = (value) => callback(value, key, params);
if (pt?.hasOwnProperty('_usept')) {
const { mergeSections = true, mergeProps: useMergeProps = false } = pt['_usept'] || {};
const { mergeSections = true, mergeProps: useMergeProps = false } = pt['_usept'] || instance.$config?.ptOptions || {};
const originalValue = fn(pt.originalValue);
const value = fn(pt.value);

View File

@ -56,6 +56,7 @@ import { OverlayPanelPassThroughOptions } from '../overlaypanel';
import { PaginatorPassThroughOptions } from '../paginator';
import { PanelPassThroughOptions } from '../panel';
import { PanelMenuPassThroughOptions } from '../panelmenu';
import { PassThroughOptions } from '../passthrough';
import { PasswordPassThroughOptions } from '../password';
import { PickListPassThroughOptions } from '../picklist';
import { ProgressBarPassThroughOptions } from '../progressbar';
@ -102,6 +103,7 @@ export interface PrimeVueConfiguration {
filterMatchModeOptions?: any;
zIndex?: PrimeVueZIndexOptions;
pt?: PassThrough<PrimeVuePTOptions>;
ptOptions?: PassThroughOptions;
unstyled?: boolean;
csp?: PrimeVueCSPOptions;
}

View File

@ -134,6 +134,10 @@ export const defaultOptions = {
tooltip: 1100
},
pt: undefined,
ptOptions: {
mergeSections: true,
mergeProps: false
},
unstyled: false,
csp: {
nonce: undefined

View File

@ -5,12 +5,9 @@
* usePassThrough(pt1, pt2, pt3, pt*, { mergeSections: true });
* usePassThrough(pt1, { mergeSections: true });
*/
export const usePassThrough = (pt1 = {}, pt2 = {}, { mergeSections = true, mergeProps = false } = {}) => {
export const usePassThrough = (pt1 = {}, pt2 = {}, ptOptions) => {
return {
_usept: {
mergeSections,
mergeProps
},
_usept: ptOptions,
originalValue: pt1,
value: { ...pt1, ...pt2 }
};