<template>
  <div class="search">
    <div class="flex">
      <el-input class="search-input" @clear="clear" clearable v-model="input" size="default" :placeholder="placeholder" :prefix-icon="Search" />
      <el-button color="#ac014d" class="search-button" size="default" @click="search" >搜索</el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { Search } from "@element-plus/icons-vue";
const props = defineProps({
  placeholder: {
    type: String,
    default: "请输入您要搜索的内容",
  },
});
const emits = defineEmits(["clear", "search"]);
const { placeholder } = props;
const input = ref("");
const clear = () => {
  emits("clear");
};
const search = () => {
  emits("search", input.value);
};
</script>

<style lang="scss" scoped>
.search {
  &-input {
    width: 240px;
    margin-right: 12px;
    box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  }
  &-button {
    margin-right: 16px;
  }
}
</style>