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

@moluoxixi/config-form

v0.2.5

Published

Vue 3 配置化表单。所有表单只通过 Headless controller 和 ConfigFormRenderer 执行;ConfigForm 是带字段预处理的薄组件。

Readme

@moluoxixi/config-form

Vue 3 配置化表单。所有表单只通过 Headless controller 和 ConfigFormRenderer 执行;ConfigForm 是带字段预处理的薄组件。

使用

<script setup lang="ts">
import { shallowRef } from 'vue'
import { ConfigForm } from '@moluoxixi/config-form'
import { createConfigFormModel, defineFields } from '@moluoxixi/config-form-headless'
import { ElInput } from 'element-plus'
import { createElementPlusPlugin } from '@moluoxixi/config-form-plugin-element-plus'

const values = shallowRef({ name: '' })
const model = createConfigFormModel(values)
const { defineField } = defineFields<typeof values.value>()
const fields = [
  defineField({ id: 'name', field: 'name', component: ElInput, label: '姓名', required: true, validateOn: ['blur'] }),
]
const runtime = { plugins: [createElementPlusPlugin()] }
</script>

<template>
  <ConfigForm :model="model" :fields="fields" :runtime="runtime" />
</template>

模型合同

model 是必传的同步 { read, write } 端口。可以使用 createConfigFormModel(ref),也可以连接 Vue 响应式 store;read() 必须读取响应式状态,write(next) 返回前必须能读到新值。异步请求和审核在调用写入前完成。表单不维护模型镜像,不通过 update:modelValue 等待父组件确认。

changefieldChangemetaChangeerrorsChangesubmiterror 是通知事件。defaultValues 定义 reset 基线,resetFields() 重置;setValuesetValuesgetValuesvalidateFieldvalidatesubmit 都使用同一个模型端口。

两个入口

  • ConfigFormRenderer 消费 Headless 字段节点,提供原生 form、响应式 Grid/Flex、ARIA、嵌套 slots、readonly、校验和 reaction。
  • ConfigForm 在进入 Renderer 前执行 runtime.plugins,合并组件绑定默认值、转换字段、解析嵌套节点,并将 readonly adapter 接为字段 readonlyRender。它没有第二套状态机。

所有节点必须有稳定 id。组件与 slot 函数使用 Vue/Headless 当前合同;slot 上下文包含 modelmetaslotProps,字段 slot 另有 fieldvaluesetValue。不再提供旧 FormLayout、RecursiveField、FormContext 或 useForm 模板链路。

插件

runtime 接受 FormRuntimeOptions,可配置 componentspluginsreadonlyAdaptersgetDefaultFieldtransformField 只处理字段配置,不拥有表单值、校验队列或提交行为。字段显式配置优先于注册默认值;未知组件 key、重复插件名及冲突注册会抛出带 code/context 的 ConfigFormError

底层纯预处理 API 从 @moluoxixi/config-form/plugins 导入。单独调用 transformField 不会执行校验或 reaction。

样式与验证

默认命名空间为 mx-config-form,默认 columns/fieldSpan 为 24、gap 为 16px。布局规则来自 Core,Designer、Renderer 与 Source 共用。

import '@moluoxixi/config-form/styles'
pnpm --filter @moluoxixi/config-form test
pnpm --filter @moluoxixi/config-form typecheck
pnpm test:config-form-packages