<template>
  <el-row :gutter="12">
    <el-col v-if="!hideLineHeight" :span="hideLetterSpacing ? 24 : 12">
      <el-form-item label="" label-position="left" label-width="0px">
        <input-number
          v-model="lineHeight"
          controls-position="right"
          style="width: 100%"
          :min="-100"
          :max="100"
        >
          <template #prefix>
            <span>行</span>
          </template>
        </input-number>
      </el-form-item>
    </el-col>
    <el-col v-if="!hideLetterSpacing" :span="hideLineHeight ? 24 : 12">
      <el-form-item label="" label-position="left" label-width="0px">
        <input-number
          v-model="letterSpacing"
          controls-position="right"
          style="width: 100%"
          :min="-100"
          :max="100"
        >
          <template #prefix>
            <span>字</span>
          </template>
        </input-number>
      </el-form-item>
    </el-col>
  </el-row>
</template>

<script setup lang="ts">
import { computed } from 'vue'

const modelValue = defineModel<{
  letterSpacing: number
  lineHeight: number
}>('modelValue')

defineProps<{
  hideLetterSpacing?: boolean
  hideLineHeight?: boolean
}>()

// letterSpacing
const letterSpacing = computed({
  get: () => modelValue.value?.letterSpacing,
  set: (val: number) => {
    if (modelValue.value) {
      modelValue.value.letterSpacing = val
    }
  }
})

// lineHeight
const lineHeight = computed({
  get: () => modelValue.value?.lineHeight,
  set: (val: number) => {
    if (modelValue.value) {
      modelValue.value.lineHeight = val
    }
  }
})
</script>

<style scoped></style>
