/*! * Copyright (c) 2023, 2026, Oracle and/or its affiliates. */ /** * @file * * Contains the model of the single-color circle element with no text, just glyph. */ import { isSafari } from "../../utils/browser.mjs"; import Element from "./Element.mjs"; export default class TerminatorElement extends Element { preinitialize() { super.preinitialize( ...arguments ); this.markup = [{ tagName: "circle", selector: "body" }, { tagName: "text", selector: "glyph" }, { tagName: "g", selector: "statusIconContainer", children: [{ tagName: "circle", selector: "statusIconBackground" }, { tagName: "text", selector: "statusIcon" }] }]; Object.defineProperty( this, "safari", { value: isSafari(), enumerable: true } ); } defaults() { const safari = this.safari; return { ...super.defaults(), type: "apex.Terminator", size: { width: 60, height: 60 }, attrs: { body: { cx: "calc(h / 2)", cy: "calc(h / 2)", r: "calc(h / 2)", fill: "var(--a-diagram-element-terminator-background-color, #000)" }, glyph: { text: "", fontFamily: "apex-core-font", fontSize: "calc(h / 2)", width: "calc(h)", x: "calc(h / 2)", y: "calc(h / 2)", textAnchor: "middle", ...( !safari && { dominantBaseline: "central" } ), // We are unable to position the icon with dominantBaseline or textVerticalAnchor // in Safari. Considering the Terminator never changes size, let's just hardcode // the y value. ...( safari && { y: 43 } ), fill: "var(--a-diagram-element-terminator-text-color, #fff)" }, statusIconContainer: { display: "none", transform: "translate(calc(w - 10) 10)" }, statusIconBackground: { x: 10, y: 10, r: 10, fill: "var(--a-diagram-element-terminator-status-icon-background-color, #fff)", stroke: "var(--a-diagram-element-terminator-background-color, #000)" }, statusIcon: { text: "", fontFamily: "apex-core-font", fontSize: 14, width: 20, x: 0, // We are unable to position the icon with dominantBaseline or textVerticalAnchor // in Safari. y: this.safari ? 6 : 0, textAnchor: "middle", ...( !safari && { dominantBaseline: "central" } ), fill: "#000000", dataTooltip: null } } }; } initialize() { super.initialize( ...arguments ); // ensure that the status icon container is not hidden after init if there is a glyph set this.attr( "statusIconContainer/display", this.statusIcon() === "" ? "none" : "", { silent: true } ); } changeToRtl( attrs ) { attrs.statusIconContainer.transform = "translate(10 10)"; } statusIcon( icon = "" ) { if ( arguments.length ) { icon = icon == null ? "" : icon; this.attr( "statusIconContainer/display", icon === "" ? "none" : "" ); return this.attr( "statusIcon/text", icon ); } return this.attr( "statusIcon/text" ); } }