Skip to content

Commit

Permalink
fix: default init type loses value & change
Browse files Browse the repository at this point in the history
  • Loading branch information
eternalsky committed Jun 3, 2024
1 parent 775f0ae commit 774e477
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alifd/field",
"version": "2.0.0",
"version": "2.0.1",
"description": "Fields can be used to manage data when it comes to form data manipulation and validation. After being associated with a component, the form data can be automatically written back, read, and verified.",
"files": [
"demo/",
Expand Down Expand Up @@ -93,7 +93,7 @@
"表单"
]
},
"homepage": "https://unpkg.com/@alifd/[email protected].0/build/index.html",
"homepage": "https://unpkg.com/@alifd/[email protected].1/build/index.html",
"bugs": "https://github.com/alibaba-fusion/field/issues",
"publishConfig": {
"access": "public",
Expand Down
26 changes: 6 additions & 20 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,32 +136,18 @@ class Field {
Object.assign(this.options, options);
}

init<ValueType = any, OtherProps extends object = object>(
name: string,
option?: InitOption<ValueType, never, never, OtherProps>,
rprops?: OtherProps
): Omit<OtherProps, keyof InitResult<'value', 'onChange', ValueType>> & InitResult<'value', 'onChange', ValueType>;
init<
ValueType = any,
ValueName extends string = 'value',
Trigger extends string = 'onChange',
OtherProps extends object = object,
>(
name: string,
option?: InitOption<ValueType, ValueName, Trigger, OtherProps>,
rprops?: OtherProps
): Omit<OtherProps, keyof InitResult<ValueName, Trigger, ValueType>> & InitResult<ValueName, Trigger, ValueType>;
/**
* 初始化一个字段项
* @param name - 字段 key
* @param option - 字段配置
* @param rprops - 其它参数
*/
init<ValueType, ValueName extends string, Trigger extends string, OtherProps extends object>(
name: string,
option: InitOption<ValueType, ValueName, Trigger, OtherProps> = {},
rprops?: OtherProps
) {
init<
ValueType,
ValueName extends string = 'value',
Trigger extends string = 'onChange',
OtherProps extends object = object,
>(name: string, option: InitOption<ValueType, ValueName, Trigger, OtherProps> = {}, rprops?: OtherProps) {
const {
id,
initValue,
Expand Down

0 comments on commit 774e477

Please sign in to comment.