@fishbelly/form-morph-arco 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 fishbelly
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,212 @@
1
- # Temporary Holding Version
1
+ # @fishbelly/form-morph-arco
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [form-morph](https://www.npmjs.com/package/@fishbelly/form-morph) 的官方 Arco Design 字段包,提供 22 种字段、展示组件与布局容器,并实现 Arco 风格的表单外壳与字段校验视觉。
4
+
5
+ 引擎本身不依赖 UI 组件库;安装本包即可获得开箱可用的 Arco Design 表单组件。
6
+
7
+ - 完整 API 文档:[docs/API.md](https://gitee.com/fishbelly/form-morph/blob/master/docs/API.md)
8
+ - 主包:[@fishbelly/form-morph](https://www.npmjs.com/package/@fishbelly/form-morph)
9
+
10
+ ## 安装
11
+
12
+ ```bash
13
+ # npm
14
+ npm install @fishbelly/form-morph @fishbelly/form-morph-arco @arco-design/web-vue
15
+
16
+ # yarn
17
+ yarn add @fishbelly/form-morph @fishbelly/form-morph-arco @arco-design/web-vue
18
+
19
+ # pnpm
20
+ pnpm add @fishbelly/form-morph @fishbelly/form-morph-arco @arco-design/web-vue
21
+ ```
22
+
23
+ ## 快速开始
24
+
25
+ ```ts
26
+ // main.ts
27
+ import { createApp } from 'vue';
28
+ import ArcoVue from '@arco-design/web-vue';
29
+ import { createFormMorph } from '@fishbelly/form-morph';
30
+ import { createArcoPack } from '@fishbelly/form-morph-arco';
31
+ import '@arco-design/web-vue/dist/arco.css';
32
+ import '@fishbelly/form-morph/style.css';
33
+ import '@fishbelly/form-morph-arco/style.css';
34
+ import App from './App.vue';
35
+
36
+ const morph = createFormMorph({
37
+ plugins: [createArcoPack()]
38
+ });
39
+
40
+ createApp(App).use(ArcoVue).use(morph).mount('#app');
41
+ ```
42
+
43
+ ```vue
44
+ <script setup lang="ts">
45
+ import { ref } from 'vue';
46
+ import { FormRenderer, type FormSchema } from '@fishbelly/form-morph';
47
+
48
+ const schema: FormSchema = {
49
+ id: 'arco-demo',
50
+ layout: { mode: 'horizontal', labelWidth: 96, gutter: 16 },
51
+ nodes: [
52
+ { id: 'n1', type: 'input', name: 'name', label: '姓名', validate: { required: true } },
53
+ {
54
+ id: 'n2',
55
+ type: 'select',
56
+ name: 'level',
57
+ label: '等级',
58
+ data: {
59
+ source: {
60
+ kind: 'static',
61
+ options: [
62
+ { label: '高', value: 'high' },
63
+ { label: '中', value: 'medium' },
64
+ { label: '低', value: 'low' }
65
+ ]
66
+ }
67
+ }
68
+ },
69
+ { id: 'n3', type: 'switch', name: 'enabled', label: '启用' }
70
+ ]
71
+ };
72
+
73
+ const values = ref<Record<string, unknown>>({});
74
+ </script>
75
+
76
+ <template>
77
+ <FormRenderer :schema="schema" v-model="values" show-actions />
78
+ </template>
79
+ ```
80
+
81
+ 也可以直接使用全局默认实例:
82
+
83
+ ```ts
84
+ import { arcoPack } from '@fishbelly/form-morph-arco';
85
+
86
+ const morph = createFormMorph({ plugins: [arcoPack] });
87
+ ```
88
+
89
+ ## 字段清单
90
+
91
+ ### 基础字段
92
+
93
+ | type | 名称 | valueType | 别名 | 常用属性 |
94
+ | --- | --- | --- | --- | --- |
95
+ | `input` | 单行文本 | `string` | `text`、`text-input`、`string` | `placeholder`、`allowClear`、`maxLength` |
96
+ | `textarea` | 多行文本 | `string` | `text-area` | `rows`、`autoSize`、`showWordLimit`、`maxLength` |
97
+ | `password` | 密码输入 | `string` | — | `placeholder`、`allowClear` |
98
+ | `number` | 数字输入 | `number` | `input-number`、`inputnumber` | `min`、`max`、`step`、`precision` |
99
+
100
+ ### 选择字段
101
+
102
+ | type | 名称 | valueType | 别名 | 常用属性 |
103
+ | --- | --- | --- | --- | --- |
104
+ | `select` | 下拉选择 | `string` | `dropdown` | `placeholder`、`allowSearch`、`allowClear` |
105
+ | `multi-select` | 多选下拉 | `string[]` | `multiselect`、`multiple-select`、`multi` | 同上、`maxTagCount` |
106
+ | `radio` | 单选框 | `string` | — | `direction`(`horizontal` / `vertical`) |
107
+ | `checkbox` | 复选框 | `string[]` | — | `direction` |
108
+ | `switch` | 开关 | `boolean` | — | `checkedText`、`uncheckedText` |
109
+ | `slider` | 滑动条 | `number` | — | `min`、`max`、`step`、`showInput` |
110
+ | `rate` | 评分 | `number` | — | `count`、`allowHalf` |
111
+
112
+ ### 日期时间
113
+
114
+ | type | 名称 | valueType | 别名 | 常用属性 |
115
+ | --- | --- | --- | --- | --- |
116
+ | `date` | 日期 | `timestamp` | `datepicker`、`date-picker` | `showTime`、`format`、`allowClear` |
117
+ | `date-range` | 日期范围 | `timestamp[]` | `daterange`、`date-picker-range`、`rangepicker` | `showTime`、`format`、`allowClear` |
118
+ | `time` | 时间 | `string` | `timepicker`、`time-picker` | `format`、`allowClear` |
119
+
120
+ > `date` / `date-range` 的值类型为时间戳(number),绑定到业务字段时如需字符串请在提交前通过值适配器转换。
121
+
122
+ ### 高级字段
123
+
124
+ | type | 名称 | valueType | 别名 | 常用属性 |
125
+ | --- | --- | --- | --- | --- |
126
+ | `upload` | 文件上传 | `file[]` | `file`、`file-upload` | `accept`、`action`、`autoUpload`、`limit`、`multiple`、`showFileList` |
127
+ | `cascader` | 级联选择 | `string[]` | — | `placeholder`、`allowSearch`、`changeOnSelect` |
128
+ | `tree-select` | 树选择 | `string` | `treeselect` | `placeholder`、`allowSearch`、`allowClear` |
129
+ | `color` | 颜色选择 | `string` | — | `disabledAlpha` |
130
+
131
+ ### 展示与容器
132
+
133
+ | type | 名称 | kind | 别名 | 常用属性 |
134
+ | --- | --- | --- | --- | --- |
135
+ | `static-text` | 静态文本 | display | `static`、`statictext` | `content`、`type` |
136
+ | `card` | 卡片容器 | container | — | `bordered` |
137
+ | `section` | 分组区块 | container | — | `icon`、`plain` |
138
+ | `divider` | 分割线 | display | `line` | `orientation`、`dividerType` |
139
+
140
+ 容器节点通过 `children` 嵌套子节点,渲染时使用默认插槽承载子网格。
141
+
142
+ ## 上传字段
143
+
144
+ - 使用 Arco 默认上传按钮,同时支持将文件拖拽到整个字段区域;拖拽与点击共享 `accept`、`multiple`、`limit` 规则。
145
+ - 默认 `autoUpload: false`,文件对象暂存在表单值中,由宿主在提交时统一上传(推荐)。
146
+ - 需要自定义上传链路时,注册值适配器在 `serialize` 阶段上传并返回业务所需的值(如文件 ID 数组):
147
+
148
+ ```ts
149
+ import { defineValueAdapter, definePlugin } from '@fishbelly/form-morph';
150
+
151
+ export const uploadAdapterPlugin = definePlugin({
152
+ name: 'my-upload-adapter',
153
+ version: '1.0.0',
154
+ contributes: {
155
+ valueAdapters: [
156
+ defineValueAdapter({
157
+ name: 'upload-codec',
158
+ appliesTo: ['upload'],
159
+ serialize: async (value) => {
160
+ if (!Array.isArray(value)) return value;
161
+ const uploaded = await Promise.all(
162
+ value.map((item) => (item instanceof File ? myUpload(item) : item))
163
+ );
164
+ return uploaded.map((item) => item.id);
165
+ },
166
+ deserialize: async (value) => (Array.isArray(value) ? value : [])
167
+ })
168
+ ]
169
+ }
170
+ });
171
+ ```
172
+
173
+ 宿主如需资源地址前缀,可通过 `createFormMorph({ resolveAssetUrl })` 统一解析回显链接。
174
+
175
+ ## 设计器属性面板
176
+
177
+ 每个字段定义内置 `inspector` 配置,设计器会自动渲染对应属性控件(文本、数字、开关、下拉、文本域)。字段 API(别名、默认布局、默认属性、可配置项)可在设计器「API 文档 → 组件 API」中直接查看。
178
+
179
+ ## 扩展与覆写
180
+
181
+ - 通过 `createArcoPack({ name })` 可自定义插件名,用于多实例或按名传配置。
182
+ - 需要覆写已有字段时,在 `createFormMorph({ allowOverrideTypes: ['input'] })` 中显式声明允许覆盖的类型,再通过 `morph.registry.resolveField('input')` 等 API 处理。
183
+ - 自定义字段仍使用 `defineFieldType` 注册,可参考本包源码中的字段实现。
184
+
185
+ ```ts
186
+ import { createFormMorph } from '@fishbelly/form-morph';
187
+ import { createArcoPack, arcoFieldTypes } from '@fishbelly/form-morph-arco';
188
+
189
+ const morph = createFormMorph({
190
+ plugins: [createArcoPack()],
191
+ allowOverrideTypes: ['input']
192
+ });
193
+
194
+ console.log(morph.registry.listFields());
195
+ ```
196
+
197
+ ## 兼容性
198
+
199
+ - Vue `^3.4.0`
200
+ - `@arco-design/web-vue` `^2.50.0`
201
+ - `@fishbelly/form-morph` `^0.1.0`
202
+ - 需同时引入 Arco 样式、`@fishbelly/form-morph/style.css` 与本包 `style.css`
203
+
204
+ ## 文档
205
+
206
+ - [完整 API 文档](https://gitee.com/fishbelly/form-morph/blob/master/docs/API.md)
207
+ - [主包 @fishbelly/form-morph](https://www.npmjs.com/package/@fishbelly/form-morph)
208
+ - [示例与演示](https://gitee.com/fishbelly/form-morph/tree/master/examples/playground)
209
+
210
+ ## License
211
+
212
+ [MIT](https://gitee.com/fishbelly/form-morph/blob/master/LICENSE)
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ import { FormNode, NodeRuntimeState } from '../../../form-morph/src/index.ts';
2
+ type __VLS_Props = {
3
+ node: FormNode;
4
+ state: NodeRuntimeState;
5
+ error?: string;
6
+ vertical?: boolean;
7
+ view?: boolean;
8
+ disabled?: boolean;
9
+ labelWidth?: string | number;
10
+ labelAlign?: 'left' | 'right';
11
+ reserveMessage?: boolean;
12
+ };
13
+ declare function __VLS_template(): {
14
+ attrs: Partial<{}>;
15
+ slots: {
16
+ default?(_: {}): any;
17
+ };
18
+ refs: {};
19
+ rootEl: any;
20
+ };
21
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
22
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
23
+ reserveMessage: boolean;
24
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
25
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
26
+ export default _default;
27
+ type __VLS_WithTemplateSlots<T, S> = T & {
28
+ new (): {
29
+ $slots: S;
30
+ };
31
+ };