Skip to content

Commit

Permalink
docs: fix TS signature for dependencies field of SchemaReactions (#3938)
Browse files Browse the repository at this point in the history
* docs(react): fix TS signature for SchemaReactions

* docs(vue): fix TS signature for SchemaReactions

* chore: fix compressed size / build check failed
  • Loading branch information
mya12321 authored Oct 12, 2023
1 parent bf0ab1c commit 9598d97
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 16 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"@types/react-dom": "^18.0.0",
"@mapbox/hast-util-to-jsx": "~1.0.0",
"yargs": "^16.x",
"commander": "^6.x"
"commander": "^6.x",
"ttypescript": "1.5.15"
},
"devDependencies": {
"@alifd/next": "^1.19.1",
Expand Down
18 changes: 15 additions & 3 deletions packages/react/docs/api/shared/Schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,9 @@ type SchemaEnum<Message> = Array<
#### Description
Schema linkage protocol, if the reaction object contains target, it represents active linkage mode, otherwise it represents passive linkage mode
If you want to achieve more complex linkage, you can pass in the reaction responder function through the scope for processing
Schema linkage protocol, if the reaction object contains target, it represents active linkage mode, otherwise it represents passive linkage mode
If you want to achieve more complex linkage, you can pass in the reaction responder function through the scope for processing
FormPathPattern path syntax documentation is [here](https://core.formilyjs.org/api/entry/form-path#formpathpattern)
#### Signature
Expand All @@ -651,7 +652,18 @@ type SchemaReactionEffect =

type SchemaReaction<Field = any> =
| {
dependencies?: string[] | Record<string, string> //The list of dependent field paths can only describe dependencies in dot paths, and supports relative paths. If it is an array format, then it is also an array format when reading, if it is an object format , It is also an object format when reading, but the object format is equivalent to an alias
dependencies?: //The list of dependent field paths can only describe dependencies in dot paths, and supports relative paths
| Array<
| string //If it is an array contains string format, then it is also an array format when reading
| {
//If it is an array contains object format, then it is an object format when reading, but the name field is equivalent to an alias
name?: string
type?: string
source?: string
property?: string
}
>
| Record<string, string> //If it is an object format, It is also an object format when reading, but the key for object is equivalent to an alias
when?: string | boolean //Linkage condition
target?: string //The field path to be operated, supports FormPathPattern path syntax, note: relative path is not supported! !
effects?: SchemaReactionEffect[] //Independent life cycle hook in active mode
Expand Down
24 changes: 18 additions & 6 deletions packages/react/docs/api/shared/Schema.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,9 @@ type SchemaEnum<Message> = Array<
#### 描述
Schema 联动协议,如果 reaction 对象里包含 target,则代表主动联动模式,否则代表被动联动模式
如果想实现更复杂的联动,可以通过作用域传入 reaction 响应器函数进行处理
Schema 联动协议,如果 reaction 对象里包含 target,则代表主动联动模式,否则代表被动联动模式
如果想实现更复杂的联动,可以通过作用域传入 reaction 响应器函数进行处理
FormPathPattern 路径语法文档看[这里](https://core.formilyjs.org/zh-CN/api/entry/form-path#formpathpattern)
#### 签名
Expand All @@ -651,9 +652,20 @@ type SchemaReactionEffect =

type SchemaReaction<Field = any> =
| {
dependencies?: string[] | Record<string, string> //依赖的字段路径列表,只能以点路径描述依赖,支持相对路径,如果是数组格式,那么读的时候也是数组格式,如果是对象格式,读的时候也是对象格式,只是对象格式相当于是一个alias
dependencies?: //依赖的字段路径列表,支持FormPathPattern数据路径语法, 只能以点路径描述依赖,支持相对路径
| Array<
| string //如果数组里是string,那么读的时候也是数组格式
| {
//如果数组里是对象, 那么读的时候通过name从$deps获取
name?: string //从$deps读取时的别名
type?: string //字段类型
source?: string //字段路径
property?: string //依赖属性, 默认为value
}
>
| Record<string, string> //如果是对象格式,读的时候也是对象格式,只是对象的key相当于别名
when?: string | boolean //联动条件
target?: string //要操作的字段路径,支持FormPathPattern路径语法,注意:不支持相对路径!!
target?: string //要操作的字段路径,支持FormPathPattern匹配路径语法,注意:不支持相对路径!!
effects?: SchemaReactionEffect[] //主动模式下的独立生命周期钩子
fulfill?: {
//满足条件
Expand All @@ -668,11 +680,11 @@ type SchemaReaction<Field = any> =
run?: string //执行语句
}
}
| ((field: Field) => void) //可以复杂联动
| ((field: Field) => void) //支持函数, 可以复杂联动

type SchemaReactions<Field = any> =
| SchemaReaction<Field>
| SchemaReaction<Field>[]
| SchemaReaction<Field>[] //支持传入数组
```
#### 用例
Expand Down
24 changes: 18 additions & 6 deletions packages/vue/docs/api/shared/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,9 @@ type SchemaEnum<Message> = Array<
#### 描述
Schema 联动协议,如果 reaction 对象里包含 target,则代表主动联动模式,否则代表被动联动模式
如果想实现更复杂的联动,可以通过作用域传入 reaction 响应器函数进行处理
Schema 联动协议,如果 reaction 对象里包含 target,则代表主动联动模式,否则代表被动联动模式
如果想实现更复杂的联动,可以通过作用域传入 reaction 响应器函数进行处理
FormPathPattern 路径语法文档看[这里](https://core.formilyjs.org/zh-CN/api/entry/form-path#formpathpattern)
#### 签名
Expand All @@ -649,9 +650,20 @@ type SchemaReactionEffect =

type SchemaReaction<Field = any> =
| {
dependencies?: string[] | Record<string, string> //依赖的字段路径列表,只能以点路径描述依赖,支持相对路径,如果是数组格式,那么读的时候也是数组格式,如果是对象格式,读的时候也是对象格式,只是对象格式相当于是一个alias
dependencies?: //依赖的字段路径列表,支持FormPathPattern数据路径语法, 只能以点路径描述依赖,支持相对路径
| Array<
| string //如果数组里是string,那么读的时候也是数组格式
| {
//如果数组里是对象, 那么读的时候通过name从$deps获取
name?: string //从$deps读取时的别名
type?: string //字段类型
source?: string //字段路径
property?: string //依赖属性, 默认为value
}
>
| Record<string, string> //如果是对象格式,读的时候也是对象格式,只是对象的key相当于别名
when?: string | boolean //联动条件
target?: string //要操作的字段路径,支持FormPathPattern路径语法,注意:不支持相对路径!!
target?: string //要操作的字段路径,支持FormPathPattern匹配路径语法,注意:不支持相对路径!!
effects?: SchemaReactionEffect[] //主动模式下的独立生命周期钩子
fulfill?: {
//满足条件
Expand All @@ -666,11 +678,11 @@ type SchemaReaction<Field = any> =
run?: string //执行语句
}
}
| ((field: Field) => void) //可以复杂联动
| ((field: Field) => void) //支持函数, 可以复杂联动

type SchemaReactions<Field = any> =
| SchemaReaction<Field>
| SchemaReaction<Field>[]
| SchemaReaction<Field>[] //支持传入数组
```
#### 用例
Expand Down

0 comments on commit 9598d97

Please sign in to comment.