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

f3

v0.0.23

Published

Form tree (AKA F3), is a module to create dynamic (client-side) decision trees (D3) with forms

Downloads

7

Readme

F3

Form tree (AKA F3), is a module to create dynamic (client-side) decision trees (D3) with forms.

Dependencies

This first implementation of F3 has some several dependencies:

Instalation

With NPM (using Browserify):

npm install f3 --save

Then, in your front-end module:

var formTree = require('f3')();

Standalone

Copy the file dist/f3.js or dist/f3.min.js in your project.

Then, in your .js:

var formTree = f3();

Finaly, to use the formTree variable, see the available methods, configurations and examples.

Methods

  • formTree.init(): This method load all F3 components/types, subscribers and validations.

  • formTree.render($target, tree): This method allow render an instance of F3 inside a specific jQuery selector ($target) using the description of the tree object.

Configuration

The tree object

This object has all the definitions for the creation of the decision tree. For example, the follow object create a F3 with 3 branches:

  • The first branch show a question with two options
  • If the user select Yes, another question/branch appears
  • Else, if the user select No, the user see the final branch to send the responses
var tree = {
	
	//Every branch is an object inside the array branches
	'branches': [
		
		//First visible branch
		{
			//Every branch need an ID
			'branch': '1',

			//Form components are inside the html array
			'html': [

				//A decision component 
				{

					//Component type
					'type': 'decision',

					//The question for the user
					'question': 'Do you like ice cream?',

					//The options to answer
					'options': [

						{
							//Label to show
							'text': 'Yes',
							//If the user select this option, show the branch 1.1
							'branch': '1.1'
						},

						{
							//Label to show
							'text': 'No',
							//If the user doen't like ice cream, show the branch 2
							'branch': '2'
						}

					]

				}

			]

		},

		//Branch 1.1
		{
			//The ID has to be in the format x.x
			'branch': '1.1',
			'html': [

				//This branch has a text component
				{

					'type': 'text',
					'question': 'What flavor do you like?',

					//Validation rules
					'validation': {
						'rules': {
							'required': true
						},
						'messages': {
							'required': 'You need write a flavor'
						}
					}

				},

				//And a next component
				{
					'type': 'next',

					//Label of the button
					'text': 'Next',

					//Go to the final branch
					'branch': '2',

					//But before validate if the user complete the flavor 
					'validate': true

				}

			]

		},

		//The final branch
		{
			'branch': '2',

			//This branch has only an send component
			'html':
			[

				//This component allow know when the user finish the F3
				{
					'type': 'send',
					'text': 'Send'
				}

			]

		}

	]

};

See this example working.

TODO

  • Explain every F3 component and configuration

  • Add more examples

  • Use less dependencies

  • Add tests