1- import { TemplateOptions } from "../template" ;
1+ import { TagStyle , TemplateOptions } from "../template" ;
22import { Commit , CommitRenderOptions , CommitOptions } from "../commit" ;
33import {
44 Branch ,
@@ -10,7 +10,12 @@ import { GitgraphCore } from "../gitgraph";
1010import { Refs } from "../refs" ;
1111import { BranchUserApi } from "./branch-user-api" ;
1212
13- export { GitgraphCommitOptions , GitgraphBranchOptions , GitgraphUserApi } ;
13+ export {
14+ GitgraphCommitOptions ,
15+ GitgraphBranchOptions ,
16+ GitgraphTagOptions ,
17+ GitgraphUserApi ,
18+ } ;
1419
1520interface GitgraphCommitOptions < TNode > extends CommitRenderOptions < TNode > {
1621 author ?: string ;
@@ -26,10 +31,11 @@ interface GitgraphCommitOptions<TNode> extends CommitRenderOptions<TNode> {
2631 onMouseOut ?: ( commit : Commit < TNode > ) => void ;
2732}
2833
29- interface GitgraphTagOptions {
34+ interface GitgraphTagOptions < TNode > {
3035 name : string ;
31- ref ?: Commit [ "hash" ] | Branch [ "name" ] ;
3236 style ?: TemplateOptions [ "tag" ] ;
37+ ref ?: Commit [ "hash" ] | Branch [ "name" ] ;
38+ render ?: ( name : string , style : TagStyle ) => TNode ;
3339}
3440
3541interface GitgraphBranchOptions < TNode > extends BranchRenderOptions < TNode > {
@@ -113,29 +119,32 @@ class GitgraphUserApi<TNode> {
113119 *
114120 * @param options Options of the tag
115121 */
116- public tag ( options : GitgraphTagOptions ) : this;
122+ public tag ( options : GitgraphTagOptions < TNode > ) : this;
117123 /**
118124 * Tag a specific commit.
119125 *
120126 * @param name Name of the tag
121127 * @param ref Commit or branch name or commit hash
122128 */
123129 public tag (
124- name : GitgraphTagOptions [ "name" ] ,
125- ref ?: GitgraphTagOptions [ "ref" ] ,
130+ name : GitgraphTagOptions < TNode > [ "name" ] ,
131+ ref ?: GitgraphTagOptions < TNode > [ "ref" ] ,
126132 ) : this;
127133 public tag ( ...args : any [ ] ) : this {
128134 // Deal with shorter syntax
129- let name : GitgraphTagOptions [ "name" ] ;
130- let ref : GitgraphTagOptions [ "ref" ] ;
131- let style : GitgraphTagOptions [ "style" ] ;
135+ let name : GitgraphTagOptions < TNode > [ "name" ] ;
136+ let ref : GitgraphTagOptions < TNode > [ "ref" ] ;
137+ let style : GitgraphTagOptions < TNode > [ "style" ] ;
138+ let render : GitgraphTagOptions < TNode > [ "render" ] ;
139+
132140 if ( typeof args [ 0 ] === "string" ) {
133141 name = args [ 0 ] ;
134142 ref = args [ 1 ] ;
135143 } else {
136144 name = args [ 0 ] . name ;
137145 ref = args [ 0 ] . ref ;
138146 style = args [ 0 ] . style ;
147+ render = args [ 0 ] . render ;
139148 }
140149
141150 if ( ! ref ) {
@@ -162,6 +171,7 @@ class GitgraphUserApi<TNode> {
162171
163172 this . _graph . tags . set ( name , commitHash ) ;
164173 this . _graph . tagStyles [ name ] = style ;
174+ this . _graph . tagRenders [ name ] = render ;
165175 this . _onGraphUpdate ( ) ;
166176 return this ;
167177 }
0 commit comments