@@ -548,6 +548,8 @@ Type: `object`
548548
549549Header configuration.
550550
551+ * Deprecated in favor of the new spanning cells API.*
552+
551553The header configuration inherits the most of the column's, except:
552554- ` content ` ** {string}** : the header content.
553555- ` width: ` calculate based on the content width automatically.
@@ -589,6 +591,82 @@ console.log(table(data, config));
589591```
590592
591593
594+ <a name =" table-api-table-1-config-spanningcells " ></a >
595+ ##### config.spanningCells
596+
597+ Type: ` SpanningCellConfig[] `
598+
599+ Spanning cells configuration.
600+
601+ The configuration should be straightforward: just specify an array of minimal cell configurations including the position of top-left cell
602+ and the number of columns and/or rows will be expanded from it.
603+
604+ The content of overlap cells will be ignored to make the ` data ` shape be consistent.
605+
606+ By default, the configuration of column that the top-left cell belongs to will be applied to the whole spanning cell, except:
607+ * The ` width ` will be summed up of all spanning columns.
608+ * The ` paddingRight ` will be received from the right-most column intentionally.
609+
610+ Advances customized column-like styles can be configurable to each spanning cell to overwrite the default behavior.
611+
612+ ``` js
613+ const data = [
614+ [' Test Coverage Report' , ' ' , ' ' , ' ' , ' ' , ' ' ],
615+ [' Module' , ' Component' , ' Test Cases' , ' Failures' , ' Durations' , ' Success Rate' ],
616+ [' Services' , ' User' , ' 50' , ' 30' , ' 3m 7s' , ' 60.0%' ],
617+ [' ' , ' Payment' , ' 100' , ' 80' , ' 7m 15s' , ' 80.0%' ],
618+ [' Subtotal' , ' ' , ' 150' , ' 110' , ' 10m 22s' , ' 73.3%' ],
619+ [' Controllers' , ' User' , ' 24' , ' 18' , ' 1m 30s' , ' 75.0%' ],
620+ [' ' , ' Payment' , ' 30' , ' 24' , ' 50s' , ' 80.0%' ],
621+ [' Subtotal' , ' ' , ' 54' , ' 42' , ' 2m 20s' , ' 77.8%' ],
622+ [' Total' , ' ' , ' 204' , ' 152' , ' 12m 42s' , ' 74.5%' ],
623+ ];
624+
625+ const config = {
626+ columns: [
627+ { alignment: ' center' , width: 12 },
628+ { alignment: ' center' , width: 10 },
629+ { alignment: ' right' },
630+ { alignment: ' right' },
631+ { alignment: ' right' },
632+ { alignment: ' right' }
633+ ],
634+ spanningCells: [
635+ { col: 0 , row: 0 , colSpan: 6 },
636+ { col: 0 , row: 2 , rowSpan: 2 , verticalAlignment: ' middle' },
637+ { col: 0 , row: 4 , colSpan: 2 , alignment: ' right' },
638+ { col: 0 , row: 5 , rowSpan: 2 , verticalAlignment: ' middle' },
639+ { col: 0 , row: 7 , colSpan: 2 , alignment: ' right' },
640+ { col: 0 , row: 8 , colSpan: 2 , alignment: ' right' }
641+ ],
642+ };
643+
644+ console .log (table (data, config));
645+ ```
646+
647+ ```
648+ ╔══════════════════════════════════════════════════════════════════════════════╗
649+ ║ Test Coverage Report ║
650+ ╟──────────────┬────────────┬────────────┬──────────┬───────────┬──────────────╢
651+ ║ Module │ Component │ Test Cases │ Failures │ Durations │ Success Rate ║
652+ ╟──────────────┼────────────┼────────────┼──────────┼───────────┼──────────────╢
653+ ║ │ User │ 50 │ 30 │ 3m 7s │ 60.0% ║
654+ ║ Services ├────────────┼────────────┼──────────┼───────────┼──────────────╢
655+ ║ │ Payment │ 100 │ 80 │ 7m 15s │ 80.0% ║
656+ ╟──────────────┴────────────┼────────────┼──────────┼───────────┼──────────────╢
657+ ║ Subtotal │ 150 │ 110 │ 10m 22s │ 73.3% ║
658+ ╟──────────────┬────────────┼────────────┼──────────┼───────────┼──────────────╢
659+ ║ │ User │ 24 │ 18 │ 1m 30s │ 75.0% ║
660+ ║ Controllers ├────────────┼────────────┼──────────┼───────────┼──────────────╢
661+ ║ │ Payment │ 30 │ 24 │ 50s │ 80.0% ║
662+ ╟──────────────┴────────────┼────────────┼──────────┼───────────┼──────────────╢
663+ ║ Subtotal │ 54 │ 42 │ 2m 20s │ 77.8% ║
664+ ╟───────────────────────────┼────────────┼──────────┼───────────┼──────────────╢
665+ ║ Total │ 204 │ 152 │ 12m 42s │ 74.5% ║
666+ ╚═══════════════════════════╧════════════╧══════════╧═══════════╧══════════════╝
667+ ```
668+
669+
592670<a name =" table-api-createstream " ></a >
593671### createStream
594672
0 commit comments