Skip to content

Commit 9e5ed94

Browse files
committed
refactor: rc-component/form
1 parent 5971749 commit 9e5ed94

File tree

11 files changed

+20
-25
lines changed

11 files changed

+20
-25
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "rc-field-form",
3-
"version": "2.7.0",
2+
"name": "@rc-component/form",
3+
"version": "1.0.0",
44
"description": "React Form Component",
55
"typings": "es/index.d.ts",
66
"engines": {
@@ -51,7 +51,7 @@
5151
"dependencies": {
5252
"@babel/runtime": "^7.18.0",
5353
"@rc-component/async-validator": "^5.0.3",
54-
"rc-util": "^5.32.2"
54+
"@rc-component/util": "^1.1.0"
5555
},
5656
"devDependencies": {
5757
"@rc-component/father-plugin": "^1.0.0",

src/Field.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import toChildrenArray from 'rc-util/lib/Children/toArray';
2-
import isEqual from 'rc-util/lib/isEqual';
3-
import warning from 'rc-util/lib/warning';
1+
import toChildrenArray from '@rc-component/util/lib/Children/toArray';
2+
import isEqual from '@rc-component/util/lib/isEqual';
3+
import warning from '@rc-component/util/lib/warning';
44
import * as React from 'react';
55
import FieldContext, { HOOK_MARK } from './FieldContext';
66
import type {
@@ -112,11 +112,6 @@ export interface FieldState {
112112
class Field extends React.Component<InternalFieldProps, FieldState> implements FieldEntity {
113113
public static contextType = FieldContext;
114114

115-
public static defaultProps = {
116-
trigger: 'onChange',
117-
valuePropName: 'value',
118-
};
119-
120115
public state = {
121116
resetCount: 0,
122117
};
@@ -566,11 +561,11 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
566561
public getControlled = (childProps: ChildProps = {}) => {
567562
const {
568563
name,
569-
trigger,
564+
trigger = 'onChange',
570565
validateTrigger,
571566
getValueFromEvent,
572567
normalize,
573-
valuePropName,
568+
valuePropName = 'value',
574569
getValueProps,
575570
fieldContext,
576571
} = this.props;

src/FieldContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import warning from 'rc-util/lib/warning';
1+
import warning from '@rc-component/util/lib/warning';
22
import * as React from 'react';
33
import type { InternalFormInstance } from './interface';
44

src/List.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import warning from 'rc-util/lib/warning';
2+
import warning from '@rc-component/util/lib/warning';
33
import type { InternalNamePath, NamePath, StoreValue, ValidatorRule, Meta } from './interface';
44
import FieldContext from './FieldContext';
55
import Field from './Field';

src/useForm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { merge } from 'rc-util/lib/utils/set';
2-
import warning from 'rc-util/lib/warning';
1+
import { merge } from '@rc-component/util/lib/utils/set';
2+
import warning from '@rc-component/util/lib/warning';
33
import * as React from 'react';
44
import { HOOK_MARK } from './FieldContext';
55
import type {

src/useWatch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import warning from 'rc-util/lib/warning';
1+
import warning from '@rc-component/util/lib/warning';
22
import { useContext, useEffect, useMemo, useRef, useState } from 'react';
33
import FieldContext, { HOOK_MARK } from './FieldContext';
44
import type {

src/utils/validateUtil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import RawAsyncValidator from '@rc-component/async-validator';
22
import * as React from 'react';
3-
import warning from 'rc-util/lib/warning';
3+
import warning from '@rc-component/util/lib/warning';
44
import type {
55
InternalNamePath,
66
InternalValidateOptions,
@@ -9,7 +9,7 @@ import type {
99
RuleError,
1010
} from '../interface';
1111
import { defaultValidateMessages } from './messages';
12-
import { merge } from 'rc-util/lib/utils/set';
12+
import { merge } from '@rc-component/util/lib/utils/set';
1313

1414
// Remove incorrect original ts define
1515
const AsyncValidator: any = RawAsyncValidator;

src/utils/valueUtil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import getValue from 'rc-util/lib/utils/get';
2-
import setValue from 'rc-util/lib/utils/set';
1+
import getValue from '@rc-component/util/lib/utils/get';
2+
import setValue from '@rc-component/util/lib/utils/set';
33
import type { InternalNamePath, NamePath, Store, EventArgs } from '../interface';
44
import { toArray } from './typeUtil';
55

tests/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { act, fireEvent, render } from '@testing-library/react';
2-
import { resetWarned } from 'rc-util/lib/warning';
2+
import { resetWarned } from '@rc-component/util/lib/warning';
33
import React from 'react';
44
import type { FormInstance } from '../src';
55
import Form, { Field, useForm } from '../src';

tests/initialValue.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { act, fireEvent, render } from '@testing-library/react';
2-
import { resetWarned } from 'rc-util/lib/warning';
2+
import { resetWarned } from '@rc-component/util/lib/warning';
33
import React, { useState } from 'react';
44
import Form, { Field, List, useForm, type FormInstance } from '../src';
55
import { changeValue, getInput } from './common';

0 commit comments

Comments
 (0)