-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74925b4
commit adbf94f
Showing
4 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<script setup lang="ts"> | ||
import { computed } from 'vue'; | ||
import HiveButton from '@/components/hive-button/hive-button.vue'; | ||
import HiveInput from '@/components/hive-input/hive-input.vue'; | ||
const props = defineProps<{ | ||
title?: string; | ||
modelValue: (string | number)[]; | ||
}>(); | ||
const emit = defineEmits<{ | ||
(e: 'update:modelValue', value: (string | number)[]): void; | ||
}>(); | ||
const currentValue = computed({ | ||
get() { | ||
return props.modelValue; | ||
}, | ||
set(value) { | ||
emit('update:modelValue', value); | ||
}, | ||
}); | ||
const addValue = () => { | ||
currentValue.value.push(''); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<div class="container"> | ||
<slot name="title"> | ||
<div class="title" v-if="title">{{ title }}</div> | ||
</slot> | ||
<div v-for="(_, i) in currentValue" :key="i" class="input"> | ||
<hive-input style="width: 100%" v-model="currentValue[i]!" /> | ||
<hive-button @click="currentValue.splice(i, 1)" class="button">Удалить</hive-button> | ||
</div> | ||
<slot name="button" :add-value="addValue"> | ||
<hive-button @click="addValue">Добавить значение</hive-button> | ||
</slot> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
.title { | ||
font-size: 18px; | ||
} | ||
.input { | ||
display: flex; | ||
gap: 10px; | ||
.button { | ||
width: 30%; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters