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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@eavfw/expression-builder

v1.1.3

Published

A powerful React component for building dynamic expressions with function suggestions and parameter hints.

Downloads

20

Readme

Expression Builder

A powerful React component for building dynamic expressions with function suggestions and parameter hints.

Expression Builder Demo

Features

  • 🔍 Real-time function suggestions
  • 📝 Parameter hints and documentation
  • 🎯 Nested function support
  • 🎨 Beautiful UI with Tailwind CSS
  • 💪 Full TypeScript support

Installation

npm install @eavfw/expression-builder

Quick Start

import { 
  ExpressionProvider,
  ExpressionInput,
  FunctionPanel,
  SingleLineInput
} from '@eavfw/expression-builder';

function App() {
  return (
    <div className="space-y-8">
      {/* Multi-line expression input */}
      <div className="bg-white rounded-lg shadow-lg p-6">
        <h2 className="text-lg font-semibold mb-4">Multi-line Expression</h2>
        <ExpressionProvider>
          <ExpressionInput />
          <FunctionPanel />
        </ExpressionProvider>
      </div>

      {/* Single-line expression input */}
      <div className="bg-white rounded-lg shadow-lg p-6">
        <h2 className="text-lg font-semibold mb-4">Single-line Expression</h2>
        <ExpressionProvider>
          <SingleLineInput />
          <FunctionPanel />
        </ExpressionProvider>
      </div>
    </div>
  );
}

Basic Usage

For simpler use cases, you can use individual components with the context:

import { ExpressionProvider, ExpressionInput } from '@eavfw/expression-builder';

function SimpleExpression() {
  return (
    <ExpressionProvider>
      <ExpressionInput />
    </ExpressionProvider>
  );
}

Context and State Management

The Expression Builder uses React Context for state management. You can wrap your components with ExpressionProvider to access the shared state:

import { ExpressionProvider } from '@eavfw/expression-builder';

function App() {
  return (
    <ExpressionProvider>
      <ExpressionInput />
      <FunctionPanel />
    </ExpressionProvider>
  );
}

Using the Context

Access the expression context in your components using the useExpressionContext hook:

import { useExpressionContext } from '@eavfw/expression-builder';

function CustomInput() {
  const { state, updateInput, selectFunction } = useExpressionContext();

  return (
    // Your component implementation
  );
}

Context API

The expression context provides:

  • state: Current expression state including:

    • input: Current input value
    • cursorPosition: Current cursor position
    • isExpression: Whether currently typing a function
    • activeFunction: Currently active function
    • parameterIndex: Current parameter being edited
    • suggestions: Available function suggestions
  • updateInput(value: string, cursorPosition: number): Update input value

  • selectFunction(func: FunctionDefinition, cursorPosition: number): Select a function

  • dispatch: Direct access to the state reducer (advanced usage)

Usage

  1. Start your expression with @ to see function suggestions
  2. Select a function from the suggestions dropdown
  3. Fill in the function parameters
  4. For nested functions, type the function name directly (without @) as a parameter

Example:

// Correct usage - @ only at the start of expression
@concat("Hello", upper("World"))

// Incorrect usage - don't use @ for nested functions
@concat("Hello", @upper("World"))  // Wrong!

Custom Functions

You can define your own functions by creating a function library:

import { FunctionDefinition } from '@eavfw/expression-builder';

const customFunctions: FunctionDefinition[] = [
  {
    name: 'greet',
    description: 'Generates a greeting message',
    parameters: [
      {
        name: 'name',
        type: 'string',
        description: 'Person to greet'
      }
    ],
    returnType: 'string',
    examples: ['@greet("John") → "Hello, John!"'],
    category: 'text'
  }
];

API Reference

Components

ExpressionInput

Props:

  • state: ExpressionState - Current state of the expression
  • onInputChange: (value: string, cursorPosition: number) => void - Input change handler
  • onFunctionSelect: (func: FunctionDefinition, cursorPosition: number) => void - Function selection handler

FunctionPanel

Props:

  • activeFunction: FunctionDefinition | null - Currently active function
  • parameterIndex: number - Index of the current parameter being edited

Hooks

useExpression

Returns:

  • state: ExpressionState - Current expression state
  • updateInput: (value: string, cursorPosition: number) => void - Update input handler
  • selectFunction: (func: FunctionDefinition, cursorPosition: number) => void - Function selection handler

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

MIT © EAVFW Contributors