Skip to content

Commit

Permalink
Fixed #4929 - Add parent param to all pt method options
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Dec 5, 2023
1 parent 1a4bba8 commit eb00b8e
Show file tree
Hide file tree
Showing 104 changed files with 399 additions and 158 deletions.
4 changes: 4 additions & 0 deletions components/lib/accordion/Accordion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export interface AccordionPassThroughMethodOptions {
* Defines current inline state.
*/
state: AccordionState;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
1 change: 1 addition & 0 deletions components/lib/accordion/Accordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default {
const tabMetaData = {
props: tab.props || {},
parent: {
instance: this,
props: this.$props,
state: this.$data
},
Expand Down
5 changes: 2 additions & 3 deletions components/lib/accordiontab/AccordionTab.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*
*/
import { AnchorHTMLAttributes, HTMLAttributes, TransitionProps, VNode } from 'vue';
import { AccordionPassThroughOptions } from '../accordion';
import { PassThroughOptions } from '../passthrough';
import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers';

Expand All @@ -29,9 +28,9 @@ export interface AccordionTabPassThroughMethodOptions {
*/
props: AccordionTabProps;
/**
* Defines parent instance.
* Defines parent options.
*/
parent: AccordionPassThroughOptions;
parent: any;
/**
* Defines current options.
*/
Expand Down
4 changes: 4 additions & 0 deletions components/lib/autocomplete/AutoComplete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export interface AutoCompletePassThroughMethodOptions {
* Defines current options.
*/
context: AutoCompleteContext;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
5 changes: 2 additions & 3 deletions components/lib/avatar/Avatar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @module avatar
*/
import { VNode } from 'vue';
import { AvatarGroupPassThroughOptions } from '../avatargroup';
import { ComponentHooks } from '../basecomponent';
import { PassThroughOptions } from '../passthrough';
import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
Expand All @@ -27,9 +26,9 @@ export interface AvatarPassThroughMethodOptions {
*/
props: AvatarProps;
/**
* Defines parent instance.
* Defines parent options.
*/
parent: AvatarGroupPassThroughOptions;
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
15 changes: 4 additions & 11 deletions components/lib/avatar/Avatar.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<div :class="cx('root')" :aria-labelledby="ariaLabelledby" :aria-label="ariaLabel" v-bind="getPTOptions('root')" data-pc-name="avatar">
<div :class="cx('root')" :aria-labelledby="ariaLabelledby" :aria-label="ariaLabel" v-bind="ptm('root')" data-pc-name="avatar">
<slot>
<span v-if="label" :class="cx('label')" v-bind="getPTOptions('label')">{{ label }}</span>
<span v-if="label" :class="cx('label')" v-bind="ptm('label')">{{ label }}</span>
<component v-else-if="$slots.icon" :is="$slots.icon" :class="cx('icon')" />
<span v-else-if="icon" :class="[cx('icon'), icon]" v-bind="getPTOptions('icon')" />
<img v-else-if="image" :src="image" :alt="ariaLabel" @error="onError" v-bind="getPTOptions('image')" />
<span v-else-if="icon" :class="[cx('icon'), icon]" v-bind="ptm('icon')" />
<img v-else-if="image" :src="image" :alt="ariaLabel" @error="onError" v-bind="ptm('image')" />
</slot>
</div>
</template>
Expand All @@ -19,13 +19,6 @@ export default {
methods: {
onError(event) {
this.$emit('error', event);
},
getPTOptions(key) {
return this.ptm(key, {
parent: {
instance: this.$parent
}
});
}
}
};
Expand Down
14 changes: 2 additions & 12 deletions components/lib/badge/Badge.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<span :class="cx('root')" v-bind="getPTOptions('root')" data-pc-name="badge">
<span :class="cx('root')" v-bind="ptm('root')" data-pc-name="badge">
<slot>{{ value }}</slot>
</span>
</template>
Expand All @@ -9,16 +9,6 @@ import BaseBadge from './BaseBadge.vue';
export default {
name: 'Badge',
extends: BaseBadge,
methods: {
getPTOptions(key) {
return this.ptm(key, {
parent: {
props: this.$parent?.$props,
state: this.$parent?.$data
}
});
}
}
extends: BaseBadge
};
</script>
4 changes: 4 additions & 0 deletions components/lib/badgedirective/BadgeDirective.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export declare type BadgeDirectivePassThroughOptionType = BadgeDirectivePassThro
*/
export interface BadgePassThroughMethodOptions {
context: BadgeContext;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
15 changes: 14 additions & 1 deletion components/lib/basecomponent/BaseComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,20 @@ export default {
return this.unstyled !== undefined ? this.unstyled : this.$config?.unstyled;
},
$params() {
return { instance: this, props: this.$props, state: this.$data, parentInstance: this.$parentInstance };
const parentInstance = this.$parentInstance || this.$parent;
return {
instance: this,
props: this.$props,
state: this.$data,
parent: {
instance: parentInstance,
props: parentInstance?.$props,
state: parentInstance?.$data
},
/* @deprecated since v3.43.0. Use the `parent.instance` instead of the `parentInstance`.*/
parentInstance
};
},
$style() {
return { classes: undefined, inlineStyles: undefined, loadStyle: () => {}, loadCustomStyle: () => {}, ...(this._getHostInstance(this) || {}).$style, ...this.$options.style };
Expand Down
4 changes: 4 additions & 0 deletions components/lib/blockui/BlockUI.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export interface BlockUIPassThroughMethodOptions {
* Defines current inline state.
*/
state: BlockUIState;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
4 changes: 4 additions & 0 deletions components/lib/breadcrumb/Breadcrumb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export interface BreadcrumbPassThroughMethodOptions {
* Defines current options.
*/
context: BreadcrumbContext;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
4 changes: 0 additions & 4 deletions components/lib/button/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export default {
methods: {
getPTOptions(key) {
return this.ptm(key, {
parent: {
props: this.$parent?.$props,
state: this.$parent?.$data
},
context: {
disabled: this.disabled
}
Expand Down
4 changes: 4 additions & 0 deletions components/lib/calendar/Calendar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export interface CalendarPassThroughMethodOptions {
* Defines current options.
*/
context: CalendarContext;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
4 changes: 4 additions & 0 deletions components/lib/carousel/Carousel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export interface CarouselPassThroughMethodOptions {
* Defines current options.
*/
context: CarouselContext;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
4 changes: 4 additions & 0 deletions components/lib/cascadeselect/CascadeSelect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export interface CascadeSelectPassThroughMethodOptions {
* Defines current inline state.
*/
state: CascadeSelectState;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
4 changes: 4 additions & 0 deletions components/lib/chart/Chart.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export interface ChartPassThroughMethodOptions {
* Defines valid properties.
*/
props: ChartProps;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
4 changes: 4 additions & 0 deletions components/lib/checkbox/Checkbox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export interface CheckboxPassThroughMethodOptions {
* Defines current options.
*/
context: CheckboxContext;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
4 changes: 4 additions & 0 deletions components/lib/chip/Chip.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export interface ChipPassThroughMethodOptions {
* Defines current inline state.
*/
state: ChipState;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
4 changes: 4 additions & 0 deletions components/lib/chips/Chips.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export interface ChipsPassThroughMethodOptions {
* Defines current inline state.
*/
state: ChipsState;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
4 changes: 4 additions & 0 deletions components/lib/colorpicker/ColorPicker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export interface ColorPickerPassThroughMethodOptions {
* Defines current inline state.
*/
state: ColorPickerState;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
4 changes: 2 additions & 2 deletions components/lib/column/Column.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export interface ColumnPassThroughMethodOptions {
*/
props: ColumnProps;
/**
* Defines parent instance.
* Defines parent options.
*/
parent: DataTablePassThroughOptions;
parent: any;
/**
* Defines current options.
*/
Expand Down
5 changes: 2 additions & 3 deletions components/lib/columngroup/ColumnGroup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* @module columngroup
*/
import { ComponentHooks } from '../basecomponent';
import { DataTablePassThroughOptions } from '../datatable';
import { PassThroughOptions } from '../passthrough';
import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers';

Expand All @@ -25,9 +24,9 @@ export interface ColumnGroupPassThroughMethodOptions {
*/
props: ColumnGroupProps;
/**
* Defines parent instance.
* Defines parent options.
*/
parent: DataTablePassThroughOptions;
parent: any;
/**
* Defines current options.
*/
Expand Down
4 changes: 4 additions & 0 deletions components/lib/confirmdialog/ConfirmDialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export interface ConfirmDialogPassThroughMethodOptions {
* Defines current inline state.
*/
state: ConfirmDialogState;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
4 changes: 4 additions & 0 deletions components/lib/confirmpopup/ConfirmPopup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export interface ConfirmPopupPassThroughMethodOptions {
* Defines current inline state.
*/
state: ConfirmPopupState;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
4 changes: 4 additions & 0 deletions components/lib/contextmenu/ContextMenu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export interface ContextMenuPassThroughMethodOptions {
* Defines current options.
*/
context: ContextMenuContext;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
1 change: 1 addition & 0 deletions components/lib/datatable/BodyCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export default {
const columnMetaData = {
props: this.column.props,
parent: {
instance: this,
props: this.$props,
state: this.$data
},
Expand Down
1 change: 1 addition & 0 deletions components/lib/datatable/ColumnFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ export default {
const columnMetaData = {
props: this.column.props,
parent: {
instance: this,
props: this.$props,
state: this.$data
},
Expand Down
4 changes: 4 additions & 0 deletions components/lib/datatable/DataTable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export interface DataTablePassThroughMethodOptions {
* Defines current options.
*/
context: DataTableContext;
/**
* Defines parent options.
*/
parent: any;
/**
* Defines passthrough(pt) options in global config.
*/
Expand Down
1 change: 1 addition & 0 deletions components/lib/datatable/FooterCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default {
const columnMetaData = {
props: this.column.props,
parent: {
instance: this,
props: this.$props,
state: this.$data
},
Expand Down
1 change: 1 addition & 0 deletions components/lib/datatable/HeaderCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export default {
const columnMetaData = {
props: this.column.props,
parent: {
instance: this,
props: this.$props,
state: this.$data
},
Expand Down
1 change: 1 addition & 0 deletions components/lib/datatable/HeaderCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default {
const columnMetaData = {
props: this.column.props,
parent: {
instance: this,
props: this.$props,
state: this.$data
},
Expand Down
Loading

0 comments on commit eb00b8e

Please sign in to comment.