mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
refactor: TagsItem typing
This commit is contained in:
parent
ea7f070b2c
commit
2977ed4d7a
2 changed files with 33 additions and 27 deletions
|
@ -1,31 +1,31 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { inject } from 'vue'
|
import { computed, inject } from 'vue'
|
||||||
|
|
||||||
withDefaults(
|
import { ValidationTouchSymbol } from '@/composables/form'
|
||||||
defineProps<{
|
import type { BaseItemComputedProps, TagsItemProps } from '@/types/form'
|
||||||
modelValue?: unknown[] | null
|
|
||||||
id?: string
|
const props = withDefaults(
|
||||||
placeholder?: string
|
defineProps<TagsItemProps & BaseItemComputedProps<string[]>>(),
|
||||||
limit?: number
|
|
||||||
required?: boolean
|
|
||||||
state?: boolean
|
|
||||||
name?: string
|
|
||||||
// FIXME no options on BFormTags
|
|
||||||
options?: unknown[]
|
|
||||||
}>(),
|
|
||||||
{
|
{
|
||||||
modelValue: null,
|
|
||||||
id: undefined,
|
id: undefined,
|
||||||
placeholder: undefined,
|
|
||||||
limit: undefined,
|
|
||||||
required: false,
|
|
||||||
state: undefined,
|
|
||||||
name: undefined,
|
name: undefined,
|
||||||
options: undefined,
|
placeholder: undefined,
|
||||||
|
touchKey: undefined,
|
||||||
|
limit: undefined,
|
||||||
|
// options: undefined,
|
||||||
|
|
||||||
|
ariaDescribedby: undefined,
|
||||||
|
modelValue: undefined,
|
||||||
|
state: undefined,
|
||||||
|
validation: undefined,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
const touch = inject('touch')
|
const touch = inject(ValidationTouchSymbol)
|
||||||
|
|
||||||
|
const model = defineModel<string[]>()
|
||||||
|
|
||||||
|
const required = computed(() => 'required' in (props?.validation ?? {}))
|
||||||
|
|
||||||
// FIXME rework for options/choices
|
// FIXME rework for options/choices
|
||||||
// https://bootstrap-vue-next.github.io/bootstrap-vue-next/docs/components/form-tags.html#using-custom-form-components
|
// https://bootstrap-vue-next.github.io/bootstrap-vue-next/docs/components/form-tags.html#using-custom-form-components
|
||||||
|
@ -33,16 +33,16 @@ const touch = inject('touch')
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<BFormTags
|
<BFormTags
|
||||||
:modelValue="modelValue"
|
|
||||||
@update:modelValue="$emit('update:modelValue', $event)"
|
|
||||||
:id="id"
|
:id="id"
|
||||||
|
v-model="model"
|
||||||
|
:name="name"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:required="required"
|
|
||||||
separator=" ,;"
|
|
||||||
:limit="limit"
|
:limit="limit"
|
||||||
remove-on-delete
|
:aria-describedby="ariaDescribedby"
|
||||||
:state="state"
|
:state="state"
|
||||||
:options="options"
|
:required="required"
|
||||||
@blur="touch(name)"
|
remove-on-delete
|
||||||
|
separator=" ,;"
|
||||||
|
@blur="touch?.(touchKey)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -76,3 +76,9 @@ export type InputItemProps = BaseWritableItemProps & {
|
||||||
export type SelectItemProps = BaseWritableItemProps & {
|
export type SelectItemProps = BaseWritableItemProps & {
|
||||||
choices: string[] | { text: string; value: string }[]
|
choices: string[] | { text: string; value: string }[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type TagsItemProps = BaseWritableItemProps & {
|
||||||
|
limit?: number
|
||||||
|
// FIXME no options on BFormTags?
|
||||||
|
// options?: string[]
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue