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

@camunda/form-playground

v0.17.4

Published

Camunda Form Playground.

Downloads

4,488

Readme

@camunda/form-playground

CI

Camunda Form Playground.

Usage

Integrate the playground into your application:

import { createCamundaFormPlayground } from 'camunda/form-playground';

const formPlayground = await createCamundaFormPlayground({
  container: document.querySelector('#container'),
  data,
  schema
});

// open preview
formPlayground.open();

// close preview
formPlayground.collapse();

// listen on editor events
const formEditor = formPlayground.getEditor();

formEditor.on('selection.changed', () => { ... });

Styling

For proper styling include the necessary stylesheets, and font used:

<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,600;1,400&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&display=swap" rel="stylesheet">

<link rel="stylesheet" href="https://unpkg.com/@camunda/[email protected]/dist/assets/form-js.css">
<link rel="stylesheet" href="https://unpkg.com/@camunda/[email protected]/dist/assets/form-js-editor.css">
<link rel="stylesheet" href="https://unpkg.com/@camunda/[email protected]/dist/assets/camunda-form-playground.css">

API

createCamundaFormPlayground => Promise<Result, Error>

Create a fully rendered form playground with options.

import { createFormPlayground } from '@camunda/form-playground';

const formPlayground = await createFormPlayground({
  container: document.querySelector('#form-playground'),
  data,
  schema
});

CamundaFormPlayground

Create a new form playground with options.

import { CamundaFormPlayground } from '@camunda/form-playground';

const formPlayground = new CamundaFormPlayground({
  container: document.querySelector('#form-playground'),
  data,
  schema
});

Options

There are several options that can be passed to the createFormPlayground or CamundaFormPlayground:

{
  container: HTMLElement,               // optional - the container to render the form playground into
  data: {},                             // required - set the initial form data
  schema: {},                           // required - set the initial form schema
  exporter: { name: '', version: '' },  // optional - set the schema exporter name and version
  layout: {},                           // optional - set the initial form layout
  editorAdditionalModules: [],          // optional - add additional modules to the form editor
  viewerAdditionalModules: [],          // optional - add additional modules to the form preview
  editorProperties: {},                 // optional - set the initial form editor properties
  viewerProperties: {},                 // optional - set the initial form preview properties
}

As an example, you can use the viewerProperties to override the default behavior to open external links in a new tab:

viewerProperties: {
  textLinkTarget: '_blank'
}

CamundaFormPlayground#open(containers?: string[]) => void

Open all or specific playground containers.

// open all
formPlayground.open();

// open specific
formPlayground.open([ 'form-preview' ]);

CamundaFormPlayground#collapse(containers?: string[]) => void

Collapse all or specific playground containers.

// collapse all
formPlayground.collapse();

// collapse specific
formPlayground.collapse([ 'form-preview' ]);

CamundaFormPlayground#get(type: String, strict: Boolean) => any

Get a service from the embedded form editor.

const eventBus = formPlayground.get('eventBus');

CamundaFormPlayground#getDataEditor() => JSONEditor

Get the embedded input data editor.

const dataEditor = formPlayground.getDataEditor();

const data = dataEditor.getValue();

CamundaFormPlayground#getEditor() => FormEditor

Get the embedded form editor.

const editor = formPlayground.getEditor();

editor.on('selection.changed', () => { ... });

CamundaFormPlayground#getForm() => Form

Get the embedded preview form.

const form = formPlayground.getForm();

form.on('submit', event => {
  console.log('Form <submit>', event);
});

CamundaFormPlayground#getResultView() => JSONEditor

Get the embedded output data view.

const resultView = formPlayground.getResultView();

const data = resultView.getValue();

CamundaFormPlayground#getSchema() => any

Get the current form schema.

CamundaFormPlayground#setSchema(schema: any) => void

Set the form schema.

CamundaFormPlayground#saveSchema() => any

Export the form schema from the embedded form editor.

const schema = formPlayground.saveSchema(schema);

console.log('exported schema', schema);

CamundaFormPlayground#attachTo(parent: HTMLElement) => void

Attach the form playground to a parent node.

CamundaFormPlayground#detach() => void

Detach the form playground from its parent node.

CamundaFormPlayground#fire(event) => void

Fire an event.

CamundaFormPlayground#on(event, fn) => void

Subscribe to an event.

CamundaFormPlayground#off(event, fn) => void

Unsubscribe from an event.

CamundaFormPlayground#destroy() => void

Remove form playground from the document.

Hacking the Project

To get the development setup make sure to have NodeJS installed. As soon as you are set up, clone the project and execute

npm install
npm start

License

MIT