title: $:/plugins/flibbles/relink/ui/components/tables

\define .make-table(title, plugin, default-table-state:yes)
\whitespace trim

<$list variable="render" filter="[relink:signatures<__plugin__>prefix<__category__>first[]]">
<$vars table-state=<<qualify """$:/state/flibbles/relink/tables/$plugin$""">>>
<tr><th class="tc-relink-header-plugin" colspan=<<column-count>> >
<$reveal type="nomatch" state=<<table-state>> text="yes" default="""$default-table-state$""">
<$button class="tc-btn-invisible tc-btn-dropdown" set=<<table-state>> setTo="yes">
{{$:/core/images/right-arrow}}&#32;$title$
</$button>
</$reveal>
<$reveal type="match" state=<<table-state>> text="yes" default="""$default-table-state$""">
<$button class="tc-btn-invisible tc-btn-dropdown" set=<<table-state>> setTo="no">
{{$:/core/images/down-arrow}}&#32;$title$
</$button>
</$reveal>
</th></tr>
<$list
	variable="signature"
	filter="[relink:signatures<__plugin__>prefix<__category__>sort[]]">
<$vars key={{{ [<signature>removeprefix<__category__>removeprefix[/]] }}} >
<$tiddler tiddler={{{[<signature>relink:source[]]}}} >
<$reveal tag="tr" type="match" state=<<table-state>> text="yes" default="""$default-table-state$""">
<$macrocall $name=<<__list-row-macro__>> signature=<<signature>> />
<td class="tc-relink-column-type">{{||$:/plugins/flibbles/relink/ui/components/select-fieldtype}}</td>
<td class="tc-relink-column-delete">{{||$:/plugins/flibbles/relink/ui/components/button-delete}}</td>
</$reveal>
</$tiddler>
</$vars>
</$list>
</$vars>
</$list>
\end

\define tables(category, list-row-macro, header-list)
\whitespace trim
<$vars
	column-count={{{[enlist<__header-list__>] [[DeleteColumn]] +[count[]]}}}>
<table class="tc-relink-whitelist"><tbody>
<tr>
<$list variable="header" filter="[enlist<__header-list__>butlast[]]"><th><<header>></th></$list>
<!-- We have the last column extend into the delete/link column, which is unlabeled. -->
<th colspan=2><$text text={{{ [enlist<__header-list__>last[]] }}} /></th>
</tr>
<<.make-table Custom "" yes>>

<$list
	filter="[plugin-type[plugin]![$:/core]![$:/plugins/flibbles/relink]]">
<$set name="subtitle"
	filter="[all[current]has[description]]"
	value="''{{!!name}}'':&#32;<$text text={{!!description}}/>"
	emptyValue="''{{!!name}}''" >
<$macrocall $name=".make-table" title=<<subtitle>> plugin=<<currentTiddler>> />
</$set>
</$list>
<<.make-table Core "$:/plugins/flibbles/relink">>

</tbody></table>
</$vars>
\end
