Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
@chronicstone/sweetforms
Advanced tools
A package based on sweetalert2 that profides highly customizable forms promised-based forms, with features like form advanced validation, optional http request handling, and many more
Key Features • How To Use • Documentation & Examples • Improvements roadmap • Credits
# Install the package
$ npm install --save @chronicstone/sweetforms
// Import the package to your project
import { SimpleForm, SteppedForm } from "@chronicstone/sweetforms";
// Call one of the provided methods to generate your form.
SimpleForm({
themeConfig: {
// [OPTION] Configure the popup's global appreaence
darkMode: false,
maxHeight: "65vh", // Max height of the inner form container
},
itemsByLine: 2, // [OPTION] Number of fields displayed for each line
title: "Sign in", // Form title
customValidators: {
// Declare here your custom validation functions
checkEmailAvailable: async ({ field, value, validate }) => {
let isAvailable = true
// ... Do some stuff here
if (isAvailable) validate({ isValid: true });
else
validate({
isValid: false, // [REQUIRED]
message: `This email address is not available`, // [REQUIRED if not valid] Displayed err message
force: true, // [OPTION] Overrides other validators messages
});
},
},
fields: [
{
label: "Email address", // [REQUIRED] Field label
key: "email", // [REQUIRED] Key of the field value in the returned object
type: "text", // [REQUIRED] Field type (See availables types above)
value: "", // [REQUIRED] Field value
placeholder: "john.doe@mail.com", // [OPTION] Placeholder value
validation: ["required", "email"], // [OPTION] field validators (Among included ones in package)
customValidation: ["checkEmailAvailable"], // [OPTION] custom field validator (Validator function must be declared on customValidators object above)
fullWidth: true, // [OPTION] Field will take the full line whatever items per line has been specified
},
{
label: "Password",
key: "password",
type: "password",
value: "",
placeholder: "••••••••••",
validation: ["required"],
},
{
label: "Password confirm", // Temporary - An built-in password confirm handler will soon be available
type: "password",
key: "confirm",
value: "",
placeholder: "••••••••••",
validation: ["required"],
},
{
label: "Country",
key: "country",
type: "select",
value: "",
options: [
{ label: "Select a country", value: "" },
...[
"France",
"Spain",
"England",
"Italy",
"United States",
"Canada",
"Japan",
].map((opt) => {
return { label: opt, value: opt.toLowerCase() };
}),
],
validation: ["required"],
},
{
label: "Upload an avatar",
type: "file",
key: "avatar",
value: "",
validation: ["required"],
attributes: {
accept: "image/png, image/jpeg",
},
},
{
label: "Gender",
type: "radio",
key: "gender",
validation: ["required"],
options: [
{ label: "Male", value: "m" },
{ label: "Female", value: "f" },
],
fullWidth: true,
},
],
}).then((result) => {
const { success, formData, ShowFeedback } = result;
// ... Do some stuff here
// ShowFeedback method allow you to display a feedback popup after processing the form content if needed
ShowFeedback({
success: true,
title: "Form completed !",
text: "",
timer: 3000,
});
});
This package is entirely based on Sweetalert2, and its promise-based notification system.
This project is 100 % open-source, do not hesitate to give feedback on the library, ask for new features or even make a pull request. Any participation is welcomed.
MIT
GitHub @ChronicStone ·
FAQs
A package based on sweetalert2 that profides highly customizable forms promised-based forms, with features like form advanced validation, optional http request handling, and many more
We found that @chronicstone/sweetforms demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.