UNPKG

@uva-glass/component-library

Version:

React components UvA

102 lines (101 loc) 3.9 kB
import { jsxs as k, Fragment as v, jsx as n } from "react/jsx-runtime"; import { forwardRef as K, useState as b, useRef as N, useImperativeHandle as T, useLayoutEffect as g } from "react"; import { e as E } from "../../../../../helpers-ChM6xtQG.js"; import { Icon as m } from "../../../../Icon/Icon.js"; import { useTranslation as R } from "../../../hooks/useTranslation.js"; import { Button as y } from "../../../../Buttons/Button.js"; import "../../../../Buttons/LinkButton.js"; import "@react-aria/button"; import '../../../../../assets/LinkContextMenu.css';const a = { "link-context-menu__wrapper": "_link-context-menu__wrapper_1ub2v_1", "link-context-menu__input": "_link-context-menu__input_1ub2v_7", "link-context-menu__button": "_link-context-menu__button_1ub2v_25", "link-context-menu__actions": "_link-context-menu__actions_1ub2v_36" }, O = K(({ url: l, onSave: f, onDelete: h, onClose: x }, w) => { const e = R(), [_, s] = b(l), [c, u] = b(!1), o = N(null), r = () => { var t; s(l), u(!1), (t = o.current) == null || t.blur(); }, C = () => { f(_), r(); }, p = () => { h(), s(""), r(); }, L = () => { r(), x(); }, d = () => { window.open(E(l), "_blank"); }; return T(w, () => ({ clearForm: r })), g(() => { s(l), window.addEventListener("keydown", (t) => { t.ctrlKey && t.shiftKey && t.key === "L" && (u(!0), setTimeout(() => { var i; return (i = o.current) == null ? void 0 : i.focus(); }, 0)), t.ctrlKey && t.shiftKey && t.code === "Digit1" && (d(), setTimeout(() => { var i; return (i = o.current) == null ? void 0 : i.focus(); }, 0)), t.ctrlKey && t.shiftKey && t.key === "Q" && (p(), setTimeout(() => { var i; return (i = o.current) == null ? void 0 : i.focus(); }, 0)); }); }, [l]), /* @__PURE__ */ k(v, { children: [ /* @__PURE__ */ k("div", { className: a["link-context-menu__wrapper"], children: [ /* @__PURE__ */ n( "input", { type: "text", value: _, onChange: (t) => s(t.target.value), className: a["link-context-menu__input"], disabled: !c, ref: o } ), !c && /* @__PURE__ */ n( "button", { type: "button", className: a["link-context-menu__button"], onClick: () => u(!0), title: e.links.linkEdittip, "aria-label": e.aria.labels.link, "aria-keyshortcuts": e.aria.keyshortcuts.editlink, children: /* @__PURE__ */ n(m, { name: "Pencil", size: 20 }) } ), /* @__PURE__ */ n( "button", { type: "button", className: a["link-context-menu__button"], onClick: d, title: e.links.linkTesttip, "aria-label": e.aria.labels.link, "aria-keyshortcuts": e.aria.keyshortcuts.testlink, children: /* @__PURE__ */ n(m, { name: "ArrowTopRightOnSquare", size: 20 }) } ), /* @__PURE__ */ n( "button", { type: "button", className: a["link-context-menu__button"], onClick: p, title: e.links.linkDeletetip, "aria-label": e.aria.labels.link, "aria-keyshortcuts": e.aria.keyshortcuts.deletelink, children: /* @__PURE__ */ n(m, { name: "LinkSlash", size: 20 }) } ) ] }), c && /* @__PURE__ */ k("div", { className: a["link-context-menu__actions"], children: [ /* @__PURE__ */ n(y, { variant: "secondary", onClick: L, "aria-label": e.common.cancel, type: "button", children: e.common.cancel }), /* @__PURE__ */ n(y, { variant: "primary", onClick: C, "aria-label": e.aria.labels.linkOkButton, type: "button", children: e.links.addLink }) ] }) ] }); }); export { O as LinkContextMenu }; //# sourceMappingURL=LinkContextMenu.js.map