UNPKG

@kit-data-manager/pid-component

Version:

The PID-Component is a web component that can be used to evaluate and display FAIR Digital Objects, PIDs, ORCiDs, and possibly other identifiers in a user-friendly way. It is easily extensible to support other identifier types.

44 lines (43 loc) 2.11 kB
/*! * * Copyright 2024 Karlsruhe Institute of Technology. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import { h } from "@stencil/core"; import { GenericIdentifierType } from "../utils/GenericIdentifierType"; export class EmailType extends GenericIdentifierType { getSettingsKey() { return 'EmailType'; } hasCorrectFormat() { const regex = /^(([\w\-.]+@([\w-]+\.)+[\w-]{2,})(\s*,\s*)?)*$/gm; return regex.test(this.value); } init() { return; } isResolvable() { return false; } renderPreview() { return (h("span", { class: 'items-center' }, this.value .split(new RegExp(/\s*,\s*/)) .filter(email => email.length > 0) .map(email => { return (h("a", { href: 'mailto:' + email, rel: 'noopener noreferrer', target: "_blank", class: 'items-center inline-flex font-mono text-sm text-blue-400 border border-slate-400 bg-white/60 rounded-md px-1 py-0.5' }, h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", "aria-hidden": "true", viewBox: "0 0 24 24", "stroke-width": "1", stroke: "black", height: "20px", class: 'mr-2' }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M21.75 6.75v10.5a2.25 2.25 0 0 1-2.25 2.25h-15a2.25 2.25 0 0 1-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25m19.5 0v.243a2.25 2.25 0 0 1-1.07 1.916l-7.5 4.615a2.25 2.25 0 0 1-2.36 0L3.32 8.91a2.25 2.25 0 0 1-1.07-1.916V6.75" })), h("span", { class: 'ml-2' }, email))); }))); } } //# sourceMappingURL=EmailType.js.map