big update

This commit is contained in:
2023-09-20 14:09:22 +03:00
parent f58a5106eb
commit 56c40021ba
35 changed files with 1049 additions and 324 deletions
+20 -13
View File
@@ -1,32 +1,39 @@
<script lang="ts">
import type { TUiFieldInputProps, TUiFieldInputEmits } from './FieldInput.vue'
export type TUiFieldDateProps = TUiFieldInputProps<Date>
export type TUiFieldDateEmits = TUiFieldInputEmits
</script>
<script setup lang="ts">
import { computed } from 'vue'
import { cFieldsSchema, getDateCommonFormat } from 'axp-ts'
import UiFieldInput from './FieldInput.vue'
import UiField from './Field.vue'
// Props.
const props = defineProps<TUiFieldDateProps>()
const props = defineProps<{
modelValue?: Date
}>()
const emit = defineEmits<{ (e: 'update:modelValue', v?: Date): void }>()
// Emits.
const emit = defineEmits<TUiFieldDateEmits>()
// Etc.
const valueStr = computed({
get: () => {
try {
const value = cFieldsSchema.shape.date.parse(props.modelValue)
const format = getDateCommonFormat(value)
return format
} catch (e) {}
return getDateCommonFormat(value)
} catch (e) { }
},
set: (val) => {
set: val => {
emit('update:error')
try {
const value = cFieldsSchema.shape.date.parse(val)
emit('update:modelValue', value)
} catch (e) {}
emit('update:model-value', value)
} catch (e) { }
}
})
</script>
<template>
<ui-field type="date" class="ui-field-date" v-model="valueStr" />
<ui-field-input :="{ ...props, ...$attrs }" v-model="valueStr" type="date" />
</template>