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

@marianmeres/questionnaire

v1.1.1

Published

[![NPM](https://img.shields.io/npm/v/@marianmeres/questionnaire)](https://www.npmjs.com/package/@marianmeres/questionnaire) [![JSR](https://jsr.io/badges/@marianmeres/questionnaire)](https://jsr.io/@marianmeres/questionnaire) [![License](https://img.shiel

Readme

@marianmeres/questionnaire

NPM JSR License

Low-level, framework-agnostic primitive for building multi-step forms ("questionnaires") from plain, serializable definitions — with per-field validation and conditional visibility. Not a form builder — the layer a form builder would sit on top of. Zero dependencies.

What you get

  • Definition format — plain JSON: steps[]fields[] with semantic field types (text, number, boolean, choice, choices, date), JSON-Schema-shaped validation rules (minLength, pattern, minimum, ...) and conditional visibility (showIf) in the condition-builder dump format. Authoring or generating configs elsewhere? See the field-by-field config authoring guide.
  • Stateless helpers — pure (config, values) functions: validateConfig, validateAnswers (e.g. server-side re-validation of a submission), resolveVisibility, extractAnswers, evaluateCondition.
  • Runtime enginecreateQuestionnaire(): a small reactive state container (Svelte store contract) owning values, touched flags, errors, visibility and per-step complete gating.

Installation

deno add jsr:@marianmeres/questionnaire
npm install @marianmeres/questionnaire

Usage

import { createQuestionnaire } from "@marianmeres/questionnaire";

const q = createQuestionnaire({
	steps: [
		{
			id: "lifestyle",
			title: "Lifestyle",
			fields: [
				{
					name: "diet",
					type: "choice",
					title: "Any diet or dietary restrictions?",
					description: "Including food allergies, intolerances and veganism.",
					options: [
						{ value: "yes", label: "yes" },
						{ value: "no", label: "no" },
					],
					ui: { control: "radio" }, // opaque hint — the engine never reads it
				},
				{
					name: "diet_detail",
					type: "text",
					title: "Please specify",
					required: true,
					// show only when diet === "yes"
					showIf: [{
						expression: { key: "diet", operator: "eq", value: "yes" },
						operator: "and",
					}],
					validate: { maxLength: 500 },
				},
			],
		},
	],
});

q.subscribe(({ steps, fields, valid, complete }) => {
	// render... (or use $q auto-subscription in Svelte)
});

q.setValue("diet", "yes");
q.get().fields.diet_detail.visible; // true
q.setValue("diet_detail", "vegan");
q.markTouched("diet_detail"); // typically on blur — reveals errors in your UI

q.dump(); // { diet: "yes", diet_detail: "vegan" }

Semantics worth knowing

  • "Only filled answers are submitted"required defaults to false; dump()/state.answers contain only visible and filled fields. false and 0 count as answers; "", [], null, undefined do not.
  • text is trimmed — leading/trailing whitespace is stripped before validating and extracting, so " " reads as unanswered and a padded answer is submitted without the padding. The raw value stays in state while editing (so typing a trailing space works); only the answer is trimmed. Other types are untouched.
  • Hidden ≠ deleted — a hidden field's value survives in state (flip the condition back and it reappears) but the field is never validated and never appears in answers.
  • Conditions see effective answers — hidden or unfilled fields read as undefined in showIf evaluation, so hiding cascades correctly through chains. Circular showIf dependencies are rejected by validateConfig.
  • Required-empty is a validation error — a pristine questionnaire with required fields is not valid; UIs typically reveal an error only once its field is touched (that is what touched is for). Gate forward navigation on StepState.complete.
  • The engine does not navigate — pair it with @marianmeres/wizard (or a few lines of app code) and gate next() on the current step's complete.
  • Conditions are authorable as stringsshowIf takes the parsed AST, so you can write "diet:yes" and convert it at authoring time with @marianmeres/condition-parser (the engine itself stays zero-dependency).

Examples

Working browser examples built with @marianmeres/vanilla live in example/:

deno task example:build
deno task example:serve
# open http://localhost:8000

Documentation

  • API.md — complete public API reference.
  • Config authoring guide — self-contained, field-by-field reference aimed at whoever produces the config JSON (e.g. a separate backend team): every type, field, validation rule, showIf operator, and the exact shape of the submitted answers.
  • example/ — runnable browser demos.

License

MIT