2018-06-14 06:23:50 -05:00
|
|
|
<template>
|
2018-11-22 17:01:14 -06:00
|
|
|
<div class="ui-select" :class="[{ focused, disabled, filled, inline }, styl]">
|
2018-06-14 06:23:50 -05:00
|
|
|
<div class="icon" ref="icon"><slot name="icon"></slot></div>
|
|
|
|
<div class="input" @click="focus">
|
|
|
|
<span class="label" ref="label"><slot name="label"></slot></span>
|
|
|
|
<div class="prefix" ref="prefix"><slot name="prefix"></slot></div>
|
|
|
|
<select ref="input"
|
2018-11-22 17:01:14 -06:00
|
|
|
:value="v"
|
|
|
|
:required="required"
|
|
|
|
:disabled="disabled"
|
|
|
|
@input="$emit('input', $event.target.value)"
|
|
|
|
@focus="focused = true"
|
|
|
|
@blur="focused = false"
|
|
|
|
>
|
2018-06-14 06:23:50 -05:00
|
|
|
<slot></slot>
|
|
|
|
</select>
|
|
|
|
<div class="suffix"><slot name="suffix"></slot></div>
|
|
|
|
</div>
|
|
|
|
<div class="text"><slot name="text"></slot></div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-22 17:01:14 -06:00
|
|
|
inject: {
|
|
|
|
horizonGrouped: {
|
|
|
|
default: false
|
|
|
|
}
|
|
|
|
},
|
2018-06-14 06:23:50 -05:00
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
required: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
2018-09-28 19:11:06 -05:00
|
|
|
},
|
2018-11-22 17:01:14 -06:00
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
|
|
|
},
|
2018-09-28 19:11:06 -05:00
|
|
|
styl: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: 'line'
|
2018-11-22 17:01:14 -06:00
|
|
|
},
|
|
|
|
inline: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default(): boolean {
|
|
|
|
return this.horizonGrouped;
|
|
|
|
}
|
|
|
|
},
|
2018-06-14 06:23:50 -05:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
v: this.value,
|
2018-09-28 19:11:06 -05:00
|
|
|
focused: false
|
2018-06-14 06:23:50 -05:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
filled(): boolean {
|
|
|
|
return this.v != '' && this.v != null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
value(v) {
|
|
|
|
this.v = v;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (this.$refs.prefix) {
|
|
|
|
this.$refs.label.style.left = (this.$refs.prefix.offsetLeft + this.$refs.prefix.offsetWidth) + 'px';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
focus() {
|
|
|
|
this.$refs.input.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 05:59:19 -05:00
|
|
|
root(fill)
|
2018-06-14 06:23:50 -05:00
|
|
|
margin 32px 0
|
|
|
|
|
|
|
|
> .icon
|
|
|
|
position absolute
|
|
|
|
top 0
|
|
|
|
left 0
|
|
|
|
width 24px
|
|
|
|
text-align center
|
|
|
|
line-height 32px
|
|
|
|
color rgba(#000, 0.54)
|
|
|
|
|
|
|
|
&:not(:empty) + .input
|
|
|
|
margin-left 28px
|
|
|
|
|
|
|
|
> .input
|
|
|
|
display flex
|
|
|
|
|
|
|
|
if fill
|
|
|
|
padding 6px 12px
|
|
|
|
background rgba(#000, 0.035)
|
|
|
|
border-radius 6px
|
|
|
|
else
|
|
|
|
&:before
|
|
|
|
content ''
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
bottom 0
|
|
|
|
left 0
|
|
|
|
right 0
|
|
|
|
height 1px
|
2018-09-27 08:50:34 -05:00
|
|
|
background var(--inputBorder)
|
2018-06-14 06:23:50 -05:00
|
|
|
|
|
|
|
&:after
|
|
|
|
content ''
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
bottom 0
|
|
|
|
left 0
|
|
|
|
right 0
|
|
|
|
height 2px
|
2018-09-26 06:19:35 -05:00
|
|
|
background var(--primary)
|
2018-06-14 06:23:50 -05:00
|
|
|
opacity 0
|
|
|
|
transform scaleX(0.12)
|
|
|
|
transition border 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)
|
|
|
|
will-change border opacity transform
|
|
|
|
|
|
|
|
> .label
|
|
|
|
position absolute
|
|
|
|
top fill ? 6px : 0
|
|
|
|
left 0
|
|
|
|
pointer-events none
|
|
|
|
transition 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)
|
|
|
|
transition-duration 0.3s
|
|
|
|
font-size 16px
|
|
|
|
line-height 32px
|
2018-11-22 17:01:14 -06:00
|
|
|
color var(--inputLabel)
|
2018-06-14 06:23:50 -05:00
|
|
|
pointer-events none
|
|
|
|
//will-change transform
|
|
|
|
transform-origin top left
|
|
|
|
transform scale(1)
|
|
|
|
|
|
|
|
> select
|
|
|
|
display block
|
|
|
|
flex 1
|
|
|
|
width 100%
|
|
|
|
padding 0
|
|
|
|
font inherit
|
|
|
|
font-weight fill ? bold : normal
|
|
|
|
font-size 16px
|
|
|
|
height 32px
|
2018-09-27 08:50:34 -05:00
|
|
|
color var(--inputText)
|
2018-06-14 06:23:50 -05:00
|
|
|
background transparent
|
|
|
|
border none
|
|
|
|
border-radius 0
|
|
|
|
outline none
|
|
|
|
box-shadow none
|
|
|
|
|
2018-06-14 17:56:56 -05:00
|
|
|
*
|
|
|
|
color #000
|
2018-06-14 06:23:50 -05:00
|
|
|
|
|
|
|
> .prefix
|
|
|
|
> .suffix
|
|
|
|
display block
|
|
|
|
align-self center
|
|
|
|
justify-self center
|
|
|
|
font-size 16px
|
|
|
|
line-height 32px
|
|
|
|
color rgba(#000, 0.54)
|
|
|
|
pointer-events none
|
|
|
|
|
|
|
|
> *
|
|
|
|
display block
|
|
|
|
min-width 16px
|
|
|
|
|
|
|
|
> .prefix
|
|
|
|
padding-right 4px
|
|
|
|
|
|
|
|
> .suffix
|
|
|
|
padding-left 4px
|
|
|
|
|
|
|
|
> .text
|
|
|
|
margin 6px 0
|
|
|
|
font-size 13px
|
|
|
|
|
2018-11-22 17:01:14 -06:00
|
|
|
&:empty
|
|
|
|
display none
|
|
|
|
|
2018-06-14 06:23:50 -05:00
|
|
|
*
|
|
|
|
margin 0
|
|
|
|
|
|
|
|
&.focused
|
|
|
|
> .input
|
|
|
|
if fill
|
|
|
|
background rgba(#000, 0.05)
|
|
|
|
else
|
|
|
|
&:after
|
|
|
|
opacity 1
|
|
|
|
transform scaleX(1)
|
|
|
|
|
|
|
|
> .label
|
2018-09-26 06:19:35 -05:00
|
|
|
color var(--primary)
|
2018-06-14 06:23:50 -05:00
|
|
|
|
|
|
|
&.focused
|
|
|
|
&.filled
|
|
|
|
> .input
|
|
|
|
> .label
|
2018-06-14 07:38:39 -05:00
|
|
|
top fill ? -24px : -17px
|
2018-06-14 06:23:50 -05:00
|
|
|
left 0 !important
|
2018-06-14 07:38:39 -05:00
|
|
|
transform scale(0.75)
|
2018-06-14 06:23:50 -05:00
|
|
|
|
2018-09-28 05:59:19 -05:00
|
|
|
.ui-select
|
2018-06-14 06:23:50 -05:00
|
|
|
&.fill
|
2018-09-28 05:59:19 -05:00
|
|
|
root(true)
|
2018-06-14 06:23:50 -05:00
|
|
|
&:not(.fill)
|
2018-09-28 05:59:19 -05:00
|
|
|
root(false)
|
2018-06-14 06:23:50 -05:00
|
|
|
|
2018-11-22 17:01:14 -06:00
|
|
|
&.inline
|
|
|
|
display inline-block
|
|
|
|
margin 0
|
|
|
|
|
|
|
|
&.disabled
|
|
|
|
opacity 0.7
|
|
|
|
|
|
|
|
&, *
|
|
|
|
cursor not-allowed !important
|
|
|
|
|
2018-06-14 06:23:50 -05:00
|
|
|
</style>
|