@saltcorn/markup
Advanced tools
Comparing version 1.0.0-rc.6 to 1.0.0-rc.7
@@ -23,2 +23,3 @@ /** | ||
tableId?: string; | ||
grouped?: string; | ||
}; | ||
@@ -25,0 +26,0 @@ } |
@@ -7,3 +7,3 @@ "use strict"; | ||
const tags = require("./tags"); | ||
const { a, td, tr, th, text, div, table, thead, tbody, ul, li, span } = tags; | ||
const { a, td, tr, th, text, div, table, thead, tbody, ul, li, span, h4 } = tags; | ||
const helpers = require("./helpers"); | ||
@@ -43,2 +43,10 @@ const { pagination } = helpers; | ||
const mkTable = (hdrs, vs, opts = {}) => { | ||
const val_row = (v) => tr(mkClickHandler(opts, v), hdrs.map((hdr) => td({ | ||
style: { | ||
...(hdr.align ? { "text-align": hdr.align } : {}), | ||
...(hdr.width && opts.noHeader ? { width: hdr.width } : {}), | ||
}, | ||
}, typeof hdr.key === "string" ? text(v[hdr.key]) : hdr.key(v)))); | ||
const groupedBody = (groups) => Object.entries(groups).map(([group, rows]) => tr(td({ colspan: "1000" }, h4({ class: "list-group-header" }, group))) + | ||
rows.map(val_row).join("")); | ||
return div({ | ||
@@ -60,10 +68,5 @@ class: ["table-responsive", opts.tableClass], | ||
? transposedBody(hdrs, vs, opts) | ||
: (vs || []).map((v) => tr(mkClickHandler(opts, v), hdrs.map((hdr) => td({ | ||
style: { | ||
...(hdr.align ? { "text-align": hdr.align } : {}), | ||
...(hdr.width && opts.noHeader | ||
? { width: hdr.width } | ||
: {}), | ||
}, | ||
}, typeof hdr.key === "string" ? text(v[hdr.key]) : hdr.key(v))))))), opts.pagination && pagination(opts.pagination)); | ||
: opts.grouped | ||
? groupedBody(vs) | ||
: (vs || []).map(val_row))), opts.pagination && pagination(opts.pagination)); | ||
}; | ||
@@ -70,0 +73,0 @@ /** |
{ | ||
"name": "@saltcorn/markup", | ||
"version": "1.0.0-rc.6", | ||
"version": "1.0.0-rc.7", | ||
"description": "Markup for Saltcorn, open-source no-code platform", | ||
@@ -38,3 +38,3 @@ "homepage": "https://saltcorn.com", | ||
"devDependencies": { | ||
"@saltcorn/types": "1.0.0-rc.6", | ||
"@saltcorn/types": "1.0.0-rc.7", | ||
"@types/escape-html": "^1.0.1", | ||
@@ -41,0 +41,0 @@ "@types/jest": "^29.5.11", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
266387
3481