-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/npm_and_yarn/react-dnd-16.0.1
- Loading branch information
Showing
77 changed files
with
3,349 additions
and
2,594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { defineConfig } from 'dumi'; | ||
import path from 'path'; | ||
|
||
const isProdSite = | ||
// 不是预览模式 同时是生产环境 | ||
process.env.PREVIEW !== 'true' && process.env.NODE_ENV === 'production'; | ||
|
||
const name = 'field-form'; | ||
|
||
export default defineConfig({ | ||
alias: { | ||
'rc-field-form$': path.resolve('src'), | ||
'rc-field-form/es': path.resolve('src'), | ||
}, | ||
mfsu: false, | ||
favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], | ||
themeConfig: { | ||
name: 'FieldForm', | ||
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', | ||
}, | ||
base: isProdSite ? `/${name}/` : '/', | ||
publicPath: isProdSite ? `/${name}/` : '/', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
export default { | ||
cjs: 'babel', | ||
esm: { type: 'babel', importLibToEs: true }, | ||
runtimeHelpers: true, | ||
preCommit: { | ||
eslint: true, | ||
prettier: true, | ||
}, | ||
}; | ||
import { defineConfig } from 'father'; | ||
|
||
export default defineConfig({ | ||
plugins: ['@rc-component/father-plugin'], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,9 +19,11 @@ | |
.DS_Store | ||
.vscode | ||
.idea | ||
~* | ||
|
||
# umi | ||
.umi | ||
.umi-production | ||
.umi-test | ||
.env.local | ||
.dumi/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## basic | ||
|
||
|
||
<code src="../examples/basic.tsx" /> | ||
<code src="../examples/basic.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## component | ||
|
||
<code src="../examples/component.tsx" /> | ||
<code src="../examples/component.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## context | ||
|
||
<code src="../examples/context.tsx" /> | ||
<code src="../examples/context.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## deps | ||
|
||
|
||
<code src="../examples/deps.tsx" /> | ||
<code src="../examples/deps.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## initialValues | ||
|
||
|
||
<code src="../examples/initialValues.tsx" /> | ||
<code src="../examples/initialValues.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## layout | ||
|
||
<code src="../examples/layout.tsx" /> | ||
<code src="../examples/layout.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## list | ||
|
||
<code src="../examples/list.tsx" /> | ||
<code src="../examples/list.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## preserve | ||
|
||
|
||
<code src="../examples/preserve.tsx" /> | ||
<code src="../examples/preserve.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## redux | ||
|
||
<code src="../examples/redux.tsx" /> | ||
<code src="../examples/redux.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## renderProps | ||
|
||
<code src="../examples/renderProps.tsx" /> | ||
<code src="../examples/renderProps.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## reset | ||
|
||
<code src="../examples/reset.tsx" /> | ||
<code src="../examples/reset.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## stateForm-list-draggable | ||
|
||
<code src="../examples/stateForm-list-draggable.tsx" /> | ||
<code src="../examples/stateForm-list-draggable.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## useForm | ||
|
||
<code src="../examples/useForm.tsx" /> | ||
<code src="../examples/useForm.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## useWatch-list | ||
|
||
<code src="../examples/useWatch-list.tsx" /> | ||
<code src="../examples/useWatch-list.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## useWatch | ||
|
||
<code src="../examples/useWatch.tsx" /> | ||
<code src="../examples/useWatch.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## validate-perf | ||
|
||
<code src="../examples/validate-perf.tsx" /> | ||
<code src="../examples/validate-perf.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## validate | ||
|
||
<code src="../examples/validate.tsx" /> | ||
<code src="../examples/validate.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## validateOnly | ||
|
||
<code src="../examples/validateOnly.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* eslint-disable react/prop-types, @typescript-eslint/consistent-type-imports */ | ||
|
||
import React from 'react'; | ||
import Form from 'rc-field-form'; | ||
import type { FormInstance } from 'rc-field-form'; | ||
import Input from './components/Input'; | ||
import LabelField from './components/LabelField'; | ||
|
||
function useSubmittable(form: FormInstance) { | ||
const [submittable, setSubmittable] = React.useState(false); | ||
const store = Form.useWatch([], form); | ||
|
||
React.useEffect(() => { | ||
form | ||
.validateFields({ | ||
validateOnly: true, | ||
}) | ||
.then( | ||
() => { | ||
setSubmittable(true); | ||
}, | ||
() => { | ||
setSubmittable(false); | ||
}, | ||
); | ||
}, [store]); | ||
|
||
return submittable; | ||
} | ||
|
||
export default () => { | ||
const [form] = Form.useForm(); | ||
|
||
const canSubmit = useSubmittable(form); | ||
|
||
const onValidateOnly = async () => { | ||
const result = await form.validateFields({ | ||
validateOnly: true, | ||
}); | ||
console.log('Validate:', result); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Form form={form}> | ||
<LabelField | ||
name="name" | ||
label="Name" | ||
rules={[ | ||
{ required: true }, | ||
// { warningOnly: true, validator: () => Promise.reject('Warn Name!') }, | ||
]} | ||
> | ||
<Input /> | ||
</LabelField> | ||
<LabelField | ||
name="age" | ||
label="Age" | ||
rules={[ | ||
{ required: true }, | ||
// { warningOnly: true, validator: () => Promise.reject('Warn Age!') }, | ||
]} | ||
> | ||
<Input /> | ||
</LabelField> | ||
<button type="reset">Reset</button> | ||
<button type="submit" disabled={!canSubmit}> | ||
Submit | ||
</button> | ||
</Form> | ||
<button type="button" onClick={onValidateOnly}> | ||
Validate Without UI update | ||
</button> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.