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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fig-tree-editor-react

v0.8.2

Published

React component for constructing FigTree Evaluator expressions

Readme

fig-tree-editor-react

Demo/Playground

A React component for constructing and editing FigTreeEvaluator expressions.

It's built on json-edit-react (a JSON/object data viewer/editor), so usage is basically the same as for that component. The main addition is the use of Custom Nodes to handle the specifics of FigTree expressions, providing validation and custom UI to select and manipulate the various operators.

Your best bet is to have a play with the Demo to get a feel for it.

Installation

npm i fig-tree-builder-react

or

yarn add fig-tree-builder-react

Implementation

import { FigTreeEditor } from 'fig-tree-builder-react'

// In your React component:
return 
  <FigTreeEditor
    // These 3 props are required, the rest are optional
    figTree={figTree} // your FigTree instance
    expression={expressionObject} // your FigTree expression object
    setData={ (data) => updateMyExpression(data) } // function to update your expression object
    { ...otherProps } />

Available props

The majority of props are those for json-edit-react, so won't be covered here. The ones specific to this component are:

Required

| Prop | Type | Default | Description | | --------------- | ---------------------------------------- | ------- | ---------------------------------------- | | figTree | FigTreeEvaluator | | A FigTree instance to run evaluations on | | expression | EvaluatorNode(object/array/value) | | The FigTree expression | | setExpression | (data: EvaluatorNode) => void | | React state update function |

Optional

| Prop | Type | Default | Description | | ------------------------------ | ----------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | objectData | object | | Data object accessed by FigTree's getData/objectProperties operator. | | | onEvaluate | (value: unknown, e: React.MouseEvent) => void | | Optional function to call on the evaluated result after clicking one of the "Evaluate" buttons. Can be used (for example) to display a Notification with the result. | | onEvaluateStart | () => void | | Called when an "Evaluate" button is clicked. Some evaluations can take some time (e.g. network requests), so this can be used to trigger a "Loading" indicator. | | operatorDisplay | Operator Display Data | | Used to set the background and text colours for the various Operator "Evaluate" buttons. See [below] for details. | | | defaultNewOperatorExpression | EvaluatorNode | | Expression to populate the UI with when switching to a new "Operator" node | | | defaultNewFragment | string | | Name of the Fragment to default to when switching to new "Fragment" node | | | defaultNewCustomOperator | string | | Name of the Custom Operator to default to when switching to new "Custom Operator" node | | | addTopLevelFallback | any | | If defined, the specified value will be inserted as a fallback when selecting a new operator/fragment at the top level only. This offers an option to ensure protection against evaluator errors lower in the tree. | |

Operator UI customisation

You can override the colour scheme for each operator in the UI by passing in an object to the operatorDisplay prop. Each operator can have the backgroundColor, textColor and displayName defined — see defaults file for specific structure.

You can also specify the colours for Fragments and Custom Operators in their metadata definitions.

Help, Feedback, Suggestions

Please open an issue: https://github.com/CarlosNZ/fig-tree-editor-react/issues

Changelog

  • v0.7.10:
    • When switching Fragments, remove old fragment properties
  • v0.7.9:
    • Switching node type (operator/fragment/custom operator) auto-focuses the operator/fragment selector menu
    • Add addTopLevelFallback prop
  • v0.7.8:
    • props to set default expression, fragment and custom operator
  • v0.7.5:
    • Fix possible infinite re-render when loading new expression
  • v0.7.1:
    • Improve type definitions for styles input
    • Pass "event" to onEvaluate function
  • v0.7.0:
    • Use updated editor package (json-edit-react) in order to restrict to enum values when appropriate
    • Correct defaults for all operator properties
  • v0.6.6: Respect editing restrictions in Custom Nodes
  • v0.5.0 – v0.6.5: Initial release