refactor: clearable DatePicker
This commit is contained in:
parent
ea95191037
commit
8ee67bbca5
1 changed files with 11 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ const model = defineModel<string | Date | null>();
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
id?: string;
|
id?: string;
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
|
clearable?: boolean;
|
||||||
label?: string;
|
label?: string;
|
||||||
rules?: ((value: string) => string | true)[];
|
rules?: ((value: string) => string | true)[];
|
||||||
disabledDates?: string[] | Date[] | ((date: Date) => boolean);
|
disabledDates?: string[] | Date[] | ((date: Date) => boolean);
|
||||||
|
|
@ -54,6 +55,7 @@ function valueUpdate(value: string) {
|
||||||
utc
|
utc
|
||||||
auto-apply
|
auto-apply
|
||||||
:id
|
:id
|
||||||
|
:for="id"
|
||||||
:disabled="readonly"
|
:disabled="readonly"
|
||||||
:disabled-dates="disabledDates"
|
:disabled-dates="disabledDates"
|
||||||
:teleport="true"
|
:teleport="true"
|
||||||
|
|
@ -100,6 +102,15 @@ function valueUpdate(value: string) {
|
||||||
color="primary"
|
color="primary"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-if="clearable" v-slot:append>
|
||||||
|
<q-icon
|
||||||
|
v-if="model && !readonly"
|
||||||
|
name="mdi-close-circle"
|
||||||
|
class="cursor-pointer app-text-muted"
|
||||||
|
size="sm"
|
||||||
|
@click.stop="model = undefined"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
</template>
|
</template>
|
||||||
</VueDatePicker>
|
</VueDatePicker>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue