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

@fishbelly/form-morph-arco

v0.3.0

Published

form-morph 官方 Arco Design 字段包,提供 28 种表单字段与布局容器

Readme

@fishbelly/form-morph-arco

form-morph 的官方 Arco Design 字段包,提供 28 种字段、展示组件与布局容器,并实现 Arco 风格的表单外壳与字段校验视觉。

引擎本身不依赖 UI 组件库;安装本包即可获得开箱可用的 Arco Design 表单组件。

安装

# npm
npm install @fishbelly/form-morph @fishbelly/form-morph-arco @arco-design/web-vue

# yarn
yarn add @fishbelly/form-morph @fishbelly/form-morph-arco @arco-design/web-vue

# pnpm
pnpm add @fishbelly/form-morph @fishbelly/form-morph-arco @arco-design/web-vue

字段包与引擎按同一版本线发布,安装时请保持 @fishbelly/form-morph 与本包版本一致(当前 0.3.x);引擎注册插件时会校验插件 API 版本,不兼容将直接报错并提示升级。

快速开始

// main.ts
import { createApp } from 'vue';
import ArcoVue from '@arco-design/web-vue';
import { createFormMorph } from '@fishbelly/form-morph';
import { createArcoPack } from '@fishbelly/form-morph-arco';
import '@arco-design/web-vue/dist/arco.css';
import '@fishbelly/form-morph/style.css';
import '@fishbelly/form-morph-arco/style.css';
import App from './App.vue';

const morph = createFormMorph({
  plugins: [createArcoPack()]
});

createApp(App).use(ArcoVue).use(morph).mount('#app');
<script setup lang="ts">
import { ref } from 'vue';
import { FormRenderer, type FormSchema } from '@fishbelly/form-morph';

const schema: FormSchema = {
  schemaVersion: 3,
  id: 'arco-demo',
  layout: { mode: 'horizontal', labelWidth: 96, gutter: 16 },
  nodes: [
    { id: 'n1', type: 'input', name: 'name', label: '姓名', validate: { required: true } },
    {
      id: 'n2',
      type: 'select',
      name: 'level',
      label: '等级',
      data: {
        source: {
          kind: 'static',
          options: [
            { label: '高', value: 'high' },
            { label: '中', value: 'medium' },
            { label: '低', value: 'low' }
          ]
        }
      }
    },
    { id: 'n3', type: 'switch', name: 'enabled', label: '启用' }
  ]
};

const values = ref<Record<string, unknown>>({});
</script>

<template>
  <FormRenderer :schema="schema" v-model="values" show-actions />
</template>

也可以直接使用全局默认实例:

import { arcoPack } from '@fishbelly/form-morph-arco';

const morph = createFormMorph({ plugins: [arcoPack] });

主题

字段包不注入自身主题:表单内 Arco 组件跟随宿主的 Arco 全局主题(body 上的 --primary-1 ~ --primary-10 RGB 三元组)。需要与设计器品牌色一致时,在应用入口统一设置这套变量即可。

字段清单

基础字段

| type | 名称 | valueType | 别名 | 常用属性 | | --- | --- | --- | --- | --- | | input | 单行文本 | string | text、text-input、string | placeholder、allowClear、maxLength | | textarea | 多行文本 | string | text-area | rows、autoSize、showWordLimit、maxLength | | password | 密码输入 | string | — | placeholder、allowClear | | number | 数字输入 | number | input-number、inputnumber | min、max、step、precision |

选择字段

| type | 名称 | valueType | 别名 | 常用属性 | | --- | --- | --- | --- | --- | | select | 下拉选择 | string | dropdown | placeholder、allowSearch、allowClear | | multi-select | 多选下拉 | string[] | multiselect、multiple-select、multi | 同上、maxTagCount | | radio | 单选框 | string | — | direction(horizontal / vertical) | | checkbox | 复选框 | string[] | — | direction | | switch | 开关 | boolean | — | checkedText、uncheckedText | | slider | 滑动条 | number | — | min、max、step、showInput | | rate | 评分 | number | — | count、allowHalf |

日期时间

| type | 名称 | valueType | 别名 | 常用属性 | | --- | --- | --- | --- | --- | | date | 日期 | timestamp | datepicker、date-picker | showTime、format、allowClear | | date-range | 日期范围 | timestamp[] | daterange、date-picker-range、rangepicker | showTime、format、allowClear | | time | 时间 | string | timepicker、time-picker | format、allowClear |

date / date-range 的值类型为时间戳(number),绑定到业务字段时如需字符串请在提交前通过值适配器转换。

高级字段

| type | 名称 | valueType | 别名 | 常用属性 | | --- | --- | --- | --- | --- | | upload | 文件上传 | file[] | file、file-upload | accept、maxSize、action、autoUpload、limit、multiple、showFileList | | cascader | 级联选择 | string[] | — | placeholder、allowSearch、changeOnSelect | | tree-select | 树选择 | string | treeselect | placeholder、allowSearch、allowClear | | color | 颜色选择 | string | — | disabledAlpha | | formula | 公式字段 | number | formula-field、computed、calc | expression、precision、prefix、suffix、emptyText |

展示与容器

| type | 名称 | kind | 别名 | 常用属性 | | --- | --- | --- | --- | --- | | static-text | 静态文本 | display | static、statictext | content、type | | card | 卡片容器 | container | — | — | | section | 分组区块 | container | — | icon、plain | | divider | 分割线 | display | line | orientation、dividerType | | tabs | 标签页 | container | — | position、variant、lazy | | collapse | 折叠面板 | container | — | accordion、bordered、defaultExpanded、lazy | | steps | 步骤 | container | — | direction、clickable、showNav、lazy | | subform | 子表单 | container | — | minRows、maxRows、defaultRows、showIndex |

容器节点通过 children 嵌套子节点,渲染时使用默认插槽承载子网格。tabs / collapse / steps 的直接子节点必须是 pane;pane 是内部结构容器,不产生值。

上传字段

  • 使用 Arco 默认上传按钮,同时支持将文件拖拽到整个字段区域;拖拽与点击共享 accept、multiple、limit 规则;超限/不支持的类型会在按钮下方提示。
  • 提交时引擎按 accept 与 maxSize(MB)做 Schema 级校验;远程文件缺少本地元信息时跳过。disabled / readonly 渲染为静态链接或数量摘要。
  • 默认 autoUpload: false,文件对象暂存在表单值中,由宿主在提交时统一上传(推荐)。默认开启多选(multiple: true),可在设计器属性面板关闭。
  • 需要自定义上传链路时,注册值适配器在 serialize 阶段上传并返回业务所需的值(如文件 ID 数组):
import { defineValueAdapter, definePlugin } from '@fishbelly/form-morph';

export const uploadAdapterPlugin = definePlugin({
  name: 'my-upload-adapter',
  version: '1.0.0',
  contributes: {
    valueAdapters: [
      defineValueAdapter({
        name: 'upload-codec',
        appliesTo: ['upload'],
        serialize: async (value) => {
          if (!Array.isArray(value)) return value;
          const uploaded = await Promise.all(
            value.map((item) => (item instanceof File ? myUpload(item) : item))
          );
          return uploaded.map((item) => item.id);
        },
        deserialize: async (value) => (Array.isArray(value) ? value : [])
      })
    ]
  }
});

宿主如需资源地址前缀,可通过 createFormMorph({ resolveAssetUrl }) 统一解析回显链接。

选项过滤与禁用

select、multi-select、radio、checkbox、cascader、tree-select 支持 Schema v3 的选项效果(kind: 'options'):

  • mode: 'filter':按关联值过滤选项;来源字段为空时结果为空列表;默认 clear: true 会清空失效值。
  • mode: 'disable':选项仍展示但不可选,只把匹配项的 disabled 置为 true,不会恢复静态已禁用项;scope: 'unmatching' 可改为禁用不匹配项。
  • 静态选项在设计器「数据」页「关联值」列维护 parent;过滤/禁用效果默认按 parent 匹配,动态数据源也支持 parentId、code、group 或自定义键。
  • 控件直接消费运行时选项的 disabled 字段:Select 下拉、Cascader 级联、Radio/Checkbox 标签均按 Arco 原生禁用样式渲染;TreeSelect 通过 buildTreeData 保留 disabled。
  • legacy-* 宿主字段由内部控件解析数据源并忽略运行时选项,因此不使用选项效果;状态、赋值、属性与清空校验效果不受影响。

0.1.2 起行为联动为 Schema v3,不兼容 v2:旧 actions / elseActions 规则不会执行,需重新配置。

设计器属性面板

每个字段定义内置 inspector 配置,设计器会自动渲染对应属性控件(文本、数字、开关、下拉、文本域)。字段 API(别名、默认布局、默认属性、可配置项)可在设计器「API 文档 → 组件 API」中直接查看。

扩展与覆写

  • 通过 createArcoPack({ name }) 可自定义插件名,用于多实例或按名传配置。
  • 需要覆写已有字段时,在 createFormMorph({ allowOverrideTypes: ['input'] }) 中显式声明允许覆盖的类型,再通过 morph.registry.resolveField('input') 等 API 处理。
  • 自定义字段仍使用 defineFieldType 注册,可参考本包源码中的字段实现。
import { createFormMorph } from '@fishbelly/form-morph';
import { createArcoPack, arcoFieldTypes } from '@fishbelly/form-morph-arco';

const morph = createFormMorph({
  plugins: [createArcoPack()],
  allowOverrideTypes: ['input']
});

console.log(morph.registry.listFields());

国际化

  • 引擎默认语言为 zh-CN;createFormMorph({ locale: 'en-US' }) 或运行时 morph.setLocale('en-US') 可切换,字段名称、分类、属性面板与校验提示同步切换;切回 zh-CN 后完整恢复。
  • 英文资源从子路径按需导入,不会进入本包主产物:
import { createFormMorph } from '@fishbelly/form-morph';
import enUS from '@fishbelly/form-morph/locales/en-US';
import designerEnUS from '@fishbelly/form-morph/designer/locales/en-US';
import arcoEnUS from '@fishbelly/form-morph-arco/locales/en-US';

const morph = createFormMorph({
  locale: 'en-US',
  messages: { 'en-US': { ...enUS, ...designerEnUS } },
  plugins: [createArcoPack({ locales: { 'en-US': arcoEnUS } })]
});
  • Arco 组件内置文案(日期面板、空数据等)默认跟随引擎语言,zh-CN / en-US 已内置映射;追加其他语言用 uiLocales: { 'zh-TW': arcoZhTW },需要交给宿主管理时传 syncLibraryLocale: false,由宿主自行用 ConfigProvider 包裹。
  • 宿主可传 translate(key, defaultMessage, context) 接管翻译,返回 undefined 时回退内置资源;ValidationRule.message 与 messageProvider 优先级更高。
  • Schema 中的用户文案(label、placeholder、静态选项)不会自动翻译;设计器新建字段时按当前语言写入。

兼容性

  • Vue ^3.4.0
  • @arco-design/web-vue ^2.50.0
  • @fishbelly/form-morph ~0.3.x(与本包同版本安装)
  • 需同时引入 Arco 样式、@fishbelly/form-morph/style.css 与本包 style.css
  • 表单外壳默认将引擎语言映射到 Arco 语言包(内置 zh-CN / en-US),日期面板、空数据等组件内置文案随引擎语言切换;可用 syncLibraryLocale: false 交回宿主管理

文档

License

MIT