/** @odoo-module */ import { Component, useState, xml } from "@odoo/owl"; import { copy, hasClipboard } from "../hoot_utils"; /** * @typedef {{ * altText?: string; * text: string; * }} HootCopyButtonProps */ /** @extends {Component} */ export class HootCopyButton extends Component { static props = { altText: { type: String, optional: true }, text: String, }; static template = xml` `; hasClipboard = hasClipboard; setup() { this.state = useState({ copied: false }); } /** * @param {PointerEvent} ev */ async onClick(ev) { const text = ev.altKey && this.props.altText ? this.props.altText : this.props.text; await copy(text); this.state.copied = true; } }