@@ -19,6 +19,7 @@ import {
1919
2020type SearchEntry = {
2121 code : string ;
22+ example : string ;
2223 name : string ;
2324 age : string ;
2425 block : string ;
@@ -67,6 +68,11 @@ const categoryMap: { [key: string]: string } = {
6768 "Zs" : "Separator, Space"
6869}
6970
71+ // translates from a hex codepoint string to the actual character
72+ function codeToString ( code : string ) :string {
73+ return String . fromCodePoint ( parseInt ( code , 16 ) ) ;
74+ }
75+
7076function filterCategory (
7177 headerValue : string ,
7278 rowValue : string ,
@@ -143,15 +149,6 @@ function fmtCodepoint(cell: CellComponent) {
143149 return `U+${ val . toUpperCase ( ) } ` ;
144150}
145151
146- function fmtExampleString ( cell : CellComponent ) {
147- const val = cell . getValue ( ) as string ;
148- if ( ! val ) {
149- return "" ;
150- }
151- const codepoints = val . split ( " " ) . map ( ( cp ) => parseInt ( cp , 16 ) ) ;
152- return String . fromCodePoint ( ...codepoints ) ;
153- }
154-
155152function fmtTags ( cell : CellComponent ) {
156153 const tags = cell . getValue ( ) as string [ ] ;
157154 if ( ! tags || tags . length === 0 ) {
@@ -279,6 +276,10 @@ async function main() {
279276
280277 data = rawData . data ;
281278
279+ for ( const row of data ) {
280+ row . example = codeToString ( row . code ) ;
281+ }
282+
282283 console . log ( data [ 0 ] ) ;
283284
284285 Tabulator . registerModule ( [
@@ -298,43 +299,45 @@ async function main() {
298299 autoResize : true ,
299300 data,
300301 columns : [
302+ {
303+ field : "example" ,
304+ headerFilter : "input" ,
305+ headerFilterFunc : (
306+ headerValue ,
307+ rowValue ,
308+ rowData ,
309+ filterParams
310+ ) => {
311+ if ( ! headerValue ) return true ;
312+ return headerValue == rowValue ;
313+ } ,
314+ headerHozAlign : "center" ,
315+ hozAlign : "center" ,
316+ responsive : 0 ,
317+ title : "Character" ,
318+ width : 150 ,
319+ } ,
301320 {
302321 field : "code" ,
303322 formatter : fmtCodepoint ,
304323 headerFilter : "input" ,
305324 headerHozAlign : "center" ,
306325 hozAlign : "center" ,
307- responsive : 2 ,
308- sorter : function ( a , b , aRow , bRow , column , dir , sorterParams ) {
326+ responsive : 10 ,
327+ sorter : function ( a , b , aRow , bRow , column , dir , sorterParams ) {
309328 const aInt = parseInt ( a , 16 ) ;
310329 const bInt = parseInt ( b , 16 ) ;
311330 return aInt - bInt ;
312331 } ,
313332 title : "Codepoint" ,
314- width : 175 ,
315- } ,
316- {
317- field : "code" ,
318- formatter : fmtExampleString ,
319- headerFilter : "input" ,
320- headerFilterFunc : ( headerValue , rowValue , rowData , filterParams ) => {
321- if ( ! headerValue || headerValue . length != 1 ) return true ;
322- const headerInt = headerValue . codePointAt ( 0 ) ;
323- const headerHex = headerInt . toString ( 16 ) . toUpperCase ( ) . padStart ( 4 , "0" ) ;
324- return headerHex == rowData . code ;
325- } ,
326- headerHozAlign : "center" ,
327- hozAlign : "center" ,
328- responsive : 2 ,
329- title : "Example" ,
330- width : 175 ,
333+ width : 150 ,
331334 } ,
332335 {
333336 field : "block" ,
334337 headerFilter : "input" ,
335338 headerHozAlign : "center" ,
336339 hozAlign : "center" ,
337- responsive : 2 ,
340+ responsive : 20 ,
338341 title : "Block" ,
339342 width : 175 ,
340343 } ,
@@ -345,19 +348,29 @@ async function main() {
345348 headerFilterFunc : filterCategory ,
346349 headerHozAlign : "center" ,
347350 hozAlign : "center" ,
348- responsive : 2 ,
351+ responsive : 40 ,
349352 title : "Category" ,
350353 width : 200 ,
351354 } ,
355+ {
356+ field : "script" ,
357+ headerFilter : "input" ,
358+ headerFilterFunc : "starts" ,
359+ headerHozAlign : "center" ,
360+ hozAlign : "center" ,
361+ responsive : 50 ,
362+ title : "Script" ,
363+ width : 100 ,
364+ } ,
352365 {
353366 field : "age" ,
354367 headerFilter : "input" ,
355368 headerFilterFunc : "starts" ,
356369 headerHozAlign : "center" ,
357370 hozAlign : "center" ,
358- responsive : 2 ,
371+ responsive : 30 ,
359372 title : "Version" ,
360- width : 125 ,
373+ width : 110 ,
361374 } ,
362375 {
363376 title : "Name" ,
@@ -382,7 +395,7 @@ async function main() {
382395 field : "tags" ,
383396 formatter : fmtTags ,
384397 headerSort : false ,
385- responsive : 0 ,
398+ responsive : 15 ,
386399 width : 375 ,
387400 } ,
388401 ] ,
0 commit comments