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

@patternfly-labs/react-form-wizard

v2.2.0

Published

A Patternfly react wizard framework.

Downloads

2,039

Readme

PatternFly Labs React Form Wizard GitHub package.json version

An opinionated framework for wizards using PatternFly.

Demo

Installation

Install dependencies

Using npm

npm install @patternfly-labs/react-form-wizard @patternfly/react-core @patternfly/react-styles

Using yarn

yarn add @patternfly-labs/react-form-wizard @patternfly/react-core @patternfly/react-styles

Setup Patternfly CSS

Import css from patternfly before importing react-form-wizard.

import '@patternfly/react-core/dist/styles/base.css'
import '@patternfly/react-styles/css/components/Wizard/wizard.css'

Concepts

Wizard structure

A wizard contains steps which contain sections which contain inputs.

import { WizardPage, Step, Section, TextInput, Select } from '@patternfly-labs/react-form-wizard'

function Example() {
   return (
      <WizardPage title="My Wizard">
         <Step label="Details" id="details-step">
            <Section label="Details">
               <TextInput label="Name" path="name" required />
               <Select label="Namespace" path="namespace" options={['default', 'namespace-1']} />
            </Section>
         </Step>
      </WizardPage>
   )
}

Item Context

The wizard works by setting an item context which inputs use as a data source. Inputs then get value or set value in the item context using path notation.

function Example() {
   return (
      <TextInput label="Name" path="metadata.name" required />
   )
}

Some inputs can change the item context, such as the ArrayInput.

function Example() {
   return (
      <ArrayInput path="resources" placeholder="Add new resource">
         <TextInput label="Name" path="metadata.name" required />
         <Select label="Namespace" path="metadata.namespace" options={['default']} required/>
      </ArrayInput>
   )
}

Working with an array of items

The root data can either be an object or an array of objects. When working with an array of objects anItemSelector can be used to set the item context specific item.

function Example() {
   return (
      <ItemSelector selectKey="kind" selectValue="Application">
         <TextInput label="Name" path="metadata.name" required />
         <Select label="Namespace" path="metadata.namespace" options={['default']} required/>
      </ItemSelector>
   )
}

ArrayInput can also be used to work with a subset of items in this case.

function Example() {
   return (
      <ArrayInput path={null} filter={(item) => item.kind === 'Subscription'}>
         <TextInput label="Name" path="metadata.name" required />
         <Select label="Namespace" path="metadata.namespace" options={['default']} required/>
      </ArrayInput>
   )
}

Input common properties

  • label - The label for the input.
  • path - The path the input is getting and setting value to, in the current item context.
  • id - Optional id of the input control. Used for testing. If not set, defaults to a sanitized version of the path.
  • validation - Optional validation function that takes in the current item context and input value. It should return an error string if there is an error.
  • hidden - Optional hidden function that takes in the current item context and returns true if the input should be hidden.

Validation

Inputs take an optional validation function. The validation function takes in the current item context and input value. It should returns a validation error string if the validation fails.

Conditional hiding

Inputs take an optional hidden function. The hidden function takes in the current item context, and returns true if the input should be hidden.

Steps and Sections automatically hide if all its inputs are hidden. This makes it easy to make a wizard with conditional flow.

Examples

See the wizards directory for example wizards.

Development

If you plan on contributing, please fork the repo and create a pull request using your fork.

  1. Clone the repo

    git clone [email protected]:patternfly-labs/react-form-wizard.git
  2. Install dependencies

    npm ci
  3. Start the project

    npm start