<template>
  <DesignPropertiesBox v-if="data.show" style="margin-top: 10px">
    <a-form-item :label="t('标题')" :colon="false" labelAlign="left">
      <a-input v-model:value="data.info.config.title" />
    </a-form-item>
    <a-form-item :label="t('最大行数')" :colon="false" labelAlign="left">
      <a-input-number
        v-model:value="data.info.config.maxRows"
        :min="0"
        :max="100"
        @change="resetDisplay"
      />
    </a-form-item>
  </DesignPropertiesBox>
</template>

<script setup lang="ts">
  import { onMounted, reactive, watch } from 'vue';
  import { DesignPropertiesBox } from '/@/components/Desktop';
  import { todoListInfo } from '../config/info';
  import { TodoListInfo } from '/@/model/mobileDesign/designer';

  import { useI18n } from '/@/hooks/web/useI18n';
  const { t } = useI18n();
  const props = withDefaults(
    defineProps<{
      info: TodoListInfo;
    }>(),
    {
      info: () => {
        return todoListInfo;
      },
    },
  );
  watch(
    () => props.info,
    (val) => {
      if (val) data.info = val;
    },
    {
      deep: true,
    },
  );
  const data: {
    show: boolean;
    info: TodoListInfo;
  } = reactive({
    show: true,
    info: todoListInfo,
  });

  onMounted(() => {
    data.info = props.info;
    data.show = true;
  });
  function resetDisplay() {
    if (data.info.config.renderKey >= 0) {
      data.info.config.renderKey++;
    }
  }
</script>

<style lang="less" scoped></style>
