2020-01-29 13:37:25 -06:00
|
|
|
<template>
|
|
|
|
<div class="adhpbeos" :class="{ focused, filled, tall, pre }">
|
|
|
|
<div class="input">
|
|
|
|
<span class="label" ref="label"><slot></slot></span>
|
2020-11-25 06:31:34 -06:00
|
|
|
<textarea ref="input" :class="{ code, _monospace: code }"
|
2020-01-29 13:37:25 -06:00
|
|
|
:value="value"
|
|
|
|
:required="required"
|
|
|
|
:readonly="readonly"
|
|
|
|
:pattern="pattern"
|
|
|
|
:autocomplete="autocomplete"
|
2020-10-24 11:23:23 -05:00
|
|
|
:spellcheck="!code"
|
2020-01-29 13:37:25 -06:00
|
|
|
@input="onInput"
|
|
|
|
@focus="focused = true"
|
|
|
|
@blur="focused = false"
|
|
|
|
></textarea>
|
|
|
|
</div>
|
2020-12-25 19:47:36 -06:00
|
|
|
<button class="save _textButton" v-if="save && changed" @click="() => { changed = false; save(); }">{{ $ts.save }}</button>
|
2020-08-08 23:46:19 -05:00
|
|
|
<div class="desc _caption"><slot name="desc"></slot></div>
|
2020-01-29 13:37:25 -06:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 06:12:00 -05:00
|
|
|
import { defineComponent } from 'vue';
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
export default defineComponent({
|
2020-01-29 13:37:25 -06:00
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
required: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
readonly: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
pattern: {
|
|
|
|
type: String,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
autocomplete: {
|
|
|
|
type: String,
|
|
|
|
required: false
|
|
|
|
},
|
2020-10-24 11:23:23 -05:00
|
|
|
code: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
|
|
|
},
|
2020-01-29 13:37:25 -06:00
|
|
|
tall: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
pre: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
save: {
|
|
|
|
type: Function,
|
|
|
|
required: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
focused: false,
|
|
|
|
changed: false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
filled(): boolean {
|
|
|
|
return this.value != '' && this.value != null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
focus() {
|
|
|
|
this.$refs.input.focus();
|
|
|
|
},
|
|
|
|
onInput(ev) {
|
|
|
|
this.changed = true;
|
2020-10-17 06:12:00 -05:00
|
|
|
this.$emit('update:value', ev.target.value);
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.adhpbeos {
|
|
|
|
margin: 42px 0 32px 0;
|
|
|
|
position: relative;
|
|
|
|
|
2020-02-13 10:24:05 -06:00
|
|
|
&:first-child {
|
|
|
|
margin-top: 16px;
|
|
|
|
}
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
&:last-child {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .input {
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
&:before {
|
|
|
|
content: '';
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
background: none;
|
|
|
|
border: solid 1px var(--inputBorder);
|
|
|
|
border-radius: 3px;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
content: '';
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
background: none;
|
|
|
|
border: solid 2px var(--accent);
|
|
|
|
border-radius: 3px;
|
|
|
|
opacity: 0;
|
|
|
|
transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .label {
|
|
|
|
position: absolute;
|
|
|
|
top: 6px;
|
|
|
|
left: 12px;
|
|
|
|
pointer-events: none;
|
|
|
|
transition: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
|
|
|
|
transition-duration: 0.3s;
|
2020-07-10 20:13:11 -05:00
|
|
|
font-size: 1em;
|
2020-01-29 13:37:25 -06:00
|
|
|
line-height: 32px;
|
|
|
|
pointer-events: none;
|
|
|
|
//will-change transform
|
|
|
|
transform-origin: top left;
|
|
|
|
transform: scale(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
> textarea {
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
min-width: 100%;
|
|
|
|
max-width: 100%;
|
|
|
|
min-height: 130px;
|
|
|
|
padding: 12px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
font: inherit;
|
|
|
|
font-weight: normal;
|
2020-07-10 20:13:11 -05:00
|
|
|
font-size: 1em;
|
2020-01-29 13:37:25 -06:00
|
|
|
background: transparent;
|
|
|
|
border: none;
|
|
|
|
border-radius: 0;
|
|
|
|
outline: none;
|
|
|
|
box-shadow: none;
|
|
|
|
color: var(--fg);
|
2020-10-24 11:23:23 -05:00
|
|
|
|
|
|
|
&.code {
|
|
|
|
tab-size: 2;
|
|
|
|
}
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .save {
|
|
|
|
margin: 6px 0 0 0;
|
2020-08-08 23:46:19 -05:00
|
|
|
font-size: 0.8em;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
> .desc {
|
|
|
|
margin: 6px 0 0 0;
|
|
|
|
|
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
* {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.focused {
|
|
|
|
> .input {
|
|
|
|
&:after {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .label {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.focused,
|
|
|
|
&.filled {
|
|
|
|
> .input {
|
|
|
|
> .label {
|
|
|
|
top: -24px;
|
|
|
|
left: 0 !important;
|
|
|
|
transform: scale(0.75);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.tall {
|
|
|
|
> .input {
|
|
|
|
> textarea {
|
|
|
|
min-height: 200px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.pre {
|
|
|
|
> .input {
|
|
|
|
> textarea {
|
|
|
|
white-space: pre;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|