<template>
  <section class="AiSearchBar" :class="{bottomBorder,isSingleRow,expand}">
    <div class="left">
      <div class="flex wrap content">
        <slot name="left"/>
      </div>
    </div>
    <div class="right" v-if="$slots.right">
      <slot name="right"/>
    </div>
    <ai-pull-down v-if="!isSingleRow" v-model="expand"/>
  </section>
</template>

<script>
export default {
  name: "AiSearchBar",
  props: {
    bottomBorder: Boolean,
    size: {default: "small"}
  },
  computed: {
    isSingleRow: v => v.height <= 45
  },
  data() {
    return {
      height: 0,
      expand: false
    }
  },
  mounted() {
    this.height = this.$el.querySelector(".left .content").getBoundingClientRect().height
  },
}
</script>

<style lang="scss" scoped>
.AiSearchBar {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  padding-bottom: 32px;
  position: relative;
  height: 64px;
  overflow: hidden;

  &.isSingleRow {
    height: 44px;
    padding-bottom: 12px;
  }

  &.bottomBorder {
    border-bottom: 1px solid #eee;
  }

  &.expand {
    height: auto;
    .left{
      height: auto;
    }
  }

  .left {
    padding-top: 1px;
    height: 33px;
    overflow: hidden;

    .content {
      gap: 8px;
    }
  }

  :deep(.right ) {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    align-self: flex-start;
    width: 280px;

    .el-input {
      width: 280px;
    }

    * + button, * + div, * + section {
      margin-left: 8px;
    }
  }

  .el-input {
    width: auto;
  }
}

:deep( .searchLeftZone > .el-button), :deep( .searchRightZone > .el-button ) {
  margin-left: 0;
}
</style>
