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-element

v0.2.4

Published

`@moluoxixi/config-form-element` 是面向 Element Plus 输入组件的轻量配置表单。

Readme

ElementConfigForm

@moluoxixi/config-form-element 是面向 Element Plus 输入组件的轻量配置表单。

  • 根节点使用原生 <form>,字段使用包内自有 label/control/error 壳;
  • inline 布局使用原生 Flex,grid 布局使用原生 CSS Grid;
  • 字段默认通过 modelValue + update:modelValue 写回外部模型;
  • 校验、reset、submit 和 readonly 语义统一由 @moluoxixi/config-form-headless 提供;validateOn 控制 change/blur 校验触发且 submit 校验始终启用;适配器同时透传独立的 dirty/touched 状态、metaChange、默认 slot metagetMeta / getFieldMeta / setTouched

组件不使用 ElFormElFormItemElRowElCol 或 Element Plus rulesformAttrs 传给原生 form,layoutAttrs / cellAttrs 分别传给原生布局和 grid cell div;布局由 columnsgapfieldSpan 和字段 span 控制。

<script setup lang="ts">
import { defineFields } from '@moluoxixi/config-form-headless'
import { ElementConfigForm } from '@moluoxixi/config-form-element'
import '@moluoxixi/config-form-element/styles'
import { ElInput, ElTag } from 'element-plus'
import { h, shallowRef } from 'vue'
import { z } from 'zod'

interface UserForm {
  locked: boolean
  name: string
}

const model = shallowRef<UserForm>({ locked: false, name: '' })
const { defineField } = defineFields<UserForm>()
const fields = [
  defineField({
    component: ElInput,
    field: 'name',
    label: '姓名',
    props: { placeholder: '请输入姓名' },
    required: true,
    schema: z.string().trim().min(2, '姓名至少 2 个字符'),
    validateOn: 'blur',
    readonly: values => values.locked,
    readonlyRender: ({ value }) => h(ElTag, null, () => value || '-'),
  }),
]
</script>

<template>
  <ElementConfigForm v-model="model" :fields="fields" :form-attrs="{ autocomplete: 'off' }" :columns="12" gap="16px" />
</template>

语义组件注册

适配器内置 texttextareanumberbooleanselect 别名,因此 schema 可以直接写 component: 'text'components prop 可注册业务别名或覆盖同名默认项;完整注册项还可提供默认 props 和绑定协议,字段上的显式配置优先。

内置别名分别定义在 src/materials/<name>.ts,由构建期文件扫描生成 ELEMENT_CONFIG_FORM_COMPONENTSELEMENT_CONFIG_FORM_MATERIAL_REGISTRY 可用于检查物料来源与确定性顺序;业务扩展仍通过 components prop 注册,不依赖扫描器。

const fields = [defineField({ component: 'text', field: 'name', label: '姓名' })]

节点的 extensions 供设计器和业务插件读取,不会透传给 Element Plus 组件或 DOM。

节点与布局

包含 field 的节点绑定模型并参与 Headless 生命周期;没有 field 的节点是纯容器。配置化 slots 会递归处理,render-function slot 只负责自定义渲染。

visiblehiddendisabledreadonlyrequired 支持布尔值或 (values) => boolean。readonly 字段跳过校验但保留提交值。

inline 布局不消费 span / cellAttrs;grid 布局将 span 映射到 CSS Grid,并把 cellAttrs 作为原生 div attributes。getValueFromEvent 可覆盖默认的首参数取值逻辑。