11<script setup lang="ts">
22import FlatPickr from ' vue-flatpickr-component' ;
3- import { ref , computed , onMounted , nextTick , PropType , useAttrs } from ' vue' ;
3+ import { ref , computed , onMounted , nextTick , PropType } from ' vue' ;
44import { useTheme } from ' vuetify' ;
55import { useFocus } from ' @vueuse/core' ;
66
7- // @ts-expect-error There won't be declaration file for it
8- import { VField , filterFieldProps , makeVFieldProps } from ' vuetify/lib/components/VField/VField' ;
9-
10- // @ts-expect-error There won't be declaration file for it
11- import { VInput , makeVInputProps } from ' vuetify/lib/components/VInput/VInput' ;
12-
13- // @ts-expect-error There won't be declaration file for it
14- import { filterInputAttrs } from ' vuetify/lib/util/helpers' ;
15-
167const props = defineProps ({
17- autofocus: Boolean ,
18- counter: [Boolean , Number , String ] as PropType <true | number | string >,
19- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20- counterValue: Function as PropType <(value : any ) => number >,
8+ // Support string dates to match existing usage, plus Date/number/array
9+ modelValue: {
10+ type: [String , Number , Array , Object ] as PropType <null | string | number | Date | (string | number | Date )[]>,
11+ default: null
12+ },
13+ label: String ,
14+ id: String ,
2115 prefix: String ,
22- placeholder: String ,
23- persistentPlaceholder: Boolean ,
24- persistentCounter: Boolean ,
2516 suffix: String ,
26- type: {
27- type: String ,
28- default: ' text'
17+ placeholder: String ,
18+ density: { type: String as PropType <' default' | ' comfortable' | ' compact' >, default: ' compact' },
19+ hideDetails: { type: [Boolean , String ] as PropType <boolean | ' auto' >, default: ' auto' },
20+ variant: {
21+ type: String as PropType <' outlined' | ' plain' | ' filled' | ' solo' | ' solo-filled' | ' solo-inverted' | ' underlined' >,
22+ default: ' outlined'
2923 },
30- modelModifiers: Object as PropType < Record < string , boolean >> ,
31- ... makeVInputProps ({
32- density: ' compact ' ,
33- hideDetails: ' auto '
34- }),
35- ... makeVFieldProps ({
36- variant: ' outlined ' ,
37- color: ' primary '
38- })
24+ color: { type: String , default: ' primary ' } ,
25+ // Additional styling passthroughs
26+ class: [ String , Array , Object ] as PropType < string | string [] | Record < string , boolean >> ,
27+ style: [ String , Object ] as PropType < string | Record < string , string >>,
28+ // Whether to mark the field as dirty
29+ dirty: Boolean ,
30+ // Flatpickr config object
31+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32+ config: { type: Object as PropType < Record < string , any >>, default : () => ({}) }
3933});
4034
4135const emit = defineEmits <Emit >();
@@ -53,25 +47,20 @@ defineOptions({
5347 inheritAttrs: false
5448});
5549
56- const attrs = useAttrs ();
57-
58- const [rootAttrs, compAttrs] = filterInputAttrs (attrs );
59-
60- // eslint-disable-next-line @typescript-eslint/no-unused-vars
61- const { modelValue : _, ... inputProps } = VInput .filterProps (props );
62- const fieldProps = filterFieldProps (props );
63- console .log (filterFieldProps (props ), VInput .filterProps (props ));
64-
6550const refFlatPicker = ref ();
6651const { focused } = useFocus (refFlatPicker );
6752const isCalendarOpen = ref (false );
6853const isInlinePicker = ref (false );
6954const isReadonly = ref (false );
7055
7156// flat picker prop manipulation
72- if (compAttrs .config && compAttrs .config .inline ) {
73- isInlinePicker .value = compAttrs .config .inline ;
74- Object .assign (compAttrs , { altInputClass: ' inlinePicker' });
57+ const compAttrs = ref <Record <string , unknown >>({});
58+ if (props .config ) {
59+ compAttrs .value = { ... props .config };
60+ if ((props .config as Record <string , unknown >).inline ) {
61+ isInlinePicker .value = Boolean ((props .config as Record <string , unknown >).inline );
62+ Object .assign (compAttrs .value , { altInputClass: ' inlinePicker' });
63+ }
7564}
7665
7766// v-field clear prop
@@ -111,7 +100,7 @@ const emitModelValue = (val: string) => {
111100};
112101
113102const elementId = computed (() => {
114- const _elementIdToken = fieldProps .id || fieldProps .label ;
103+ const _elementIdToken = props .id || props .label ;
115104
116105 return _elementIdToken ? ` app-picker-field-${_elementIdToken }-${Math .random ().toString (36 ).slice (2 , 7 )} ` : undefined ;
117106});
@@ -120,17 +109,11 @@ const elementId = computed(() => {
120109<template >
121110 <div class =" app-picker-field" >
122111 <!-- v-input -->
123- <VLabel
124- v-if =" fieldProps.label"
125- class =" mb-1 text-body-2 text-high-emphasis"
126- :for =" elementId"
127- :text =" fieldProps.label"
128- />
112+ <VLabel v-if =" props.label" class =" mb-1 text-body-2 text-high-emphasis" :for =" elementId" :text =" props.label" />
129113
130114 <VInput
131- v-bind =" { ...inputProps, ...rootAttrs }"
132- :model-value =" modelValue"
133115 :hide-details =" props.hideDetails"
116+ :density =" props.density"
134117 :class =" [
135118 {
136119 'v-text-field--prefixed': props.prefix,
@@ -145,7 +128,8 @@ const elementId = computed(() => {
145128 <template #default =" { id , isDirty , isValid , isDisabled } " >
146129 <!-- v-field -->
147130 <VField
148- v-bind =" { ...fieldProps, label: undefined }"
131+ :variant =" props.variant"
132+ :color =" props.color"
149133 :id =" id.value"
150134 role =" textbox"
151135 :active =" focused || isDirty.value || isCalendarOpen"
@@ -163,7 +147,7 @@ const elementId = computed(() => {
163147 v-bind =" compAttrs"
164148 :id =" elementId"
165149 ref =" refFlatPicker"
166- :model-value =" modelValue"
150+ :model-value =" props. modelValue"
167151 :placeholder =" props.placeholder"
168152 class =" flat-picker-custom-style"
169153 :disabled =" isReadonly"
@@ -175,7 +159,7 @@ const elementId = computed(() => {
175159 <!-- simple input for inline prop -->
176160 <input
177161 v-if =" isInlinePicker"
178- :value =" modelValue"
162+ :value =" props. modelValue"
179163 :placeholder =" props.placeholder"
180164 class =" flat-picker-custom-style"
181165 type =" text"
@@ -191,7 +175,7 @@ const elementId = computed(() => {
191175 v-if =" isInlinePicker"
192176 v-bind =" compAttrs"
193177 ref =" refFlatPicker"
194- :model-value =" modelValue"
178+ :model-value =" props. modelValue"
195179 @update:model-value =" emitModelValue"
196180 @on-open =" isCalendarOpen = true"
197181 @on-close =" isCalendarOpen = false"
@@ -201,8 +185,8 @@ const elementId = computed(() => {
201185
202186<style lang="scss">
203187/* stylelint-disable no-descending-specificity */
204- @use ' flatpickr/dist/flatpickr.css' ;
205188@use ' @/scss/mixins' ;
189+ @import url (' flatpickr/dist/flatpickr.css' );
206190
207191.flat-picker-custom-style {
208192 position : absolute ;
0 commit comments