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

zan-admin-form

v0.1.0

Published

Schema-driven admin form designer and renderer for Zan ecosystem

Readme

zan-admin-form

Schema-driven form designer and renderer for the Zan component ecosystem.

zan-admin-form is intentionally independent from business payloads. It renders JSON form schemas, validates values, handles simple conditional visibility, and builds submit payloads through a declarative map. Business-specific adapters should live in the consuming app.

Install

npm install zan-admin-form

Use

<script setup lang="ts">
import { ref } from 'vue';
import { ZanFormRenderer, type ZanFormSchema } from 'zan-admin-form';
import 'zan-admin-form/style';

const values = ref({});

function handleSubmit(result) {
  // Send result.payload to the business action adapter.
}

const schema: ZanFormSchema = {
  title: 'Batch price update',
  layout: { labelWidth: 96, columns: 24 },
  sections: [
    {
      id: 'main',
      title: 'Price settings',
      fields: [
        {
          field: 'mode',
          label: 'Mode',
          component: 'radio-group',
          span: 24,
          required: true,
          defaultValue: 'fixed',
          options: [
            { label: 'Fixed', value: 'fixed' },
            { label: 'Amount', value: 'amount' },
            { label: 'Percent', value: 'percent' }
          ]
        },
        {
          field: 'direction',
          label: 'Direction',
          component: 'select',
          span: 12,
          visibleWhen: { field: 'mode', in: ['amount', 'percent'] },
          options: [
            { label: 'Increase', value: 'increase' },
            { label: 'Decrease', value: 'decrease' }
          ]
        },
        {
          field: 'value',
          label: 'Value',
          component: 'input-number',
          span: 12,
          required: true,
          props: { min: 0, step: 0.01 }
        }
      ]
    }
  ],
  submit: {
    map: {
      priceMode: '$form.mode',
      direction: '$form.direction',
      value: '$form.value'
    }
  }
};
</script>

<template>
  <ZanFormRenderer v-model="values" :schema="schema" @submit="handleSubmit" />
</template>

Schema Boundary

Supported first batch:

  • layout: title, description, sections, tabs, grid columns, label width
  • fields: input, textarea, input-number, select, radio-group, checkbox-group, switch, date, time, divider, custom
  • runtime: default values, required/min/max/pattern validation, visibleWhen, dynamic child branches, submit payload mapping
  • designer: basic schema editing plus raw JSON editing

Business-specific components should be registered through customComponents:

<ZanFormRenderer :schema="schema" :custom-components="{ 'region-picker': RegionPicker }" />

The schema selects component: 'custom' and customType: 'region-picker'; the app owns the component behavior and old payload compatibility.

Dynamic Branches

Options can declare child fields or sections. The renderer activates the matching branch from the current field value, fills child defaults, validates only active children, and removes inactive branch values from submit values.

Dynamic branches are flattened into the same section grid. They are not rendered as an indented tree; parent-child relationships affect visibility and data only.

const schema: ZanFormSchema = {
  sections: [
    {
      fields: [
        {
          field: 'scene',
          label: 'Scene',
          component: 'radio-group',
          defaultValue: 'crowd',
          options: [
            {
              label: 'Crowd',
              value: 'crowd',
              fields: [
                {
                  field: 'crowdType',
                  label: 'Crowd type',
                  component: 'select',
                  defaultValue: 'oldCustomer',
                  options: [
                    { label: 'Old customer', value: 'oldCustomer' },
                    { label: 'New customer', value: 'newCustomer' }
                  ]
                }
              ]
            },
            {
              label: 'Keyword',
              value: 'keyword',
              fields: [
                {
                  field: 'keywordLimit',
                  label: 'Keyword limit',
                  component: 'input-number',
                  defaultValue: 50
                }
              ]
            }
          ]
        }
      ]
    }
  ]
};

Fields can also use children for switch or condition-driven branches:

{
  field: 'smartOptimize',
  label: 'Smart optimize',
  component: 'switch',
  defaultValue: true,
  children: [
    {
      values: [true],
      fields: [
        { field: 'optimizeTarget', label: 'Target', component: 'select' }
      ]
    }
  ]
}