Skip to content

Commit

Permalink
refactor: use DatePicker from PrimeVue
Browse files Browse the repository at this point in the history
  • Loading branch information
zumuta committed Nov 30, 2024
1 parent c0a2f1d commit ee5449b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
<script setup lang="ts">
import { computed, toRef, useSlots } from 'vue';
import { toRef, useSlots } from 'vue';
import { useField } from 'vee-validate';
import RequiredIcon from '../icons/RequiredIcon.vue';
import VueDatePicker from '@vuepic/vue-datepicker';
import type { TimeModel } from '@vuepic/vue-datepicker';
import '@vuepic/vue-datepicker/dist/main.css';
import DatePicker from 'primevue/datepicker';
const props = defineProps<{
name: string,
id?: string,
placeholder?: string
format?: string
required?: boolean
}>();
const slots = useSlots();
const nameRef = toRef(props, 'name');
const { value, errorMessage } = useField<TimeModel>(nameRef);
const format = computed(() => props.format ?? 'HH:mm');
const { value, errorMessage } = useField<Date>(nameRef);
</script>

<template>
Expand All @@ -34,14 +29,12 @@ const format = computed(() => props.format ?? 'HH:mm');
class="ml-1 w-2 h-2 -mt-4 fill-black"
/>
</label>
<VueDatePicker
<DatePicker
:id="id ?? name"
v-model="value"
:format="format"
time-picker
text-input
:hour-format="'24'"
time-only
:placeholder="placeholder ?? ''"
:class="{ 'mt-1': !!slots.label, 'border-red-600': errorMessage, 'focus:ring-red-600': errorMessage, 'focus:border-red-600': errorMessage }"
/>
<p
v-if="!!slots.help"
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/kwai-ui/src/form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export { default as InputField } from './InputField.vue';
export { default as KwaiDateRangePicker } from './KwaiDateRangePicker.vue';
export { default as KwaiDatePicker } from './KwaiDatePicker.vue';
export type { TimeModel } from '@vuepic/vue-datepicker';
export { default as TimePicker } from './TimePicker.vue';
export { default as KwaiTimePicker } from './KwaiTimePicker.vue';
export { default as CheckBox } from './CheckBox.vue';
export { default as KwaiButton } from './KwaiButton.vue';
export { default as KwaiButtonGroup } from './KwaiButtonGroup.vue';
Expand Down

0 comments on commit ee5449b

Please sign in to comment.