Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@saltcorn/markup

Package Overview
Dependencies
Maintainers
1
Versions
401
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saltcorn/markup - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

89

form.js

@@ -14,3 +14,3 @@ const { p, div, i, label, text, button, a, span } = require("./tags");

const isHoriz = formStyle => formStyle === "horiz";
const formRowWrap = (hdr, inner, error = "", fStyle) =>
const formRowWrap = (hdr, inner, error = "", fStyle, labelCols) =>
div(

@@ -25,3 +25,7 @@ {

? div(
{ class: isHoriz(fStyle) && "col-sm-10 offset-md-2" },
{
class:
isHoriz(fStyle) &&
`col-sm-${12 - labelCols} offset-md-${labelCols}`
},
div(

@@ -41,11 +45,18 @@ { class: "form-check" },

for: `input${text(hdr.name)}`,
class: isHoriz(fStyle) && "col-sm-2 col-form-label"
class: isHoriz(fStyle) && `col-sm-${labelCols} col-form-label`
},
text(hdr.label)
),
div({ class: isHoriz(fStyle) && "col-sm-10" }, inner, text(error))
div(
{ class: isHoriz(fStyle) && `col-sm-${12 - labelCols}` },
inner,
text(error)
)
],
hdr.sublabel &&
div(
{ class: isHoriz(fStyle) && "col-sm-10 offset-md-2" },
{
class:
isHoriz(fStyle) && `col-sm-${12 - labelCols} offset-md-${labelCols}`
},
i(text(hdr.sublabel))

@@ -76,8 +87,8 @@ )

const mkFormRow = (v, errors, formStyle) => hdr =>
const mkFormRow = (v, errors, formStyle, labelCols) => hdr =>
hdr.isRepeat
? mkFormRowForRepeat(v, errors, formStyle, hdr)
: mkFormRowForField(v, errors, formStyle)(hdr);
? mkFormRowForRepeat(v, errors, formStyle, labelCols, hdr)
: mkFormRowForField(v, errors, formStyle, labelCols)(hdr);
const mkFormRowForRepeat = (v, errors, formStyle, hdr) => {
const mkFormRowForRepeat = (v, errors, formStyle, labelCols, hdr) => {
const adder = a({ href: `javascript:add_repeater('${hdr.name}')` }, "Add");

@@ -107,3 +118,9 @@ const icons = div(

hdr.fields.map(f => {
return mkFormRowForField(vi, errors, formStyle, "_" + ix)(f);
return mkFormRowForField(
vi,
errors,
formStyle,
labelCols,
"_" + ix
)(f);
})

@@ -122,3 +139,3 @@ );

hdr.fields.map(f => {
return mkFormRowForField(v, errors, formStyle, "_0")(f);
return mkFormRowForField(v, errors, formStyle, labelCols, "_0")(f);
})

@@ -150,3 +167,9 @@ )

const mkFormRowForField = (v, errors, formStyle, nameAdd = "") => hdr => {
const mkFormRowForField = (
v,
errors,
formStyle,
labelCols,
nameAdd = ""
) => hdr => {
const name = hdr.name + nameAdd;

@@ -168,3 +191,4 @@ const validClass = errors[name] ? "is-invalid" : "";

errorFeedback,
formStyle
formStyle,
labelCols
);

@@ -183,3 +207,4 @@ case "hidden":

errorFeedback,
formStyle
formStyle,
labelCols
);

@@ -196,16 +221,26 @@ case "ordered_multi_select":

errorFeedback,
formStyle
formStyle,
labelCols
);
default:
return formRowWrap(
hdr,
`<input type="${hdr.input_type}" class="form-control ${
hdr.class
}" name="${name}" id="input${text(name)}" ${
v && isdef(v[hdr.name]) ? `value="${text(v[hdr.name])}"` : ""
}>`,
errorFeedback,
formStyle
);
const the_input = `<input type="${hdr.input_type}" class="form-control ${
hdr.class
}" name="${name}" id="input${text(name)}" ${
v && isdef(v[hdr.name]) ? `value="${text(v[hdr.name])}"` : ""
}>`;
const inner = hdr.postText
? div(
{ class: "input-group" },
the_input,
div(
{ class: "input-group-append" },
span(
{ class: "input-group-text", id: "basic-addon2" },
hdr.postText
)
)
)
: the_input;
return formRowWrap(hdr, inner, errorFeedback, formStyle, labelCols);
}

@@ -250,7 +285,7 @@ };

const flds = form.fields
.map(mkFormRow(form.values, errors, form.formStyle))
.map(mkFormRow(form.values, errors, form.formStyle, form.labelCols || 2))
.join("");
const blurbp = form.blurb ? p(text(form.blurb)) : "";
const bot = `<div class="form-group row">
<div class="col-sm-10">
<div class="col-sm-12">
<button type="submit" class="btn btn-primary">${text(

@@ -257,0 +292,0 @@ form.submitLabel || "Save"

@@ -12,2 +12,5 @@ const renderForm = require("./form");

const post_delete_btn = href => `<form action="${text(href)}" method="post">
<button type="submit" class="btn btn-sm btn-danger"><i class="fas fa-trash"></i></button></form>`;
module.exports = {

@@ -19,3 +22,4 @@ mkTable,

post_btn,
post_delete_btn,
tabs
};
{
"name": "@saltcorn/markup",
"version": "0.0.6",
"description": "",
"version": "0.0.7",
"description": "Markup for Saltcorn, open-source no-code platform",
"homepage": "https://saltcorn.com",
"main": "index.js",

@@ -12,3 +13,3 @@ "scripts": {

"dependencies": {
"contractis": "^0.0.6",
"contractis": "^0.0.7",
"xss": "^1.0.6"

@@ -25,3 +26,3 @@ },

},
"gitHead": "4c4b8e7d7ebc5a703b8c9f7c1527b59694238d71"
"gitHead": "d72ef79b2542479469fd28919a33525d8f4a8144"
}

@@ -92,3 +92,4 @@ const xss = require("xss");

text,
nbsp
nbsp,
mkTag
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc