pull/5507/head
mertsincan 2024-03-27 13:25:54 +00:00
commit e3cd4c1bca
6 changed files with 81 additions and 24 deletions

View File

@ -14,6 +14,20 @@ export default {
draggable: { draggable: {
type: Boolean, type: Boolean,
default: true default: true
},
rejectButtonProps: {
type: Object,
default() {
return {
text: true
};
}
},
acceptButtonProps: {
type: Object,
default() {
return {};
}
} }
}, },
style: ConfirmDialogStyle, style: ConfirmDialogStyle,

View File

@ -9,7 +9,7 @@
*/ */
import { VNode } from 'vue'; import { VNode } from 'vue';
import { ComponentHooks } from '../basecomponent'; import { ComponentHooks } from '../basecomponent';
import { ButtonPassThroughOptions } from '../button'; import { ButtonPassThroughOptions, ButtonProps } from '../button';
import { ConfirmationOptions } from '../confirmationoptions'; import { ConfirmationOptions } from '../confirmationoptions';
import { PassThroughOptions } from '../passthrough'; import { PassThroughOptions } from '../passthrough';
import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers'; import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
@ -184,6 +184,18 @@ export interface ConfirmDialogProps {
* @defaultValue true * @defaultValue true
*/ */
draggable?: boolean | undefined; 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. * Used to pass attributes to DOM elements inside the component.
* @type {ConfirmDialogPassThroughOptions} * @type {ConfirmDialogPassThroughOptions}

View File

@ -1,5 +1,5 @@
<template> <template>
<CDialog <Dialog
v-model:visible="visible" v-model:visible="visible"
role="alertdialog" role="alertdialog"
:class="cx('root')" :class="cx('root')"
@ -28,22 +28,22 @@
<component v-else :is="$slots.message" :message="confirmation"></component> <component v-else :is="$slots.message" :message="confirmation"></component>
</template> </template>
<template v-if="!$slots.container" #footer> <template v-if="!$slots.container" #footer>
<CDButton :label="rejectLabel" :class="[cx('rejectButton'), confirmation.rejectClass]" @click="reject()" :text="!confirmation.rejectClass" :autofocus="autoFocusReject" :unstyled="unstyled" :pt="ptm('rejectButton')"> <Button :label="rejectLabel" :class="[cx('rejectButton'), confirmation.rejectClass]" @click="reject()" :autofocus="autoFocusReject" :unstyled="unstyled" v-bind="rejectButtonProps" :pt="ptm('rejectButton')" :text="rejectButtonProps.text">
<template v-if="rejectIcon || $slots.rejecticon" #icon="iconProps"> <template v-if="rejectIcon || $slots.rejecticon" #icon="iconProps">
<slot name="rejecticon"> <slot name="rejecticon">
<span :class="[rejectIcon, iconProps.class]" v-bind="ptm('rejectButton')['icon']" data-pc-section="rejectbuttonicon" /> <span :class="[rejectIcon, iconProps.class]" v-bind="ptm('rejectButton')['icon']" data-pc-section="rejectbuttonicon" />
</slot> </slot>
</template> </template>
</CDButton> </Button>
<CDButton :label="acceptLabel" :class="[cx('acceptButton'), confirmation.acceptClass]" @click="accept()" :autofocus="autoFocusAccept" :unstyled="unstyled" :pt="ptm('acceptButton')"> <Button :label="acceptLabel" :class="[cx('acceptButton'), confirmation.acceptClass]" @click="accept()" :autofocus="autoFocusAccept" :unstyled="unstyled" v-bind="acceptButtonProps" :pt="ptm('acceptButton')">
<template v-if="acceptIcon || $slots.accepticon" #icon="iconProps"> <template v-if="acceptIcon || $slots.accepticon" #icon="iconProps">
<slot name="accepticon"> <slot name="accepticon">
<span :class="[acceptIcon, iconProps.class]" v-bind="ptm('acceptButton')['icon']" data-pc-section="acceptbuttonicon" /> <span :class="[acceptIcon, iconProps.class]" v-bind="ptm('acceptButton')['icon']" data-pc-section="acceptbuttonicon" />
</slot> </slot>
</template> </template>
</CDButton> </Button>
</template> </template>
</CDialog> </Dialog>
</template> </template>
<script> <script>
@ -132,10 +132,10 @@ export default {
return this.confirmation ? this.confirmation.position : null; return this.confirmation ? this.confirmation.position : null;
}, },
acceptLabel() { 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() { 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() { acceptIcon() {
return this.confirmation ? this.confirmation.acceptIcon : null; return this.confirmation ? this.confirmation.acceptIcon : null;
@ -154,8 +154,8 @@ export default {
} }
}, },
components: { components: {
CDialog: Dialog, Dialog,
CDButton: Button Button
} }
}; };
</script> </script>

View File

@ -6,7 +6,24 @@ export default {
name: 'BaseConfirmPopup', name: 'BaseConfirmPopup',
extends: BaseComponent, extends: BaseComponent,
props: { props: {
group: String group: String,
rejectButtonProps: {
type: Object,
default() {
return {
size: 'small',
text: true
};
}
},
acceptButtonProps: {
type: Object,
default() {
return {
size: 'small'
};
}
}
}, },
style: ConfirmPopupStyle, style: ConfirmPopupStyle,
provide() { provide() {

View File

@ -9,7 +9,7 @@
*/ */
import { TransitionProps, VNode } from 'vue'; import { TransitionProps, VNode } from 'vue';
import { ComponentHooks } from '../basecomponent'; import { ComponentHooks } from '../basecomponent';
import { ButtonPassThroughOptions } from '../button'; import { ButtonPassThroughOptions, ButtonProps } from '../button';
import { ConfirmationOptions } from '../confirmationoptions'; import { ConfirmationOptions } from '../confirmationoptions';
import { PassThroughOptions } from '../passthrough'; import { PassThroughOptions } from '../passthrough';
import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers'; 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. * Optional key to match the key of the confirmation, useful to target a specific confirm dialog instance.
*/ */
group?: string; 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. * Used to pass attributes to DOM elements inside the component.
* @type {ConfirmPopupPassThroughOptions} * @type {ConfirmPopupPassThroughOptions}

View File

@ -15,39 +15,41 @@
</template> </template>
<component v-else :is="$slots.message" :message="confirmation"></component> <component v-else :is="$slots.message" :message="confirmation"></component>
<div :class="cx('footer')" v-bind="ptm('footer')"> <div :class="cx('footer')" v-bind="ptm('footer')">
<CPButton <Button
:label="rejectLabel" :label="rejectLabel"
@click="reject()" @click="reject()"
@keydown="onRejectKeydown" @keydown="onRejectKeydown"
:autofocus="autoFocusReject" :autofocus="autoFocusReject"
:class="[cx('rejectButton'), confirmation.rejectClass]" :class="[cx('rejectButton'), confirmation.rejectClass]"
:size="{ small: !confirmation.rejectClass }"
:text="!confirmation.rejectClass"
:unstyled="unstyled" :unstyled="unstyled"
v-bind="rejectButtonProps"
:pt="ptm('rejectButton')" :pt="ptm('rejectButton')"
:size="rejectButtonProps.size"
:text="rejectButtonProps.text"
> >
<template v-if="rejectIcon || $slots.rejecticon" #icon="iconProps"> <template v-if="rejectIcon || $slots.rejecticon" #icon="iconProps">
<slot name="rejecticon"> <slot name="rejecticon">
<span :class="[rejectIcon, iconProps.class]" v-bind="ptm('rejectButton')['icon']" data-pc-section="rejectbuttonicon" /> <span :class="[rejectIcon, iconProps.class]" v-bind="ptm('rejectButton')['icon']" data-pc-section="rejectbuttonicon" />
</slot> </slot>
</template> </template>
</CPButton> </Button>
<CPButton <Button
:label="acceptLabel" :label="acceptLabel"
@click="accept()" @click="accept()"
@keydown="onAcceptKeydown" @keydown="onAcceptKeydown"
:autofocus="autoFocusAccept" :autofocus="autoFocusAccept"
:class="[cx('acceptButton'), confirmation.acceptClass]" :class="[cx('acceptButton'), confirmation.acceptClass]"
:size="{ small: !confirmation.acceptClass }"
:unstyled="unstyled" :unstyled="unstyled"
v-bind="acceptButtonProps"
:pt="ptm('acceptButton')" :pt="ptm('acceptButton')"
:size="acceptButtonProps.size"
> >
<template v-if="acceptIcon || $slots.accepticon" #icon="iconProps"> <template v-if="acceptIcon || $slots.accepticon" #icon="iconProps">
<slot name="accepticon"> <slot name="accepticon">
<span :class="[acceptIcon, iconProps.class]" v-bind="ptm('acceptButton')['icon']" data-pc-section="acceptbuttonicon" /> <span :class="[acceptIcon, iconProps.class]" v-bind="ptm('acceptButton')['icon']" data-pc-section="acceptbuttonicon" />
</slot> </slot>
</template> </template>
</CPButton> </Button>
</div> </div>
</template> </template>
</div> </div>
@ -298,10 +300,10 @@ export default {
return this.confirmation ? this.confirmation.message : null; return this.confirmation ? this.confirmation.message : null;
}, },
acceptLabel() { 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() { 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() { acceptIcon() {
return this.confirmation ? this.confirmation.acceptIcon : null; return this.confirmation ? this.confirmation.acceptIcon : null;
@ -311,8 +313,8 @@ export default {
} }
}, },
components: { components: {
CPButton: Button, Button,
Portal: Portal Portal
}, },
directives: { directives: {
focustrap: FocusTrap focustrap: FocusTrap