1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-06 18:18:53 +08:00

Some changes in DelimiterSelector:

- disabled state for DelimiterSelector;
- DelimiterSelector emits the value only if it's not empty
This commit is contained in:
lana-k
2021-04-08 19:37:33 +02:00
parent eb950c1b9c
commit 7791f477cb

View File

@@ -1,5 +1,5 @@
<template> <template>
<div> <div :class="{ 'disabled': disabled }">
<div class="text-field-label">Delimiter</div> <div class="text-field-label">Delimiter</div>
<div <div
class="delimiter-selector-container" class="delimiter-selector-container"
@@ -14,12 +14,16 @@
@click.stop @click.stop
@keypress="onKeyPress" @keypress="onKeyPress"
@input.prevent="onInput($event)" @input.prevent="onInput($event)"
:disabled="disabled"
/> />
<div class="name">{{ getSymbolName(value) }}</div> <div class="name">{{ getSymbolName(value) }}</div>
</div> </div>
<div class="controls" @click.stop> <div class="controls" @click.stop>
<clear-icon @click.native="$emit('input', '')"/> <clear-icon @click.native="clear" :disabled="disabled"/>
<drop-down-chevron @click.native="showOptions = !showOptions"/> <drop-down-chevron
:disabled="disabled"
@click.native="!disabled && (showOptions = !showOptions)"
/>
</div> </div>
</div> </div>
<div v-show="showOptions" class="options" :style="{ width: width }"> <div v-show="showOptions" class="options" :style="{ width: width }">
@@ -42,7 +46,7 @@ import ClearIcon from '@/components/svg/clear'
export default { export default {
name: 'DelimiterSelector', name: 'DelimiterSelector',
props: ['label', 'value', 'width'], props: ['label', 'value', 'width', 'disabled'],
components: { DropDownChevron, ClearIcon }, components: { DropDownChevron, ClearIcon },
data () { data () {
return { return {
@@ -67,7 +71,10 @@ export default {
if (value.length > 1) { if (value.length > 1) {
event.target.value = value[0] event.target.value = value[0]
} }
this.$emit('input', event.target.value)
if (value) {
this.$emit('input', event.target.value)
}
}, },
chooseOption (option) { chooseOption (option) {
this.$emit('input', option) this.$emit('input', option)
@@ -75,6 +82,13 @@ export default {
}, },
onContainerClick (event) { onContainerClick (event) {
this.$refs.delimiterInput.focus() this.$refs.delimiterInput.focus()
},
clear () {
if (!this.disabled) {
this.$refs.delimiterInput.value = ''
this.$refs.delimiterInput.focus()
}
} }
} }
} }
@@ -84,7 +98,6 @@ export default {
.delimiter-selector-container { .delimiter-selector-container {
background: var(--color-white); background: var(--color-white);
border: 1px solid var(--color-border); border: 1px solid var(--color-border);
color: var(--color-text-light-2);
border-radius: var(--border-radius-medium-2); border-radius: var(--border-radius-medium-2);
height: 36px; height: 36px;
padding: 0 8px; padding: 0 8px;
@@ -101,6 +114,7 @@ export default {
} }
.value .name { .value .name {
color: var(--color-text-light-2);
cursor: default; cursor: default;
} }
@@ -162,10 +176,24 @@ input:focus {
outline: none; outline: none;
} }
input:disabled {
background: var(--color-bg-light);
color: var(--color-text-light-2);
cursor: default;
}
.text-field-label { .text-field-label {
font-size: 12px; font-size: 12px;
color: var(--color-text-base); color: var(--color-text-base);
padding-left: 8px; padding-left: 8px;
margin-bottom: 2px; margin-bottom: 2px;
} }
.disabled .text-field-label {
color: var(--color-text-light-2);
}
.disabled .delimiter-selector-container {
background: var(--color-bg-light);
}
</style> </style>