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

vue-labelset-editor

v0.1.0

Published

A Vue component for creating and editing annotation label sets: labels, colours, order, relation labels, bulk entry and JSON import/export.

Readme

vue-labelset-editor

A Vue component for creating and editing annotation label sets: labels and their colours, their order, relation labels, bulk entry and JSON import/export.

npm install vue-labelset-editor
<script setup lang="ts">
import { ref } from "vue";
import { LabelsetEditor, isValidLabelset, type Labelset } from "vue-labelset-editor";
import "vue-labelset-editor/style.css";

const labelset = ref<Labelset>({ name: "", desc: "", labels: [], relation_labels: null });
const editor = ref<InstanceType<typeof LabelsetEditor>>();

async function save() {
  if (!isValidLabelset(labelset.value)) return editor.value?.revealIssues();
  await fetch("/api/labelsets", { method: "POST", body: JSON.stringify(labelset.value) });
}
</script>

<template>
  <LabelsetEditor ref="editor" v-model="labelset" />
  <button @click="save">Save</button>
</template>

The component stores nothing and sends nothing. It edits the labelset it is given through v-model and reports what is wrong with it; the host decides where it goes and puts its own Save button next to it.

The labelset

interface Labelset {
  name: string;
  desc: string;
  labels: { name: string; color: string }[]; // order matters: it sets each label's hotkey
  relation_labels?: string[] | null;         // null: the default set
}

relation_labels set to null means "use the default relation labels" (DEFAULT_RELATION_LABELS, the same eight legal-annotation-kit offers). Customising them stores the list on the labelset, ready to pass to legal-annotation-kit's relationLabels.

What it does

  • Labels with a colour picker. New labels get the next unused colour from a palette of twenty that are easy to tell apart.
  • Reordering by dragging, or with the arrow buttons. Each row shows the key that arms the label in legal-annotation-kit: 1–9, 0, then a–z.
  • Paste a list: one label per line, optionally followed by a colour (Obligation #d62728). Lines that can't be added are shown with the reason and stay in the box to be fixed; when every line is added the panel closes.
  • Import JSON reads a file exported by this component, a whole legal-annotation-kit task file (its labelset), or a bare array of labels. Export JSON saves the labelset.
  • Undo all changes brings back the labelset as it was when the editor opened.
  • Problems are shown next to the field or row they concern, once that field has been edited, so a blank labelset doesn't open covered in errors. A labelset that arrives with labels shows its problems straight away.

Props

| Prop | Default | | |---|---|---| | v-model | required | The Labelset being edited. | | locked | false | For a labelset already in use: labels can be recoloured and reordered, but not added, removed or renamed; relation labels are fixed. | | lockedMessage | a sentence | Shown above the labels when locked. | | withRelationLabels | true | Show the relation labels section. | | requireDescription | true | Whether an empty description counts as a problem. | | hotkey | 1–9, 0, a–z | (index) => string, the key shown per label. null hides the keys. |

Events: issues with the current list of problems, every time it changes, including problems not shown yet.

Methods (through a template ref): revealIssues() shows every problem, for when Save is pressed while some remain.

Rules

A name — of the labelset, a label or a relation label — is required, has no leading or trailing spaces or repeated spaces, is at most 60 characters, and uses letters and digits in any script plus - _ ' ( ) & / .. Label names and relation label names are unique, ignoring case. Colours are #rrggbb.

Without Vue

The rules and helpers are also published on their own, for a server checking what it receives:

import { validateLabelset } from "vue-labelset-editor/model";

const issues = validateLabelset(body); // [] when valid

Also exported: nameProblem, nextColor, PALETTE, parseLabelList, labelsetToJson, labelsetFromJson, DEFAULT_RELATION_LABELS.

Development

pnpm install
pnpm dev      # demo page
pnpm test     # vitest
pnpm build

License

MIT