DynField = {
    template: "#DynField",
    router_path: "/",
    delimiters: ["[[", "]]"],
    props: {
        field: {
            default: null,
        },
        item: {
            default: function() {
                return {}
            },
        }
    },

    data: function() {
        return {
            test: null,
            modal: null,
            rules: {
                required: value => !!value || "{{_('Required') | escapejs}}",
                email: value => {
                    const pattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
                    return pattern.test(value) || "{{_('Invalid E-mail') | escapejs}}"
                },
                uuid: value => {
                    const pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
                    return pattern.test(value) || "{{_('Invalid UUID') | escapejs}}"
                },
                ipv4: value => {
                    const pattern = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/
                    return pattern.test(value) || "{{_('Invalid IPv4') | escapejs}}"
                },
            },
        }
    },

    computed: {
        field_type: function() {
            if (this.item?.property?.type == undefined) {
                return "v-textarea"
            }

            return this.item?.property?.type
        },
    }
}
