@saltcorn/markup
Advanced tools
Comparing version 0.6.1 to 0.6.2-beta.0
@@ -20,3 +20,3 @@ /** | ||
* checks if x is defined | ||
* @param {*} x | ||
* @param {*} x | ||
* @returns {boolean} | ||
@@ -27,6 +27,6 @@ */ | ||
/** | ||
* @param {object|string} v | ||
* @param {object} hdr | ||
* @param {boolean} force_required | ||
* @param {string} neutral_label | ||
* @param {object|string} v | ||
* @param {object} hdr | ||
* @param {boolean} force_required | ||
* @param {string} neutral_label | ||
* @returns {string} | ||
@@ -61,3 +61,3 @@ */ | ||
/** | ||
* | ||
* | ||
* @param {object} opts | ||
@@ -72,3 +72,11 @@ * @param {string} opts.name | ||
*/ | ||
const radio_group = ({ name, options, value, inline, form_name, ...rest }) => | ||
const radio_group = ({ | ||
name, | ||
options, | ||
value, | ||
inline, | ||
form_name, | ||
onChange, | ||
...rest | ||
}) => | ||
div( | ||
@@ -86,2 +94,3 @@ (options || []) | ||
name, | ||
onChange, | ||
"data-fieldname": form_name, | ||
@@ -101,2 +110,40 @@ id, | ||
const checkbox_group = ({ | ||
name, | ||
options, | ||
value, | ||
inline, | ||
form_name, | ||
onChange, | ||
...rest | ||
}) => | ||
div( | ||
(options || []) | ||
.filter((o) => (typeof o === "string" ? o : o.value)) | ||
.map((o, ix) => { | ||
const myvalue = typeof o === "string" ? o : o.value; | ||
const id = `input${text_attr(name)}${ix}`; | ||
return div( | ||
{ class: ["form-check", inline && "form-check-inline"] }, | ||
input({ | ||
class: ["form-check-input", rest.class], | ||
type: "checkbox", | ||
name, | ||
onChange: `check_state_field(this)`, | ||
"data-fieldname": form_name, | ||
id, | ||
value: text_attr(myvalue), | ||
checked: Array.isArray(value) | ||
? value.includes(myvalue) | ||
: myvalue === value, | ||
}), | ||
label( | ||
{ class: "form-check-label", for: id }, | ||
typeof o === "string" ? o : o.label | ||
) | ||
); | ||
}) | ||
.join("") | ||
); | ||
/** | ||
@@ -152,5 +199,5 @@ * @param {object} opts | ||
/** | ||
* @param {string} name | ||
* @param {object} v | ||
* @param {object} param2 | ||
* @param {string} name | ||
* @param {object} v | ||
* @param {object} param2 | ||
* @returns {string} | ||
@@ -227,2 +274,3 @@ */ | ||
radio_group, | ||
checkbox_group, | ||
}; |
16
index.js
@@ -5,2 +5,18 @@ /** | ||
*/ | ||
/** | ||
* All files in the saltcorn-markup package. | ||
* @namespace saltcorn-markup_overview | ||
* @property {module:builder} builder | ||
* @property {module:emergency_layout} emergency_layout | ||
* @property {module:form} from | ||
* @property {module:helpers} helpers | ||
* @property {module:layout_utils} layout_utils | ||
* @property {module:layout} layout | ||
* @property {module:mktag} mktag | ||
* @property {module:table} table | ||
* @property {module:tabs} tabs | ||
* @category saltcorn-markup | ||
*/ | ||
const renderForm = require("./form"); | ||
@@ -7,0 +23,0 @@ const renderBuilder = require("./builder"); |
@@ -37,3 +37,3 @@ /** | ||
/** | ||
* @param {string|object} body | ||
* @param {string|object} body | ||
* @param {object[]} [alerts] | ||
@@ -66,5 +66,5 @@ * @returns {object} | ||
/** | ||
* | ||
* @param {object} segment | ||
* @param {string} inner | ||
* | ||
* @param {object} segment | ||
* @param {string} inner | ||
* @returns {div|span|string} | ||
@@ -102,6 +102,9 @@ */ | ||
* @param {*} opts.ntabs | ||
* @param {function} go | ||
* @param {function} go | ||
* @returns {ul_div} | ||
*/ | ||
const renderTabs = ({ contents, titles, tabsStyle, ntabs }, go) => { | ||
const renderTabs = ( | ||
{ contents, titles, tabsStyle, ntabs, independent }, | ||
go | ||
) => { | ||
const rndid = `tab${Math.floor(Math.random() * 16777215).toString(16)}`; | ||
@@ -136,3 +139,3 @@ if (tabsStyle === "Accordion") | ||
"aria-labelledby": `${rndid}head${ix}`, | ||
"data-parent": `#${rndid}top`, | ||
"data-parent": independent ? undefined : `#${rndid}top`, | ||
}, | ||
@@ -139,0 +142,0 @@ div({ class: "card-body" }, go(t, false, ix)) |
{ | ||
"name": "@saltcorn/markup", | ||
"version": "0.6.1", | ||
"version": "0.6.2-beta.0", | ||
"description": "Markup for Saltcorn, open-source no-code platform", | ||
@@ -8,3 +8,5 @@ "homepage": "https://saltcorn.com", | ||
"scripts": { | ||
"test": "jest" | ||
"test": "jest", | ||
"tsc": "echo \"Error: no TypeScript support yet\"", | ||
"clean": "echo \"Error: no TypeScript support yet\"" | ||
}, | ||
@@ -11,0 +13,0 @@ "author": "Tom Nielsen", |
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
75252
2691