<template>
	<view><slot></slot></view>
</template>

<script>
/**
 * 表单组件
 * @description 表单组件
 * @property {String} labelWidth label宽度
 * @property {String} labelPosition = [left | top] label位置
 * @property {String} labelAlign = [left | center | right | justify] label对齐方式
 * @property {String} errorType = [toast | message] 错误提示类型
 * @property {Object} model 数据对象，表单校验时用
 */
export default {
	name: 'fs-form'
}
</script>

<script setup>
import { provide } from 'vue'

const props = defineProps({
	labelWidth: {
		type: String,
		default: '120rpx'
	},
	labelPosition: {
		type: String,
		default: 'left',
		validator(value) {
			return ['left', 'top'].includes(value)
		}
	},
	labelAlign: {
		type: String,
		default: 'left',
		validator(value) {
			return ['left', 'center', 'right', 'justify'].includes(value)
		}
	},
	errorType: {
		type: String,
		default: 'toast',
		validator(value) {
			return ['toast', 'message'].includes(value)
		}
	},
	model: Object
})

provide('form', props)

defineExpose({
	model: props.model,
	errorType: props.errorType
})
</script>

<style lang="scss"></style>
