Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Use Typescript for Confirm Modal Component #157

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 23 additions & 33 deletions lib/components/modal/ConfirmModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/>
</div>
<div class="input-group push-right">
<button class="btn" @click="modal.hide()">
<button class="btn" @click="modal?.hide()">
<XIcon />
Cancel
</button>
Expand All @@ -33,47 +33,37 @@
</Modal>
</template>

<script setup>
<script setup lang="ts">
import { Modal, TrashIcon, XIcon, renderString } from '@'
import { ref } from 'vue'

const props = defineProps({
confirmationText: {
type: String,
default: '',
},
hasToType: {
type: Boolean,
default: false,
},
title: {
type: String,
default: 'No title defined',
required: true,
},
description: {
type: String,
default: 'No description defined',
required: true,
},
proceedLabel: {
type: String,
default: 'Proceed',
},
noblur: {
type: Boolean,
default: false,
},
})
const props = withDefaults(
defineProps<{
confirmationText: string
hasToType: boolean
title: string
description: string
proceedLabel: string
noblur: boolean
}>(),
{
confirmationText: '',
hasToType: false,
title: 'No title defined',
description: 'No description defined',
proceedLabel: 'Proceed',
noblur: false,
}
)

const emit = defineEmits(['proceed'])
const modal = ref(null)
const modal = ref<InstanceType<typeof Modal> | null>(null)

const action_disabled = ref(props.hasToType)
const confirmation_typed = ref('')

function proceed() {
modal.value.hide()
modal.value?.hide()
emit('proceed')
}

Expand All @@ -85,7 +75,7 @@ function type() {
}

function show() {
modal.value.show()
modal.value?.show()
}

defineExpose({ show })
Expand Down
Loading