mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
refactor: ButtonItem typing
This commit is contained in:
parent
32da3d9ee4
commit
906d9ca95c
2 changed files with 27 additions and 18 deletions
|
@ -1,24 +1,18 @@
|
|||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
label?: string
|
||||
id?: string
|
||||
type?: 'success' | 'info' | 'warning' | 'danger'
|
||||
icon?: string
|
||||
enabled?: string | boolean
|
||||
}>(),
|
||||
{
|
||||
label: undefined,
|
||||
id: undefined,
|
||||
type: 'success',
|
||||
icon: undefined,
|
||||
enabled: true,
|
||||
},
|
||||
)
|
||||
import type { ButtonItemProps } from '@/types/form'
|
||||
|
||||
const emit = defineEmits(['action'])
|
||||
const props = withDefaults(defineProps<ButtonItemProps>(), {
|
||||
id: undefined,
|
||||
enabled: true,
|
||||
icon: undefined,
|
||||
type: 'success',
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
action: [value: ButtonItemProps['id']]
|
||||
}>()
|
||||
|
||||
const icon = computed(() => {
|
||||
const icons = {
|
||||
|
@ -36,9 +30,9 @@ const icon = computed(() => {
|
|||
<BButton
|
||||
:id="id"
|
||||
:variant="type"
|
||||
@click="emit('action', $event)"
|
||||
:disabled="!enabled"
|
||||
class="d-block mb-3"
|
||||
@click="emit('action', id)"
|
||||
>
|
||||
<YIcon :iname="icon" class="me-2" />
|
||||
<span v-html="label" />
|
||||
|
|
|
@ -1,6 +1,21 @@
|
|||
import type { BaseValidation } from '@vuelidate/core'
|
||||
type StateValidation = false | null
|
||||
|
||||
// DISPLAY
|
||||
|
||||
type BaseDisplayItemProps = {
|
||||
label: string
|
||||
id?: string
|
||||
}
|
||||
|
||||
export type ButtonItemProps = BaseDisplayItemProps & {
|
||||
// FIXME compute enabled JSExpression
|
||||
enabled?: boolean
|
||||
icon?: string
|
||||
type?: StateVariant
|
||||
}
|
||||
|
||||
|
||||
// WRITABLE
|
||||
|
||||
type BaseWritableItemProps = {
|
||||
|
|
Loading…
Reference in a new issue