-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VEZ-14 fixed DSelect.vue for DTextfield.vue
- Loading branch information
1 parent
87502cc
commit 95d5bc5
Showing
7 changed files
with
142 additions
and
83 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,72 @@ | ||
<template> | ||
<div v-bind="{...$props, ...$attrs}" @focusin="$emit('focusin')" @keyup.esc="dropdownOpen = false" | ||
@focusout="$emit('focusout')" @click.self="toggleDropdown" @keypress.enter="dropdownOpen = true" | ||
tabindex="0"> | ||
<slot name="label" :item="items[modelValue]" :index="modelValue"> | ||
<span class="d-text-field__input__default">{{ items[modelValue] }}</span> | ||
</slot> | ||
<DIconButton size="24" rounded="md" class="d-text-field__input__icon" tabindex="-1" @click="toggleDropdown"> | ||
<SlideYDownTransition group :duration="150"> | ||
<DIcon :name="angleIcon" color="currentColor"/> | ||
</SlideYDownTransition> | ||
</DIconButton> | ||
<DSelectMenu :items="items" :modelValue="modelValue" @update:modelValue="onInput" | ||
v-model:open="dropdownOpen" :mandatory="mandatory" :multiple="false" :color="$attrs.color"> | ||
<template v-slot:item="props"> | ||
<slot name="item" v-bind="props"></slot> | ||
</template> | ||
</DSelectMenu> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import {computed, ref} from "vue"; | ||
import DSelectMenu from "../../menu/DSelectMenu.vue"; | ||
import DIconButton from "../../button/DIconButton.vue"; | ||
import DIcon from "../../icon/DIcon.vue"; | ||
import defaultProps from "../../../mixins/DefaultProps"; | ||
const emit = defineEmits(['update:modelValue', 'removeFocus']) | ||
const props = defineProps({ | ||
modelValue: [Number, String], | ||
items: Array, | ||
mandatory: {type: Boolean}, | ||
...defaultProps | ||
}) | ||
const dropdownOpen = ref(false); | ||
function toggleDropdown() { | ||
dropdownOpen.value = !dropdownOpen.value; | ||
} | ||
function onInput(val: any) { | ||
emit('update:modelValue', val) | ||
emit('removeFocus') | ||
} | ||
const angleIcon = computed(() => { | ||
return dropdownOpen.value ? 'angle-up' : 'angle-down' | ||
}) | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.d-text-field__input { | ||
user-select: none; | ||
cursor: default; | ||
position: relative; | ||
padding-top: 0.5em !important; | ||
padding-bottom: 0.5em !important; | ||
display: flex; | ||
.d-text-field__input__default { | ||
align-self: center; | ||
} | ||
.d-text-field__input__icon { | ||
margin-left: auto; | ||
margin-right: -8px; | ||
align-self: center; | ||
} | ||
} | ||
</style> |
This file was deleted.
Oops, something went wrong.
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,36 @@ | ||
import DTextfield from "../components/textfield/DTextfield.vue"; | ||
import {ref} from "vue"; | ||
|
||
export default { | ||
title: 'DTextfield', | ||
component: DTextfield, | ||
}; | ||
|
||
const Template = (args) => ({ | ||
components: {DTextfield}, | ||
setup() { | ||
const modelValue = ref(0) | ||
return {args, modelValue}; | ||
}, | ||
template: ` | ||
<d-textfield v-bind="args" v-model="modelValue" :items="[1,2,3,4]" mandatory> | ||
<template v-slot:item="{item}"> | ||
<d-tooltip> | ||
item: {{ item }} | ||
<template v-slot:tooltip> | ||
{{item}} | ||
</template> | ||
</d-tooltip> | ||
</template> | ||
<template v-slot:label="{item}"> | ||
selected: {{ item }} | ||
</template> | ||
</d-textfield>`, | ||
}); | ||
|
||
export const Primary = Template.bind({}); | ||
Primary.args = { | ||
label: 'Primary', | ||
color: 'primary', | ||
filled: true | ||
}; |