@@ -3,7 +3,7 @@ import {createSafeHtmlWithoutSanitize as clientCreateSafeHtmlWithoutSanitize} fr
33import { ApiStatisticsItem as clientApiStatisticsItem } from './ApiStatisticsItem' ;
44
55import type {
6- ApiStatistics ,
6+ ApiStatistics as ApiStatisticsType ,
77 ApiStatisticsReportHash ,
88 ObjectEntries ,
99 SafeHtml ,
@@ -12,8 +12,10 @@ import type {
1212const createSafeHtmlWithoutSanitize = clientCreateSafeHtmlWithoutSanitize ;
1313const ApiStatisticsItem = clientApiStatisticsItem ;
1414
15- type Options = Readonly < {
16- apiStatistics : ApiStatistics ;
15+ declare const jsx : JSX . Runtime ;
16+
17+ type Props = Readonly < {
18+ apiStatistics : ApiStatisticsType ;
1719 hash : ApiStatisticsReportHash ;
1820} > ;
1921
@@ -22,7 +24,7 @@ type Options = Readonly<{
2224 * This base client function should not use scope variables (except other base functions).
2325 * @internal
2426 */
25- export function renderApiStatistics ( { apiStatistics, hash} : Options ) : SafeHtml {
27+ export const ApiStatistics : JSX . Component < Props > = ( { apiStatistics, hash} ) => {
2628 let header : string | undefined ;
2729 const items : SafeHtml [ ] = [ ] ;
2830
@@ -38,11 +40,13 @@ export function renderApiStatistics({apiStatistics, hash}: Options): SafeHtml {
3840 pageCount += count ;
3941 pageDuration += duration ;
4042
41- pageItems . push ( ApiStatisticsItem ( { count, duration, name : url , url} ) ) ;
43+ pageItems . push (
44+ < ApiStatisticsItem count = { count } duration = { duration } name = { url } url = { url } /> ,
45+ ) ;
4246 }
4347
4448 items . push (
45- ApiStatisticsItem ( { count : pageCount , duration : pageDuration , isHeader : true , name} ) ,
49+ < ApiStatisticsItem count = { pageCount } duration = { pageDuration } isHeader = { true } name = { name } /> ,
4650 ) ;
4751 items . push ( ...pageItems ) ;
4852 }
@@ -54,12 +58,12 @@ export function renderApiStatistics({apiStatistics, hash}: Options): SafeHtml {
5458 // eslint-disable-next-line max-depth
5559 for ( const [ statusCode , { count, duration, size} ] of Object . entries ( byStatusCode ) ) {
5660 items . push (
57- ApiStatisticsItem ( {
58- count,
59- duration,
60- name : `${ method } ${ url } ${ statusCode } ` ,
61- size,
62- } ) ,
61+ < ApiStatisticsItem
62+ count = { count }
63+ duration = { duration }
64+ name = { `${ method } ${ url } ${ statusCode } ` }
65+ size = { size }
66+ /> ,
6367 ) ;
6468 }
6569 }
@@ -72,23 +76,25 @@ export function renderApiStatistics({apiStatistics, hash}: Options): SafeHtml {
7276 > ) {
7377 for ( const [ statusCode , { count, duration, size} ] of Object . entries ( byStatusCode ) ) {
7478 items . push (
75- ApiStatisticsItem ( {
76- count,
77- duration,
78- name : `${ url } ${ statusCode } ` ,
79- size,
80- url,
81- } ) ,
79+ < ApiStatisticsItem
80+ count = { count }
81+ duration = { duration }
82+ name = { `${ url } ${ statusCode } ` }
83+ size = { size }
84+ url = { url }
85+ /> ,
8286 ) ;
8387 }
8488 }
8589 }
8690
87- return createSafeHtmlWithoutSanitize `<article class="test-details">
88- <p class="test-details__path"></p>
89- <h2 class="test-details__title">${ header } </h2>
90- <div role="tabpanel">
91- <article class="overview">${ items . join ( '' ) } </article>
92- </div>
93- </article>` ;
94- }
91+ return (
92+ < article class = "test-details" >
93+ < p class = "test-details__path" > </ p >
94+ < h2 class = "test-details__title" > { header } </ h2 >
95+ < div role = "tabpanel" >
96+ < article class = "overview" > { createSafeHtmlWithoutSanitize `${ items . join ( '' ) } ` } </ article >
97+ </ div >
98+ </ article >
99+ ) ;
100+ } ;
0 commit comments