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

@calderajs/form-builder

v1.2.5

Published

> Install from [npmjs](https://www.npmjs.com/package/@calderajs/form-builder) > `yarn add @calderajs/form-builder`

Downloads

15

Readme

Calderajs Form Builder

Install from npmjs > yarn add @calderajs/form-builder

Components for building the Caldera Forms form builder. This library is used in caldera-forms/clients/form-builder/index.js

The boundry between this library and that file should be that in CF, componets interact with the DOM and legacy state. Everything below that, goes here. That's why it's one file.

The components in Caldera Forms core mainly do not render anything, they just bind to DOM events to watch for changes in state.

Usage

Import Components

See src/exports.text.ts for the full list of importable elements.

import {
  SubscribesToFormFields,
  useCurrentFormFields,
  useNotAllowedFields,
  useFormFields,
  SelectFormField,
  Page,
  Section,
  ProcessorConditionalEditor,
  prepareConditionalForSave,
  prepareConditionalsForSave,
  conditionalsFromCfConfig,
  conditionalFromCfConfig,
  useProcessorConditonals,
  useConditionals,
  ConditionalEditor,
  RenderViaPortal,
} from '@calderajs/form-builder';

Use Portals Always

Beacuse this library lives on the same page as legacy code, we will never render on the element provided to ReactDOM. Instead Portals are always used. The RenderViaPortal component should be used for this:

import { RenderViaPortal } from '@calderajs/form-builder';

function SomethingPortal() {
  const node = document.getElmentById(`whatever`);
  if (!node) {
    return <React.Fragment />;
  }
  return (
    <RenderViaPortal domNode={node}>
      <Something />
    </RenderViaPortal>
  );
}

Context Providers

Short Intro To React Context

This package makes use of React's Context API. Context provides shared state and functions to update state between components without passing props. Doing so decouples state logic from position in the (virtual-)DOM.

The component <FormBuilder /> uses all four providers:

  • <FormFieldsProvider intitalFields={intitalFields} />
    • State for form fields
  • <MagicTagProvider systemValues={systemValues} />
    • Magic tags state. Must be under FormFieldsProvider.
  • <ConditionalsProvider initialConditionals={initialConditionals}>
    • Conditional logic state. Must be under FormFieldsProvider and MagicTagProvider providers.
  • <ProcessorsProvider initialProcessors={initialProcessors} jQuery=jQuery} />
    • Must be under FormFieldsProvider, MagicTagProvider and ConditionalsProvider providers.

Development

  • Install
    • git clone
    • yarn
  • Test
    • yarn test --watch
  • Build
    • yarn build
  • Start Storybook
    • yarn storybook

Storybook

Related documentation

This repo is intentionally isolated from Caldera Forms core to encourage test-driven development and to constrain the boundries.

You can start a Storybook site to visualize the componets.

The yarn storybook command will start a "Storybook" site. You can use this to experiment with the componets. The file .storybook\preview-head.html is used to add style tags that bring in a lot of Caldera Forms' admin styles, using CalderaForms.com. That's a hack, and isn't perfect looking at all, but it's enough for now.

Devloping With Caldera Forms

It reamins neccasary, to test with Caldera Forms. You should use Yarn Link to install this project via symlink in Caldera Forms.

  • In this directory, build for production.
    • yarn build
  • In this directory, enable other projects to link to this project.
    • yarn link
  • In Caldera Forms, link to this project
    • yarn link @calderajs/form-builder
  • In Caldera Forms, rebuild clients
    • yarn build:clients

Releasing A Version And Updating In Caldera Forms

Related Docs

Using link to test before releasing an update is strongly encouraged. After doing so, you must unlink the package, release an update and update Caldera Forms.

Before begining, make sure you are logged in to npmjs.com using Yarn's cli. Also, make sure you are Josh or Nico. If you are not Josh or Nico, please open a message in the engineering team in Basecamp and request you be granted acess. Please tag Josh and Nico and include your npmjs.com username in the message.

Please follow these steps:

  • In Caldera Forms, unlink
    • yarn unlink @calderajs/form-builder
  • In this directory, unlink
    • yarn link
  • In this directory, publish
    • yarn publish
    • You will be prompted to provide a new version.
    • Please observer semver
  • In Caldera Forms force reinstall old version -- removing symlink totally.
    • yarn install --force
  • In Caldera Forms, add the new version
    • yarn add @calderajs/form-builder@<new-version>