Переписал BaseInputDate

This commit is contained in:
dderbentsov
2022-12-27 01:11:19 +03:00
parent d15960a020
commit 145c55fec3

View File

@@ -1,53 +1,57 @@
<template lang="pug">
.input-wrapper.flex.gap-x-2.px-4.box-border(
class="py-2.5",
:style="{ minWidth: widthInput + 'px' }"
)
input.input.w-full.outline-0.not-italic.date.cursor-text(
:value="value",
.flex.flex-col
.label(v-if="!!label") {{label}}
.field
input(
v-model="value",
type="date",
@input="$emit('update:value', $event.target.value)",
:placeholder="placeholder",
:maxlength="maxLength",
max="9999-12-31",
min="0000-01-01"
)
.slot(v-if="withIcon" :class="iconPosition")
slot.cursor-pointer
)
</template>
<script>
//TODO стили перенести для всего кита, избавиться от scoped
//TODO покрыть тестами
//TODO сделать серый цвет плейсхолдера
//TODO обработать ошибку при стирании даты
export default {
name: "BaseInputDate",
props: {
maxLength: Number,
value: String,
withIcon: {
default: false,
modelValue: Date,
label: String,
},
iconPosition: {
default: "right",
emits: ["update:modelValue"],
computed: {
value: {
get() {
return this.modelValue?.toISOString().split("T")[0];
},
set(value) {
this.$emit("update:modelValue", new Date(value));
},
placeholder: {
default: "Поиск",
},
widthInput: Number,
},
};
</script>
<style lang="sass" scoped>
.left
order: -1
.right
order: 1
.input-wrapper
.field
align-items: center
border: 1.5px solid var(--border-light-grey-color)
border-radius: 4px
background-color: var(--default-white)
color: var(--font-black-color)
.date
padding: 8px 16px
input
cursor: text
border: none
outline: none
background: url("../../assets/icons/calendar-input.svg") no-repeat 100% 50%
&::-webkit-calendar-picker-indicator
opacity: 0
cursor: pointer
.label
font-weight: 600
font-size: 14px
line-height: 135%
</style>