Sha256: 0f3dca0cfc7221d17e6bf6820f349645b24a1e9593ccfe6e40ead3b07a78d372

Contents?: true

Size: 1.33 KB

Versions: 17

Compression:

Stored size: 1.33 KB

Contents

<template>
  <div>
    <label
      class="block font-semibold text-gray-800 flex justify-between items-center"
    >
      <span>{{ label }}</span>
      <span
        v-if="maxLength"
        class="text-xs"
        :class="{
          'text-red-600': isOverMaxLength,
          'text-gray-600': !isOverMaxLength,
        }"
        >{{ numCharacters }} / {{ maxLength }}</span
      >
    </label>
    <textarea
      :value="value"
      @blur="blur()"
      @input="updateInput"
      class="block w-full mt-1 py-2 px-3 rounded bg-gray-100 text-gray-800 focus:outline-none focus:ring"
      autocomplete="off"
      ref="input"
      :rows="rows"
    />
  </div>
</template>

<script>
import FocusedInputMixin from '@/mixins/focused-input'

export default {
  name: 'TextInput',
  mixins: [FocusedInputMixin],
  props: {
    label: { type: String, default: 'Label' },
    name: { type: String, default: 'text' },
    value: { type: String },
    maxLength: { type: Number, default: null },
    rows: { type: Number, default: 2 },
  },
  computed: {
    numCharacters() {
      return (this.value || '').length
    },
    isOverMaxLength() {
      return this.numCharacters > this.maxLength
    },
  },
  methods: {
    updateInput(event) {
      this.$emit('input', event.target.value)
    },
    focus() {
      this.$refs.input.focus()
    },
  },
}
</script>

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
maglevcms-1.4.0 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.3.0 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.2.2 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.2.1 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.2.0 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.1.7 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.1.6 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.1.5 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.1.4 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.1.3 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.1.2 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.1.1 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.1.0 app/frontend/editor/components/kit/textarea-input.vue
maglevcms-1.0.0 app/javascript/editor/components/kit/textarea-input.vue
maglevcms-1.0.0.rc3 app/javascript/editor/components/kit/textarea-input.vue
maglevcms-1.0.0.rc2 app/javascript/editor/components/kit/textarea-input.vue
maglevcms-1.0.0.rc1 app/javascript/editor/components/kit/textarea-input.vue