| 31 | * infrastructure), as well as building the framework of DOM elements for all Components. |
| 32 | */ |
| 33 | export class Component { |
| 34 | /** |
| 35 | * Holds all the DOM associated with this component. A direct child of the element we're |
| 36 | * anchored to. |
| 37 | */ |
| 38 | private _element: d3.Selection<HTMLElement, any, any, any>; |
| 39 | /** |
| 40 | * Container for the visual content that this Component displays. Subclasses should attach |
| 41 | * elements onto the _content. Located in between the background and the foreground. |
| 42 | */ |
| 43 | private _content: SimpleSelection<void>; |
| 44 | /** |
| 45 | * Place more objects just behind this Component's Content by appending them to the _backgroundContainer. |
| 46 | */ |
| 47 | private _backgroundContainer: SimpleSelection<void>; |
| 48 | /** |
| 49 | * Place more objects just in front of this Component's Content by appending them to the _foregroundContainer. |
| 50 | */ |
| 51 | private _foregroundContainer: SimpleSelection<void>; |
| 52 | /** |
| 53 | * Subclasses should set this to true in their constructor to prevent content from overflowing. |
| 54 | */ |
| 55 | protected _overflowHidden = false; |
| 56 | private _resizeHandler: IResizeHandler; |
| 57 | /** |
| 58 | * Origin of this Component relative to its parent. |
| 59 | */ |
| 60 | private _origin: Point = { x: 0, y: 0 }; |
| 61 | |
| 62 | /** |
| 63 | * The ComponentContainer that holds this Component in its children, or null, if this |
| 64 | * Component is top-level. |
| 65 | */ |
| 66 | private _parent: ComponentContainer; |
| 67 | private _xAlignment: XAlignment = "left"; |
| 68 | private static _xAlignToProportion: { [P in XAlignment]: number } = { |
| 69 | left: 0, |
| 70 | center: 0.5, |
| 71 | right: 1, |
| 72 | }; |
| 73 | private _yAlignment: YAlignment = "top"; |
| 74 | private static _yAlignToProportion: { [P in YAlignment]: number } = { |
| 75 | top: 0, |
| 76 | center: 0.5, |
| 77 | bottom: 1, |
| 78 | }; |
| 79 | protected _isSetup = false; |
| 80 | protected _isAnchored = false; |
| 81 | |
| 82 | /** |
| 83 | * If we're the root Component (top-level), this is the HTMLElement we've anchored to (user-supplied). |
| 84 | */ |
| 85 | private _rootElement: d3.Selection<HTMLElement, any, any, any>; |
| 86 | /** |
| 87 | * width of the Component as computed in computeLayout. Used to size the hitbox, bounding box, etc |
| 88 | */ |
| 89 | private _width: number; |
| 90 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected