2021-08-17 17:01:11 -05:00
|
|
|
<template>
|
|
|
|
<div class="w-full">
|
2022-08-15 17:35:13 -05:00
|
|
|
<slot>
|
2025-01-06 20:00:42 -07:00
|
|
|
<label :for="identifier" class="px-1 text-sm font-semibold" :class="{ 'text-gray-400': disabled }">
|
|
|
|
{{ label }}
|
|
|
|
<em v-if="note" class="font-normal text-xs pl-2">{{ note }}</em>
|
|
|
|
</label>
|
2022-08-15 17:35:13 -05:00
|
|
|
</slot>
|
2025-02-06 17:27:33 -06:00
|
|
|
<ui-text-input :placeholder="placeholder || label" :inputId="identifier" ref="input" v-model="inputValue" :disabled="disabled" :readonly="readonly" :type="type" :show-copy="showCopy" class="w-full" :class="inputClass" :trim-whitespace="trimWhitespace" @blur="inputBlurred" />
|
2021-08-17 17:01:11 -05:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: [String, Number],
|
|
|
|
label: String,
|
2024-03-19 17:57:24 +01:00
|
|
|
placeholder: String,
|
2021-09-13 20:18:58 -05:00
|
|
|
note: String,
|
2021-08-19 19:14:24 -05:00
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
default: 'text'
|
|
|
|
},
|
2022-03-19 06:41:54 -05:00
|
|
|
readonly: Boolean,
|
2022-09-03 08:06:52 -05:00
|
|
|
disabled: Boolean,
|
2025-01-22 17:56:46 -06:00
|
|
|
inputClass: String,
|
2025-02-06 17:27:33 -06:00
|
|
|
showCopy: Boolean,
|
|
|
|
trimWhitespace: Boolean
|
2021-08-17 17:01:11 -05:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
inputValue: {
|
|
|
|
get() {
|
|
|
|
return this.value
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$emit('input', val)
|
|
|
|
}
|
2022-12-29 05:00:40 +01:00
|
|
|
},
|
|
|
|
identifier() {
|
|
|
|
return Math.random().toString(36).substring(2)
|
2021-08-17 17:01:11 -05:00
|
|
|
}
|
|
|
|
},
|
2022-02-17 14:33:12 -06:00
|
|
|
methods: {
|
2022-08-03 18:38:08 -05:00
|
|
|
setFocus() {
|
|
|
|
if (this.$refs.input && this.$refs.input.setFocus) {
|
|
|
|
this.$refs.input.setFocus()
|
|
|
|
}
|
|
|
|
},
|
2022-02-17 14:33:12 -06:00
|
|
|
blur() {
|
|
|
|
if (this.$refs.input && this.$refs.input.blur) {
|
|
|
|
this.$refs.input.blur()
|
|
|
|
}
|
2022-04-14 17:15:52 -05:00
|
|
|
},
|
|
|
|
inputBlurred() {
|
|
|
|
this.$emit('blur')
|
2022-02-17 14:33:12 -06:00
|
|
|
}
|
|
|
|
},
|
2021-08-17 17:01:11 -05:00
|
|
|
mounted() {}
|
|
|
|
}
|
2025-01-06 20:00:42 -07:00
|
|
|
</script>
|