<template>
  <section class="AiItem" :class="{border}">
    <div v-if="topLabel" class="topLabel">
      <div class="labelPane" flex>
        <div class="label" :class="{required,labelBold}" v-text="label"/>
        <slot name="sub" v-if="$scopedSlots.sub"/>
      </div>
      <div class="content">
        <slot v-if="$scopedSlots.default"/>
        <div v-else v-text="value"/>
      </div>
    </div>
    <div v-else class="normal" flex>
      <div class="fill" flex>
        <div class="label" :class="{required,labelBold}" v-text="label"/>
        <slot name="sub" v-if="$scopedSlots.sub"/>
      </div>
      <div class="flexContent">
        <slot v-if="$scopedSlots.default"/>
        <div v-else v-text="value"/>
      </div>
    </div>
  </section>
</template>

<script>
export default {
  name: "AiItem",
  props: {
    value: {default: ""},
    label: {default: ""},
    required: Boolean,
    topLabel: Boolean,
    border: {default: true},
    labelBold: Boolean
  },
  data() {
    return {}
  }
}
</script>

<style lang="scss" scoped>
.AiItem {
  font-family: PingFangSC-Regular, PingFang SC;
  width: 100%;

  &.border {
    .normal {
      border-bottom: 2px solid #ddd;
    }

    .topLabel {
      border-bottom: 2px solid #ddd;
    }
  }

  .normal {
    width: 100%;
    padding-right: 32px;
    box-sizing: border-box;
    height: 112px;

    .flexContent {
      max-width: 62vw;

      input {
        text-align: right;
      }
    }
  }

  .label {
    padding-left: 20px;
    font-weight: 400;
    color: #333333;
    margin-right: 20px;
    position: relative;

    &.required:before {
      position: absolute;
      display: block;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      content: "*";
      color: #f46;
    }

    &.labelBold {
      font-weight: bold;
      font-size: 34px;
    }
  }

  ::v-deep.topLabel {
    padding: 32px 32px 32px 0;

    .labelPane {
      margin-bottom: 32px;
    }

    .content {
      padding-left: 20px;

      .AiMore > .u-icon {
        width: 100%;
      }
    }
  }
}
</style>
