npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

icarus-forms

v1.16.5

Published

the frontend for the display and execution of forms created by the Apollo backend

Downloads

106

Readme

Icarus

Icarus is a frontend for the rendering, validation, and submission of forms created by the Apollo forms backend.

Dependencies

In an effort to let Icarus fly, it has no hard dependencies except LoDash. Just don't soar too close to the sun.

Size

< 40Kb

Installation

yarn add icarus-forms
===
OR
===
npm install --save icarus-forms
===
OR
===
<script type="text/javascript" src="/path/to/icarus.min.js"></script>

Then:

let Icarus = require('icarus-forms');
// OR
var Icarus = window.Icarus;

Usage

let Icarus = require('icarus-forms');

// render a form into the '#icarus-container' container
let form = new Icarus('#icarus-container', {
  apollo: 'apollo.yourdomain.com', // the URL of the apollo forms backend
  formId: 132
});

It's also possible to set global defaults on the Icarus object to have them apply to every new form instance created

let Icarus = require('icarus-forms');

Icarus.setDefaults({
  apollo: 'apollo.yourdomain.com'
});

// this form will use the apolloUrl 'apollo.yourdomain.com' because that is the icarus default.
let form = new Icarus('#icarus-container', {
  formId: 132
});

Options

Icarus supports the following options

| Option | Default | Description | | ------------- | --------- | -------------------------------------------------------------------------------------------------------------------| | apollo | '' | The location of the apollo forms backend service | | apiRoot | '/api/v1' | The path to the mount point for the REST API | | formId | '' | The ID of the apollo form to render | | theme | 'default' | The theme to use when rendering the form. See the 'themes' directory for options. | | themesLocation| '' | The location of the themes. See here for detail | | render | {} | Render specific options. See here for detail | | validation | {} | Validation specific options. See here for detail | | listeners | {} | Hooks into the lifecycle of the form. See here for detail |

Gotchas / Notes

  1. Binding listeners directly to events on form fields likely won't behave as you expect it to, this due to the way field rendering works. For instance, say we render a form having three fields: "litigation", "litigation_selector", and "email", the DOM markup looking like:
<div id="form-selector">
    <div class="icarus">
        <form class="icarus-form">
            <div class="icarus-layout">
                <div class="icarus-layout-static">
                    <div class="icarus-field field-email label-vertical required" data-field-id="1">
                        <input type="text" name="email" placeholder="Email" />
                    </div>
                    
                    <div class="icarus-field field-litigation_selector label-vertical required" data-field-id="2">
                        <select name="litigation_selector">
                            <option value="Personal Injury">Personal Injury</option>
                            <option value="Contract Dispute">Contract Dispute</option>
                        </select>
                    </div>
                    
                    <div class="icarus-field field-litigation label-vertical required" data-field-id="3">
                        <input type="hidden" name="litigation" />
                    </div>
                </div>    
            </div>
            
            <button type="submit" class="submit-btn">Submit Evaluation</button>
        </form>
    </div>
</div>

Now, say we want to listen to the change event of the litigation_selector, updating the litigation with the selected value. You would be tempted to do something like:

$('#form-selector').on('change', '.field-litigation_selector select', (evt) => {
    $('#form-selector .field-litigation input').val($(evt.target.value));
});

The change event will never fire, this due to the fact that the litigation_selector field will re-render itself on change of value, preventing the bubble-up of the event. Alternatively, you can listen on focusout events or bind to the form instead (e.g. $('form').change).