@saltcorn/markup
Advanced tools
Comparing version 0.2.3-beta.1 to 0.2.3
@@ -1,2 +0,2 @@ | ||
const { a, text, div, input, text_attr } = require("./tags"); | ||
const { a, text, div, input, text_attr, ul, li, span } = require("./tags"); | ||
@@ -24,4 +24,44 @@ const isdef = (x) => typeof x !== "undefined"; | ||
const search_bar = (name, v, onClick) => `<div class="input-group"> | ||
<input type="text" class="form-control bg-light search-bar" placeholder="Search for..." | ||
const pagination = ({ current_page, pages, get_page_link }) => { | ||
const from = Math.max(1, current_page - 3); | ||
const to = Math.min(pages, current_page + 3); | ||
var lis = []; | ||
if (from > 1) { | ||
lis.push( | ||
li( | ||
{ class: `page-item` }, | ||
a({ class: "page-link", href: get_page_link(1) }, 1) | ||
) | ||
); | ||
lis.push(li({ class: `page-item` }, span({ class: "page-link" }, "..."))); | ||
} | ||
for (let index = from; index <= to; index++) { | ||
lis.push( | ||
li( | ||
{ class: ["page-item", index === current_page && "active"] }, | ||
a({ class: "page-link", href: get_page_link(index) }, index) | ||
) | ||
); | ||
} | ||
if (to < pages) { | ||
lis.push(li({ class: `page-item` }, span({ class: "page-link" }, "..."))); | ||
lis.push( | ||
li( | ||
{ class: `page-item` }, | ||
a({ class: "page-link", href: get_page_link(pages) }, pages) | ||
) | ||
); | ||
} | ||
return ul({ class: "pagination" }, lis); | ||
}; | ||
const search_bar = ( | ||
name, | ||
v, | ||
{ onClick, placeHolder } = {} | ||
) => `<div class="input-group"> | ||
<input type="text" class="form-control bg-light search-bar" placeholder="${ | ||
placeHolder || "Search for..." | ||
}" | ||
id="input${text_attr(name)}" name="${name}" | ||
@@ -45,2 +85,8 @@ ${onClick ? `onChange="${onClick}"` : ""} | ||
module.exports = { isdef, select_options, search_bar, search_bar_form }; | ||
module.exports = { | ||
isdef, | ||
select_options, | ||
search_bar, | ||
search_bar_form, | ||
pagination, | ||
}; |
@@ -87,3 +87,15 @@ const { contract, is } = require("contractis"); | ||
if (segment.type === "link") { | ||
return wrap(segment, isTop, ix, a({ href: segment.url }, segment.text)); | ||
return wrap( | ||
segment, | ||
isTop, | ||
ix, | ||
a( | ||
{ | ||
href: segment.url, | ||
target: segment.target_blank ? "_blank" : false, | ||
rel: segment.nofollow ? "nofollow" : false, | ||
}, | ||
segment.text | ||
) | ||
); | ||
} | ||
@@ -96,3 +108,6 @@ if (segment.type === "card") | ||
div( | ||
{ class: "card shadow mt-4" }, | ||
{ | ||
class: `card shadow mt-4 ${segment.url ? "with-link" : ""}`, | ||
onclick: segment.url ? `location.href='${segment.url}'` : false, | ||
}, | ||
segment.title && | ||
@@ -99,0 +114,0 @@ div( |
{ | ||
"name": "@saltcorn/markup", | ||
"version": "0.2.3-beta.1", | ||
"version": "0.2.3", | ||
"description": "Markup for Saltcorn, open-source no-code platform", | ||
@@ -27,3 +27,3 @@ "homepage": "https://saltcorn.com", | ||
}, | ||
"gitHead": "868921925df3768f5454083692901425c3783435" | ||
"gitHead": "87f837eeacdae376453ccbafa2a96141112b5cbb" | ||
} |
36
table.js
@@ -17,3 +17,3 @@ const { contract, is } = require("contractis"); | ||
} = require("./tags"); | ||
const { pagination } = require("./helpers"); | ||
const headerCell = (hdr) => | ||
@@ -24,36 +24,2 @@ hdr.sortlink | ||
const pagination = ({ current_page, pages, get_page_link }) => { | ||
const from = Math.max(1, current_page - 3); | ||
const to = Math.min(pages, current_page + 3); | ||
var lis = []; | ||
if (from > 1) { | ||
lis.push( | ||
li( | ||
{ class: `page-item` }, | ||
a({ class: "page-link", href: get_page_link(1) }, 1) | ||
) | ||
); | ||
lis.push(li({ class: `page-item` }, span({ class: "page-link" }, "..."))); | ||
} | ||
for (let index = from; index <= to; index++) { | ||
lis.push( | ||
li( | ||
{ class: ["page-item", index === current_page && "active"] }, | ||
a({ class: "page-link", href: get_page_link(index) }, index) | ||
) | ||
); | ||
} | ||
if (to < pages) { | ||
lis.push(li({ class: `page-item` }, span({ class: "page-link" }, "..."))); | ||
lis.push( | ||
li( | ||
{ class: `page-item` }, | ||
a({ class: "page-link", href: get_page_link(pages) }, pages) | ||
) | ||
); | ||
} | ||
return ul({ class: "pagination" }, lis); | ||
}; | ||
const mkTable = contract( | ||
@@ -60,0 +26,0 @@ is.fun( |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42080
1438