From 31c3bdf566198e19430dc982a1a5ad42e6d7dbf5 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Wed, 20 Sep 2023 12:25:33 +0100 Subject: [PATCH] Fixed #4473 - Add ptOptions option to PrimeVue config --- components/lib/basecomponent/BaseComponent.vue | 4 ++-- components/lib/basedirective/BaseDirective.js | 4 ++-- components/lib/config/PrimeVue.d.ts | 2 ++ components/lib/config/PrimeVue.js | 4 ++++ components/lib/passthrough/index.js | 7 ++----- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/components/lib/basecomponent/BaseComponent.vue b/components/lib/basecomponent/BaseComponent.vue index 034e94238..90e007b97 100644 --- a/components/lib/basecomponent/BaseComponent.vue +++ b/components/lib/basecomponent/BaseComponent.vue @@ -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); diff --git a/components/lib/basedirective/BaseDirective.js b/components/lib/basedirective/BaseDirective.js index 5fb89479d..368d41689 100644 --- a/components/lib/basedirective/BaseDirective.js +++ b/components/lib/basedirective/BaseDirective.js @@ -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); diff --git a/components/lib/config/PrimeVue.d.ts b/components/lib/config/PrimeVue.d.ts index 59dafff04..c46016675 100644 --- a/components/lib/config/PrimeVue.d.ts +++ b/components/lib/config/PrimeVue.d.ts @@ -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; + ptOptions?: PassThroughOptions; unstyled?: boolean; csp?: PrimeVueCSPOptions; } diff --git a/components/lib/config/PrimeVue.js b/components/lib/config/PrimeVue.js index 04c8ba576..5ed983652 100644 --- a/components/lib/config/PrimeVue.js +++ b/components/lib/config/PrimeVue.js @@ -134,6 +134,10 @@ export const defaultOptions = { tooltip: 1100 }, pt: undefined, + ptOptions: { + mergeSections: true, + mergeProps: false + }, unstyled: false, csp: { nonce: undefined diff --git a/components/lib/passthrough/index.js b/components/lib/passthrough/index.js index 9f4c04900..07b2c8ece 100644 --- a/components/lib/passthrough/index.js +++ b/components/lib/passthrough/index.js @@ -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 } };