;
15 |
--------------------------------------------------------------------------------
/website/versioned_docs/version-2.0.3/3rd-party-bindings.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: version-2.0.3-3rd-party-bindings
3 | title: 3rd Party Bindings
4 | original_id: 3rd-party-bindings
5 | ---
6 |
7 | If you would like to use Formik with a UI framework, you'll probably want to create a wrapper component that binds Formik's props and callbacks.
8 |
9 | A few popular frameworks have open source wrappers readily available:
10 |
11 | - [Ant Design](https://github.com/jannikbuschke/formik-antd)
12 | - [Fabric](https://github.com/kmees/formik-office-ui-fabric-react)
13 | - [Material UI](https://github.com/stackworx/formik-material-ui)
14 | - [Reactstrap](https://github.com/shoaibkhan94/reactstrap-formik)
15 | - [Semantic UI](https://github.com/turner-industries/formik-semantic-ui)
16 |
--------------------------------------------------------------------------------
/packages/formik/test/setupTests.ts:
--------------------------------------------------------------------------------
1 | const consoleError = console.error;
2 |
3 | let consoleErrorLog: any[] = [];
4 |
5 | beforeEach(() => {
6 | consoleErrorLog = [];
7 | // Make sure we aren't triggering React console.error calls
8 | console.error = (...args: any[]) => {
9 | // NOTE: We can't throw in here directly as most console.error calls happen
10 | // inside promises and result in an unhandled promise rejection
11 | consoleErrorLog.push(`console.error called with args: ${args}`);
12 | consoleError.apply(console, args as any);
13 | };
14 | });
15 |
16 | afterEach(() => {
17 | if (consoleErrorLog.length > 0) {
18 | // Not using an Error object here because the stacktrace is misleading
19 | throw consoleErrorLog[0];
20 | }
21 |
22 | console.error = consoleError;
23 | });
24 |
--------------------------------------------------------------------------------
/website/versioned_sidebars/version-1.2.0-sidebars.json:
--------------------------------------------------------------------------------
1 | {
2 | "version-1.2.0-docs": {
3 | "Getting Started": [
4 | "version-1.2.0-overview",
5 | "version-1.2.0-tutorial",
6 | "version-1.2.0-resources"
7 | ],
8 | "Guides": [
9 | "version-1.2.0-guides/validation",
10 | "version-1.2.0-guides/arrays",
11 | "version-1.2.0-guides/typescript",
12 | "version-1.2.0-guides/react-native",
13 | "version-1.2.0-guides/form-submission"
14 | ],
15 | "API Reference": [
16 | "version-1.2.0-api/formik",
17 | "version-1.2.0-api/withFormik",
18 | "version-1.2.0-api/field",
19 | "version-1.2.0-api/fieldarray",
20 | "version-1.2.0-api/form",
21 | "version-1.2.0-api/connect",
22 | "version-1.2.0-api/fastfield"
23 | ]
24 | }
25 | }
--------------------------------------------------------------------------------
/website/versioned_sidebars/version-1.3.0-sidebars.json:
--------------------------------------------------------------------------------
1 | {
2 | "version-1.3.0-docs": {
3 | "Getting Started": [
4 | "version-1.3.0-overview",
5 | "version-1.3.0-tutorial",
6 | "version-1.3.0-resources"
7 | ],
8 | "Guides": [
9 | "version-1.3.0-guides/validation",
10 | "version-1.3.0-guides/arrays",
11 | "version-1.3.0-guides/typescript",
12 | "version-1.3.0-guides/react-native",
13 | "version-1.3.0-guides/form-submission"
14 | ],
15 | "API Reference": [
16 | "version-1.3.0-api/formik",
17 | "version-1.3.0-api/withFormik",
18 | "version-1.3.0-api/field",
19 | "version-1.3.0-api/fieldarray",
20 | "version-1.3.0-api/form",
21 | "version-1.3.0-api/errormessage",
22 | "version-1.3.0-api/connect",
23 | "version-1.3.0-api/fastfield"
24 | ]
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/packages/formik/.size-snapshot.json:
--------------------------------------------------------------------------------
1 | {
2 | "./dist/formik.umd.production.js": {
3 | "bundled": 137573,
4 | "minified": 37797,
5 | "gzipped": 11769
6 | },
7 | "./dist/formik.umd.development.js": {
8 | "bundled": 146347,
9 | "minified": 40818,
10 | "gzipped": 12952
11 | },
12 | "./dist/formik.cjs.production.js": {
13 | "bundled": 43323,
14 | "minified": 20634,
15 | "gzipped": 5847
16 | },
17 | "./dist/formik.cjs.development.js": {
18 | "bundled": 45484,
19 | "minified": 22585,
20 | "gzipped": 6495
21 | },
22 | "dist/formik.esm.js": {
23 | "bundled": 41130,
24 | "minified": 21850,
25 | "gzipped": 6385,
26 | "treeshaked": {
27 | "rollup": {
28 | "code": 383,
29 | "import_statements": 349
30 | },
31 | "webpack": {
32 | "code": 2705
33 | }
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/website/static/css/fonts.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'FormikSans';
3 | font-weight: 400;
4 | src: url('/formik/fonts/FormikSans-Book.woff2') format('woff2'),
5 | url('/formik/fonts/FormikSans-Book.woff') format('woff'),
6 | url('/formik/fonts/FormikSans-Book.ttf') format('truetype');
7 | }
8 |
9 | @font-face {
10 | font-family: 'FormikSans';
11 | font-weight: 500;
12 | src: url('/formik/fonts/FormikSans-Medium.woff2') format('woff2'),
13 | url('/formik/fonts/FormikSans-Medium.woff') format('woff'),
14 | url('/formik/fonts/FormikSans-Medium.ttf') format('truetype');
15 | }
16 |
17 | @font-face {
18 | font-family: 'FormikSans';
19 | font-weight: 700;
20 | src: url('/formik/fonts/FormikSans-Demi.woff2') format('woff2'),
21 | url('/formik/fonts/FormikSans-Demi.woff') format('woff'),
22 | url('/formik/fonts/FormikSans-Demi.ttf') format('truetype');
23 | }
--------------------------------------------------------------------------------
/packages/formik/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "include": ["src", "types"],
4 | "compilerOptions": {
5 | "target": "es5",
6 | "module": "esnext",
7 | "lib": ["dom", "esnext"],
8 | "importHelpers": true,
9 | "declaration": true,
10 | "sourceMap": true,
11 | "rootDir": "./",
12 | "strict": true,
13 | "noImplicitAny": true,
14 | "strictNullChecks": true,
15 | "strictFunctionTypes": true,
16 | "strictPropertyInitialization": true,
17 | "noImplicitThis": true,
18 | "alwaysStrict": true,
19 | "noUnusedLocals": true,
20 | "noUnusedParameters": true,
21 | "noImplicitReturns": true,
22 | "noFallthroughCasesInSwitch": true,
23 | "moduleResolution": "node",
24 | "jsx": "react",
25 | "esModuleInterop": true,
26 | "baseUrl": "./",
27 | "paths": {
28 | "*": ["src/*", "node_modules/*"]
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/packages/formik-native/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "include": ["src", "types"],
4 | "compilerOptions": {
5 | "target": "es5",
6 | "module": "esnext",
7 | "lib": ["es2015", "es2016", "esnext"],
8 | "jsx": "react-native",
9 | "importHelpers": true,
10 | "declaration": true,
11 | "sourceMap": true,
12 | "rootDir": "./",
13 | "strict": true,
14 | "noImplicitAny": true,
15 | "strictNullChecks": true,
16 | "strictFunctionTypes": true,
17 | "strictPropertyInitialization": true,
18 | "noImplicitThis": true,
19 | "alwaysStrict": true,
20 | "noUnusedLocals": true,
21 | "noUnusedParameters": true,
22 | "noImplicitReturns": true,
23 | "noFallthroughCasesInSwitch": true,
24 | "moduleResolution": "node",
25 | "esModuleInterop": true,
26 | "baseUrl": "./",
27 | "paths": {
28 | "*": ["src/*", "node_modules/*"]
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/packages/formik/types/index.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'react-testing-library';
2 | declare module 'tiny-warning' {
3 | export default function warning(condition: any, message: string): void;
4 | }
5 |
6 | declare module 'react-lifecycles-compat' {
7 | import React from 'react';
8 | export function polyfill(
9 | Comp: React.ComponentType
10 | ): React.ComponentType
;
11 | }
12 |
13 | declare module 'deepmerge' {
14 | export = deepmerge;
15 |
16 | function deepmerge(
17 | x: Partial,
18 | y: Partial,
19 | options?: deepmerge.Options
20 | ): T;
21 | function deepmerge(
22 | x: T1,
23 | y: T2,
24 | options?: deepmerge.Options
25 | ): T1 & T2;
26 |
27 | namespace deepmerge {
28 | interface Options {
29 | clone?: boolean;
30 | arrayMerge?(destination: any[], source: any[], options?: Options): any[];
31 | isMergeableObject?(value: object): boolean;
32 | }
33 |
34 | function all(objects: Array>, options?: Options): T;
35 | }
36 | }
37 | declare module 'scheduler';
38 |
--------------------------------------------------------------------------------
/website/versioned_sidebars/version-2.0.3-sidebars.json:
--------------------------------------------------------------------------------
1 | {
2 | "version-2.0.3-docs": {
3 | "Getting Started": [
4 | "version-2.0.3-overview",
5 | "version-2.0.3-tutorial",
6 | "version-2.0.3-3rd-party-bindings",
7 | "version-2.0.3-migrating-v2",
8 | "version-2.0.3-resources"
9 | ],
10 | "Guides": [
11 | "version-2.0.3-guides/validation",
12 | "version-2.0.3-guides/arrays",
13 | "version-2.0.3-guides/typescript",
14 | "version-2.0.3-guides/react-native",
15 | "version-2.0.3-guides/form-submission"
16 | ],
17 | "API Reference": [
18 | "version-2.0.3-api/connect",
19 | "version-2.0.3-api/errormessage",
20 | "version-2.0.3-api/fastfield",
21 | "version-2.0.3-api/field",
22 | "version-2.0.3-api/fieldarray",
23 | "version-2.0.3-api/form",
24 | "version-2.0.3-api/formik",
25 | "version-2.0.3-api/useField",
26 | "version-2.0.3-api/useFormik",
27 | "version-2.0.3-api/useFormikContext",
28 | "version-2.0.3-api/withFormik"
29 | ]
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/website/versioned_sidebars/version-2.1.4-sidebars.json:
--------------------------------------------------------------------------------
1 | {
2 | "version-2.1.4-docs": {
3 | "Getting Started": [
4 | "version-2.1.4-overview",
5 | "version-2.1.4-tutorial",
6 | "version-2.1.4-migrating-v2",
7 | "version-2.1.4-3rd-party-bindings",
8 | "version-2.1.4-resources"
9 | ],
10 | "Guides": [
11 | "version-2.1.4-guides/validation",
12 | "version-2.1.4-guides/arrays",
13 | "version-2.1.4-guides/typescript",
14 | "version-2.1.4-guides/react-native",
15 | "version-2.1.4-guides/form-submission"
16 | ],
17 | "API Reference": [
18 | "version-2.1.4-api/connect",
19 | "version-2.1.4-api/errormessage",
20 | "version-2.1.4-api/fastfield",
21 | "version-2.1.4-api/field",
22 | "version-2.1.4-api/fieldarray",
23 | "version-2.1.4-api/form",
24 | "version-2.1.4-api/formik",
25 | "version-2.1.4-api/useField",
26 | "version-2.1.4-api/useFormik",
27 | "version-2.1.4-api/useFormikContext",
28 | "version-2.1.4-api/withFormik"
29 | ]
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/examples/Debug.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { FormikConsumer } from 'formik';
3 |
4 | export const Debug = () => (
5 |
13 |
26 | Formik State
27 |
28 |
29 | {({ validationSchema, validate, onSubmit, ...rest }) => (
30 |
37 | {JSON.stringify(rest, null, 2)}
38 |
39 | )}
40 |
41 |
42 | );
43 |
--------------------------------------------------------------------------------
/examples/basic/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import { Formik, Field, Form } from "formik";
4 |
5 | const sleep = ms => new Promise(r => setTimeout(r, ms));
6 |
7 | const Basic = () => (
8 |
9 |
Sign Up
10 | {
17 | await sleep(500);
18 | alert(JSON.stringify(values, null, 2));
19 | }}
20 | >
21 |
32 |
33 |
34 | );
35 |
36 | ReactDOM.render(, document.getElementById("root"));
37 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Test
2 |
3 | on:
4 | pull_request:
5 | types: [opened, synchronize, reopened]
6 |
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 |
11 | strategy:
12 | matrix:
13 | node: ['12.x']
14 |
15 | name: Test on node ${{ matrix.node }}
16 |
17 | steps:
18 | - uses: actions/checkout@v1
19 |
20 | - name: Use Node.js ${{ matrix.node }}
21 | uses: actions/setup-node@v1
22 | with:
23 | node-version: ${{ matrix.node }}
24 |
25 | - uses: actions/cache@v1
26 | with:
27 | path: ~/.cache/yarn
28 | key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
29 | restore-keys: |
30 | ${{ runner.os }}-yarn-
31 |
32 | - name: Install deps, build, and test
33 | run: |
34 | node --version
35 | npm --version
36 | yarn --version
37 | yarn install --frozen-lockfile
38 | yarn test --coverage
39 | env:
40 | CI: true
41 | NODE_OPTIONS: --max-old-space-size=4096
42 |
--------------------------------------------------------------------------------
/packages/formik/src/Form.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { useFormikContext } from './FormikContext';
3 |
4 | export type FormikFormProps = Pick<
5 | React.FormHTMLAttributes,
6 | Exclude<
7 | keyof React.FormHTMLAttributes,
8 | 'onReset' | 'onSubmit'
9 | >
10 | >;
11 |
12 | type FormProps = React.ComponentPropsWithoutRef<'form'>;
13 |
14 | // @todo tests
15 | export const Form = React.forwardRef(
16 | (props: FormikFormProps, ref) => {
17 | // iOS needs an "action" attribute for nice input: https://stackoverflow.com/a/39485162/406725
18 | // We default the action to "#" in case the preventDefault fails (just updates the URL hash)
19 | const { action, ...rest } = props;
20 | const _action = action || '#';
21 | const { handleReset, handleSubmit } = useFormikContext();
22 | return (
23 |
30 | );
31 | }
32 | );
33 |
34 | Form.displayName = 'Form';
35 |
--------------------------------------------------------------------------------
/docs/api/connect.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: connect
3 | title: connect()
4 | custom_edit_url: https://github.com/jaredpalmer/formik/edit/master/docs/api/connect.md
5 | ---
6 |
7 | `connect()` is a higher-order component (HoC) that allows you to hook anything into Formik's context. It is used internally to construct `` and `