@zy-frontend/form-core 2.0.6 → 2.0.7

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/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
  ### 安装
15
15
 
16
16
  ```sh
17
- npm i -S @zy/form-core
17
+ npm i -S @zy-frontend/form-core
18
18
  ```
19
19
 
20
20
  ### 使用示例
@@ -22,7 +22,7 @@ npm i -S @zy/form-core
22
22
  单表单场景:
23
23
  ```html
24
24
  <script setup lang="ts">
25
- import { ZYForm } from '@zy/form-core'
25
+ import { ZYForm } from '@zy-frontend/form-core'
26
26
  import formConfig from './form-config.json'
27
27
  import { ElForm, ElFormItem, ElInput } from 'element-plus'
28
28
 
@@ -61,7 +61,7 @@ npm i -S @zy/form-core
61
61
  多表单场景:
62
62
  ```html
63
63
  <script setup lang="ts">
64
- import { ZYFormGroup } from '@zy/form-core'
64
+ import { ZYFormGroup } from '@zy-frontend/form-core'
65
65
  import formConfig from './form-config.json'
66
66
  import { ElForm, ElFormItem, ElInput } from 'element-plus'
67
67
 
@@ -352,59 +352,59 @@ export interface UIComponents extends Record<ComponentType, any> {
352
352
  [key: string]: any
353
353
  }
354
354
 
355
- export type RemoteResponse = Option[] | Promise<Option[]> | any
356
- export interface RequestContext {
357
- requestId: number // 当前组件内递增的请求标识,用于识别过期响应
358
- signal?: AbortSignal // 新请求替换旧请求或组件卸载时触发
359
- }
360
- // 远程请求方法
361
- export type RequestFunction = (
362
- keyPath: string, // 字段键路径,格式为formKey.fieldKey
363
- value: any, // 字段值
364
- url?: string, // 字段remote里配置的远程请求URL
365
- extraParams?: Record<string, string | number | boolean>, // 字段remote里配置的远程请求参数
366
- componentParams?: Record<string, any>, // 由UI组件传入的参数,如Select组件的query、Upload组件的file等
367
- context?: RequestContext, // 请求上下文,用于取消请求及识别过期响应
368
- ) => RemoteResponse
369
- export type RemoteMethod = (
370
- componentParams?: Record<string, any>,
371
- context?: RequestContext,
372
- ) => Option[] | Promise<Option[]> // 远程选项获取方法
373
- export type UploadResponse = any | Promise<any>
374
- export type UploadMethod = (
375
- componentParams?: Record<string, any>,
376
- context?: RequestContext,
377
- ) => UploadResponse // 上传文件方法
378
- export type FileRemoveMethod = (
379
- componentParams?: Record<string, any>,
380
- context?: RequestContext,
381
- ) => Promise<void> | void // 文件删除方法
382
- ```
383
-
384
- 远程查询和上传应将 `context.signal` 传给 `fetch`、Axios 等请求库。组件会在新查询替换旧查询、文件删除或组件卸载时触发取消;不支持取消的实现也必须避免使用过期响应回写状态。
385
-
386
- Axios 示例:
387
-
388
- ```typescript
389
- const requestFn: RequestFunction = async (
390
- keyPath,
391
- value,
392
- url,
393
- extraParams,
394
- componentParams,
395
- context,
396
- ) => {
397
- const { data } = await axios.get(url || '', {
398
- params: {
399
- ...extraParams,
400
- ...componentParams,
401
- },
402
- signal: context?.signal,
403
- })
404
-
405
- return data
406
- }
407
- ```
355
+ export type RemoteResponse = Option[] | Promise<Option[]> | any
356
+ export interface RequestContext {
357
+ requestId: number // 当前组件内递增的请求标识,用于识别过期响应
358
+ signal?: AbortSignal // 新请求替换旧请求或组件卸载时触发
359
+ }
360
+ // 远程请求方法
361
+ export type RequestFunction = (
362
+ keyPath: string, // 字段键路径,格式为formKey.fieldKey
363
+ value: any, // 字段值
364
+ url?: string, // 字段remote里配置的远程请求URL
365
+ extraParams?: Record<string, string | number | boolean>, // 字段remote里配置的远程请求参数
366
+ componentParams?: Record<string, any>, // 由UI组件传入的参数,如Select组件的query、Upload组件的file等
367
+ context?: RequestContext, // 请求上下文,用于取消请求及识别过期响应
368
+ ) => RemoteResponse
369
+ export type RemoteMethod = (
370
+ componentParams?: Record<string, any>,
371
+ context?: RequestContext,
372
+ ) => Option[] | Promise<Option[]> // 远程选项获取方法
373
+ export type UploadResponse = any | Promise<any>
374
+ export type UploadMethod = (
375
+ componentParams?: Record<string, any>,
376
+ context?: RequestContext,
377
+ ) => UploadResponse // 上传文件方法
378
+ export type FileRemoveMethod = (
379
+ componentParams?: Record<string, any>,
380
+ context?: RequestContext,
381
+ ) => Promise<void> | void // 文件删除方法
382
+ ```
383
+
384
+ 远程查询和上传应将 `context.signal` 传给 `fetch`、Axios 等请求库。组件会在新查询替换旧查询、文件删除或组件卸载时触发取消;不支持取消的实现也必须避免使用过期响应回写状态。
385
+
386
+ Axios 示例:
387
+
388
+ ```typescript
389
+ const requestFn: RequestFunction = async (
390
+ keyPath,
391
+ value,
392
+ url,
393
+ extraParams,
394
+ componentParams,
395
+ context,
396
+ ) => {
397
+ const { data } = await axios.get(url || '', {
398
+ params: {
399
+ ...extraParams,
400
+ ...componentParams,
401
+ },
402
+ signal: context?.signal,
403
+ })
404
+
405
+ return data
406
+ }
407
+ ```
408
408
 
409
409
  ### 自定义组件
410
410
 
package/dist/index.es.js CHANGED
@@ -1703,8 +1703,9 @@ const al = /* @__PURE__ */ nl(rl), il = async (e, t, n, r, a) => {
1703
1703
  return (V = e.setCompRef) == null ? void 0 : V.call(e, O);
1704
1704
  },
1705
1705
  modelValue: n.value[i.value],
1706
- "onUpdate:modelValue": g[0] || (g[0] = (O) => n.value[i.value] = O)
1707
- }, { ...m.value, ...Y(o) }), null, 16, ["modelValue"])) : (L(), te("div", de({
1706
+ "onUpdate:modelValue": g[0] || (g[0] = (O) => n.value[i.value] = O),
1707
+ style: e.style
1708
+ }, { ...m.value, ...Y(o) }), null, 16, ["modelValue", "style"])) : (L(), te("div", de({
1708
1709
  key: 1,
1709
1710
  class: "zy-form-item-blank",
1710
1711
  style: e.style
@@ -2122,12 +2123,12 @@ const al = /* @__PURE__ */ nl(rl), il = async (e, t, n, r, a) => {
2122
2123
  "key-path": `${e.formKey}.${S.key}`,
2123
2124
  readonly: e.readonly,
2124
2125
  "request-fn": e.requestFn,
2125
- className: p(S),
2126
+ "class-name": p(S),
2126
2127
  style: De(d(S)),
2127
2128
  onChange: (q) => y(S.key, q),
2128
2129
  onBlur: (q, D) => w(q, S.key, D),
2129
2130
  onKeyupEnter: (q, D) => $(q, S.key, D)
2130
- }, null, 8, ["modelValue", "components", "field", "key-path", "readonly", "request-fn", "className", "style", "onChange", "onBlur", "onKeyupEnter"]))), 128))
2131
+ }, null, 8, ["modelValue", "components", "field", "key-path", "readonly", "request-fn", "class-name", "style", "onChange", "onBlur", "onKeyupEnter"]))), 128))
2131
2132
  ], 6)
2132
2133
  ]),
2133
2134
  _: 2
@@ -2147,12 +2148,12 @@ const al = /* @__PURE__ */ nl(rl), il = async (e, t, n, r, a) => {
2147
2148
  "key-path": `${e.formKey}.${S.key}`,
2148
2149
  readonly: e.readonly,
2149
2150
  "request-fn": e.requestFn,
2150
- className: p(S),
2151
+ "class-name": p(S),
2151
2152
  style: De(d(S)),
2152
2153
  onChange: (q) => y(S.key, q),
2153
2154
  onBlur: (q, D) => w(q, S.key, D),
2154
2155
  onKeyupEnter: (q, D) => $(q, S.key, D)
2155
- }, null, 8, ["modelValue", "components", "field", "key-path", "readonly", "request-fn", "className", "style", "onChange", "onBlur", "onKeyupEnter"]))), 128))
2156
+ }, null, 8, ["modelValue", "components", "field", "key-path", "readonly", "request-fn", "class-name", "style", "onChange", "onBlur", "onKeyupEnter"]))), 128))
2156
2157
  ], 6)) : Le("", !0)
2157
2158
  ], 64)) : (L(), te("div", {
2158
2159
  key: c[0].key,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zy-frontend/form-core",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",