Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@hdsydsvenskan/forms-utils
Advanced tools
A collection of fields, widgets and other useful utils for the forms module.
const { customFields: fields } = require('@hdsydsvenskan/forms-utils');
const { fields, widgets } = require('forms');
const formDefinition = {
description: customFields.html({
label: 'Description',
html: '<p>This is a HTML description</p>'
}),
items: customFields.multiObject({
label: 'Items',
rowField: {
itemName: fields.string({ label: 'Name' }),
itemValuee: fields.string({ label: 'Value' })
}
})
}
.fields
.basic
– a basic field which can eg. be extended to create more complex fields.html
– a HTML field, which doesn't contain any actual form widget, but inserts a piece of HTML in its place instead (specified through a html
property). Does not interact with any value of the field, neither gets or sets it..multiField
– a multi row field for creating complex forms. Repeats a sub-form for every item in an array value + allows adding new items. Needs a piece of client side JS to delete rows and to make adding new rows easier..widgets
.utils
getUserAttrs()
– mimics the one from forms
itselfhtmlEscape()
– mimics the one from forms
itselftag()
– mimics the one from forms
itselfpromisedFormHandle(form, body)
– takes a form definition and a body and handles the form through a Promise
– resolving to { success: true, form }
, { error: true, form }
or { empty: true, form }
promisedFormHandles(forms, body)
– same as promisedFormHandle
, but with multiple form definitions. If any of those definitions return error: true
, then it will return { error: true, forms }
. If any forms is empty, then it will return { empty: true, forms }
. Else it will return { success: true, forms }
.var multiField = require('@hdsydsvenskan/forms-utils/browser/multi-field')({
dom: ourDomLib
});
multiField.init();
options.dom
– some DOM helpers[options.activateInContext(newRow)]
– if provided, then this will be called for every new row added. This enables other pieces of javascript to run on those new rows – adding eg. autocomplete functionality or other interesting things[options.dragula]
– if drag and drop capabilities are wanted, then provide a version of Dragula 3.x
[options.textRemove]
– the text to add to the remove buttons. Defaults to Remove
.Returns an object
with two methods: initField(elem)
and init([context])
.
initField(elem)
initiates the javascript for a specific multi field setup.
init([context])
initiates the javascript for aöö multi field setups within the context
or document
.
The DOM library should have something close to this (our DOM library is still internal):
$$(selector, [context])
– returns an array of DOM elements matching the selector within the context
or document
$(selector, [context])
– returns a single DOM element matching the selector within the context
or document
createChild(parent, tagName, [classNameOrProperties], [textContent])
– creates and append a new element. classNameOrProperties
can be either a string class or an object with many properties, all which will be applied to the new elementremoveElement(elem)
appendChild(parent, child)
closestByClass(elem, className)
– returns the closest parent element to elem
that handles the className
FAQs
A set of useful utilities for the forms module
The npm package @hdsydsvenskan/forms-utils receives a total of 891 weekly downloads. As such, @hdsydsvenskan/forms-utils popularity was classified as not popular.
We found that @hdsydsvenskan/forms-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.