From 95e0a2414c6fa67760e390c3c553b0fea49cde3b Mon Sep 17 00:00:00 2001 From: tugcekucukoglu Date: Wed, 27 Mar 2024 16:22:02 +0300 Subject: [PATCH] Refactor #5437 - For ConfirmDialog/ConfirmPopup --- .../lib/confirmdialog/BaseConfirmDialog.vue | 14 +++++++++++ .../lib/confirmdialog/ConfirmDialog.d.ts | 14 ++++++++++- .../lib/confirmdialog/ConfirmDialog.vue | 20 ++++++++-------- .../lib/confirmpopup/BaseConfirmPopup.vue | 19 ++++++++++++++- components/lib/confirmpopup/ConfirmPopup.d.ts | 14 ++++++++++- components/lib/confirmpopup/ConfirmPopup.vue | 24 ++++++++++--------- 6 files changed, 81 insertions(+), 24 deletions(-) diff --git a/components/lib/confirmdialog/BaseConfirmDialog.vue b/components/lib/confirmdialog/BaseConfirmDialog.vue index 7be91657a..50ea59adf 100644 --- a/components/lib/confirmdialog/BaseConfirmDialog.vue +++ b/components/lib/confirmdialog/BaseConfirmDialog.vue @@ -14,6 +14,20 @@ export default { draggable: { type: Boolean, default: true + }, + rejectButtonProps: { + type: Object, + default() { + return { + text: true + }; + } + }, + acceptButtonProps: { + type: Object, + default() { + return {}; + } } }, style: ConfirmDialogStyle, diff --git a/components/lib/confirmdialog/ConfirmDialog.d.ts b/components/lib/confirmdialog/ConfirmDialog.d.ts index fc0587bb6..fbfcece34 100644 --- a/components/lib/confirmdialog/ConfirmDialog.d.ts +++ b/components/lib/confirmdialog/ConfirmDialog.d.ts @@ -9,7 +9,7 @@ */ import { VNode } from 'vue'; import { ComponentHooks } from '../basecomponent'; -import { ButtonPassThroughOptions } from '../button'; +import { ButtonPassThroughOptions, ButtonProps } from '../button'; import { ConfirmationOptions } from '../confirmationoptions'; import { PassThroughOptions } from '../passthrough'; import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers'; @@ -184,6 +184,18 @@ export interface ConfirmDialogProps { * @defaultValue true */ draggable?: boolean | undefined; + /** + * Used to pass all properties of the ButtonProps to the reject button inside the component. + * @type {ButtonProps} + * @defaultValue { text: true } + */ + rejectButtonProps?: object | undefined; + /** + * Used to pass all properties of the ButtonProps to the accept button inside the component. + * @type {ButtonProps} + * @defaultValue {} + */ + acceptButtonProps?: object | undefined; /** * Used to pass attributes to DOM elements inside the component. * @type {ConfirmDialogPassThroughOptions} diff --git a/components/lib/confirmdialog/ConfirmDialog.vue b/components/lib/confirmdialog/ConfirmDialog.vue index 72992520f..14eae12b9 100644 --- a/components/lib/confirmdialog/ConfirmDialog.vue +++ b/components/lib/confirmdialog/ConfirmDialog.vue @@ -1,5 +1,5 @@ - + diff --git a/components/lib/confirmpopup/BaseConfirmPopup.vue b/components/lib/confirmpopup/BaseConfirmPopup.vue index 09b2ceca6..979939758 100644 --- a/components/lib/confirmpopup/BaseConfirmPopup.vue +++ b/components/lib/confirmpopup/BaseConfirmPopup.vue @@ -6,7 +6,24 @@ export default { name: 'BaseConfirmPopup', extends: BaseComponent, props: { - group: String + group: String, + rejectButtonProps: { + type: Object, + default() { + return { + size: 'small', + text: true + }; + } + }, + acceptButtonProps: { + type: Object, + default() { + return { + size: 'small' + }; + } + } }, style: ConfirmPopupStyle, provide() { diff --git a/components/lib/confirmpopup/ConfirmPopup.d.ts b/components/lib/confirmpopup/ConfirmPopup.d.ts index f9769896f..5049bdd4b 100644 --- a/components/lib/confirmpopup/ConfirmPopup.d.ts +++ b/components/lib/confirmpopup/ConfirmPopup.d.ts @@ -9,7 +9,7 @@ */ import { TransitionProps, VNode } from 'vue'; import { ComponentHooks } from '../basecomponent'; -import { ButtonPassThroughOptions } from '../button'; +import { ButtonPassThroughOptions, ButtonProps } from '../button'; import { ConfirmationOptions } from '../confirmationoptions'; import { PassThroughOptions } from '../passthrough'; import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers'; @@ -138,6 +138,18 @@ export interface ConfirmPopupProps { * Optional key to match the key of the confirmation, useful to target a specific confirm dialog instance. */ group?: string; + /** + * Used to pass all properties of the ButtonProps to the reject button inside the component. + * @type {ButtonProps} + * @defaultValue { size: 'small', text: true } + */ + rejectButtonProps?: object | undefined; + /** + * Used to pass all properties of the ButtonProps to the accept button inside the component. + * @type {ButtonProps} + * @defaultValue { size: 'small' } + */ + acceptButtonProps?: object | undefined; /** * Used to pass attributes to DOM elements inside the component. * @type {ConfirmPopupPassThroughOptions} diff --git a/components/lib/confirmpopup/ConfirmPopup.vue b/components/lib/confirmpopup/ConfirmPopup.vue index 585a808bf..e323402f8 100644 --- a/components/lib/confirmpopup/ConfirmPopup.vue +++ b/components/lib/confirmpopup/ConfirmPopup.vue @@ -15,39 +15,41 @@
- - - +
@@ -298,10 +300,10 @@ export default { return this.confirmation ? this.confirmation.message : null; }, acceptLabel() { - return this.confirmation ? this.confirmation.acceptLabel || this.$primevue.config.locale.accept : null; + return this.confirmation ? this.confirmation.acceptLabel || this.acceptButtonProps.label || this.$primevue.config.locale.accept : null; }, rejectLabel() { - return this.confirmation ? this.confirmation.rejectLabel || this.$primevue.config.locale.reject : null; + return this.confirmation ? this.confirmation.rejectLabel || this.rejectButtonProps.label || this.$primevue.config.locale.reject : null; }, acceptIcon() { return this.confirmation ? this.confirmation.acceptIcon : null; @@ -311,8 +313,8 @@ export default { } }, components: { - CPButton: Button, - Portal: Portal + Button, + Portal }, directives: { focustrap: FocusTrap