11const makeTableHead = headers => `<thead><th class="tui-grid-cell-head">${ headers . join ( '</th><th class="tui-grid-cell-head">' ) } </th></thead>` ;
22const makeTableBody = ( items , cb ) => `<tbody>${ items . map ( item => `<tr>${ cb ( item ) . trim ( ) } </tr>` ) . join ( '' ) } </tbody>` ;
3+ const renderTypes = require ( './utils/renderTypes' ) ;
34
45module . exports = function renderTui ( description , props = [ ] , data = [ ] , computed = [ ] ) {
56 let html = description ;
@@ -36,7 +37,7 @@ module.exports = function renderTui(description, props = [], data = [], computed
3637 html += makeTableHead ( [ 'Name' , 'Type' , 'Default value' , 'Required ?' , 'Description' ] ) ;
3738 html += makeTableBody ( props , item => `
3839 <td class="tui-grid-cell"><b>${ item . name } </b></td>
39- <td class="tui-grid-cell">${ ( item . type . names || [ ] ) . join ( ', ' ) } </td>
40+ <td class="tui-grid-cell">${ renderTypes ( item . type . names || [ ] ) } </td>
4041 <td class="tui-grid-cell">${ typeof item . defaultvalue === 'undefined' ? '-' : `<code>${ item . defaultvalue } </code>` } </td>
4142 <td class="tui-grid-cell">${ item . optional ? 'No' : '<b>Yes</b>' } </td>
4243 <td class="tui-grid-cell">${ typeof item . description === 'undefined' ? '-' : item . description } </td>
@@ -50,7 +51,7 @@ module.exports = function renderTui(description, props = [], data = [], computed
5051 html += makeTableHead ( [ 'Name' , 'Type' , 'Default value' , 'Description' ] ) ;
5152 html += makeTableBody ( data , item => `
5253 <td class="tui-grid-cell"><b>${ item . name } </b></td>
53- <td class="tui-grid-cell">${ ( item . type . names || [ ] ) . join ( ', ' ) } </td>
54+ <td class="tui-grid-cell">${ renderTypes ( item . type . names || [ ] ) } </td>
5455 <td class="tui-grid-cell">${ typeof item . defaultvalue === 'undefined' ? '-' : `<code>${ item . defaultvalue } </code>` } </td>
5556 <td class="tui-grid-cell">${ typeof item . description === 'undefined' ? '-' : item . description } </td>
5657 ` ) ;
@@ -63,7 +64,7 @@ module.exports = function renderTui(description, props = [], data = [], computed
6364 html += makeTableHead ( [ 'Name' , 'Type' , 'Description' ] ) ;
6465 html += makeTableBody ( computed , item => `
6566 <td class="tui-grid-cell"><b>${ item . name } </b></td>
66- <td class="tui-grid-cell">${ ( item . type . names || [ ] ) . join ( ', ' ) } </td>
67+ <td class="tui-grid-cell">${ renderTypes ( item . type . names || [ ] ) } </td>
6768 <td class="tui-grid-cell">${ typeof item . description === 'undefined' ? '-' : item . description } </td>
6869 ` ) ;
6970 html += '</table>' ;
0 commit comments