index.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <template>
  2. <div :style="{width, fontWeight, fontSize, textAlign}" v-textarea="modelValue"></div>
  3. </template>
  4. <script>
  5. import { useFormInput } from '@cip/components/hooks/form-input'
  6. import { formInputProps } from '../../form-input-props'
  7. import { computed } from 'vue'
  8. import TextareaDirective from '../../../directives/textarea'
  9. export default {
  10. props: formInputProps,
  11. emits: ['update:modelValue'],
  12. directives: { [TextareaDirective.name]: TextareaDirective },
  13. setup (props, context) {
  14. const { width, ...formInput } = useFormInput(props, context)
  15. const fontWeight = computed(() => {
  16. return props.config.fontWeight ?? 'normal'
  17. })
  18. const fontSize = computed(() => {
  19. return props.config.fontSize + 'px' ?? '12px'
  20. })
  21. const textAlign = computed(() => {
  22. return props.config.textAlign ?? 'left'
  23. })
  24. return {
  25. ...formInput,
  26. ...context.attrs,
  27. width,
  28. fontWeight,
  29. fontSize,
  30. textAlign
  31. }
  32. }
  33. }
  34. </script>