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

@happening-oss/expr2sql-editor

v1.0.0

Published

Autocomplete expression builder for expr-lang

Downloads

5

Readme

An auto-complete query builder for expr-lang expressions, designed for intuitive filtering and search. Compatible with expr2sql. 🚀 Try the live demo: Click here!

Features

  • 📝 Auto-complete with field and operator suggestions
  • 🔍 Syntax validation for expressions
  • 🎛️ Custom input components for specific data types

Getting Started

Install from npm:

npm i @happening-oss/expr2sql-editor

Define the target element:

<div id="editor"></div>

Initialize the ExprEditor component:

import { ExprEditor } from '@happening-oss/expr2sql-editor';
import '@happening-oss/expr2sql-editor/style.css';

// define the doc
const doc = {
  variables: {
    intField: {
      name: 'intField',
      kind: 'int',
    },
    stringField: {
      name: 'stringField',
      kind: 'string',
    },
  },
};

// initialize the editor
const editorRef = document.querySelector('#editor');
const editor = new ExprEditor(editorRef, {
  rawValue: 'intField > 1234',
  doc,
  onInput: (value) => {
    console.log('value changed', value);
  },
});

Configuration

ExprEditor accepts two parameters, one is the target element which the editor loads in. The other is the configuration object.

const editor = new ExprEditor(target, options);

Raw input vs expression

The editor supports both free-text search and structured expressions. A separator (eg. :) defines where the structured expression begins. The whole input value is the "raw value" and its form is <search><separator><expression>. Examples when the separator is ::

| Raw value | | Search | Expression |--|--|--|--| |test123:field1 == "Foo"| Search + expression | test123 | field1 == "Foo" | |some string|Just search| some string | | |:timestamp < '2025-01-01'|Just expression| | timestamp < '2025-01-01' |

type Props = {
  /** Separates search and expression, eg. with ':', 'text:prop == value' is possible */
  separator?: string;
  /** The raw input value */
  rawValue?: string;
  /** Triggers whenever input changes */
  onInput?(value: string): void;
  /** Same as above but with the parsed input */
  onChange?(event: { search?: string; expression?: string; active?: boolean; }): void;
  /** Triggers when 'Enter' key is pressed */
  onEnter?(value: string): void;
  /** See: Field information */
  doc: Doc;
  /** See: Custom inputs */
  customInputs?: CustomInputs;
  /** Input placeholder */
  placeholder?: string;
  /** Element classes */
  class?: string;
}

Field information

Autocomplete and suggestions require the doc option to be set. It contains all of the available fields and optionally the operators. Example:

const doc: Doc = {
  variables: {
    stringField: {
      name: 'stringField',
      kind: 'string',
    },
    /** String field but suggests a predefined list of values */
    selectField: {
      name: 'selectField',
      kind: 'string',
      values: [
        'started',
        'inprogress',
        'finished',
        'failed',
      ],
    },
    /** Field with a custom format defined, which is used for custom inputs */
    timestampField: {
      name: 'timestampField',
      kind: 'string',
      format: 'date',
    },
    boolField: {
      name: 'boolField',
      kind: 'bool',
    },
    intField: {
      name: 'intField',
      kind: 'int',
    },
    jsonField: {
      name: 'jsonField',
      kind: 'struct',
      fields: {
        stringProp: {
          name: 'stringProp',
          kind: 'string',
        },
        boolProp: {
          name: 'boolProp',
          kind: 'bool',
        }
      },
    },
  },
};

Custom fields

Custom components to input values can be rendered to easier input values for fields. Custom components can be defined with the customInputs option which contains the following object:

{ [format: string]: ComponentCreator; }
export type ComponentCreator = (root: HTMLElement, args: ComponentParams) => Component;

export type ComponentParams = {
  value: Token | null | undefined;
  onInput(value: string, kind: string, close?: boolean): void;
  onKeyDown(e: KeyboardEvent): void;
}

export type Component = {
  update(value: Token): void;
  destroy(): void;
  focus(): void;
}

When a field doc contains a format field (eg. myField: { format: 'date' }), when entering this field (myField == ...) the exitor will then show this custom input in the dropdown.

Example:

import AirDatepicker from 'air-datepicker';
import 'air-datepicker/air-datepicker.css';
import localeEn from 'air-datepicker/locale/en';

const customInputs = {
  date: (node, { value, onInput }) => {
    const date = value ? value.value.replaceAll('"', '') : null;
    const picker = new AirDatepicker(node, {
      inline: true,
      selectedDates: [date],
      locale: localeEn,
      onSelect({ date }) {
        if (Array.isArray(date)) {
          return;
        }
        onInput(`"${date.toISOString()}"`, '', false);
      },
    });
  
    return {
      update(selectedToken) {
        const date = selectedToken ? selectedToken.value.replaceAll('"', '') : null;
        picker.selectDate(date, { silent: true });
      },
      focus() {

      },
      destroy() {
        picker.destroy();
      }
    }
  }
}