Permalink
Browse files

Add formik-next

  • Loading branch information...
jaredpalmer committed Aug 4, 2017
1 parent e20a98b commit ec95e08566439fe139e035efca53eb155be2ee84
Showing with 1,836 additions and 1,141 deletions.
  1. +226 −786 README.md
  2. +35 −44 package.json
  3. +47 −18 rollup.config.js
  4. +10 −9 rollup.config.umd.js
  5. +3 −3 src/formik.tsx
  6. +585 −0 src/next.tsx
  7. +675 −0 test/next.test.tsx
  8. +0 −1 tslint.json
  9. +255 −280 yarn.lock
1,012 README.md

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -18,9 +18,7 @@
"main": "dist/formik.js",
"module": "dist/formik.es6.js",
"typings": "dist/types/formik.d.ts",
"files": [
"dist"
],
"files": ["dist"],
"scripts": {
"test": "jest --env=jsdom",
"test:watch": "npm run test -- --watch",
@@ -37,35 +35,37 @@
},
"optionalDependencies": {},
"devDependencies": {
"@types/enzyme": "^2.8.2",
"@types/jest": "^20.0.2",
"@types/node": "^8.0.7",
"@types/react": "^15.0.28",
"@types/react-dom": "^15.5.0",
"@types/react-test-renderer": "^15.5.1",
"enzyme": "^2.9.1",
"husky": "^0.14.2",
"jest": "^20.0.4",
"lint-staged": "^4.0.0",
"lodash.camelcase": "^4.3.0",
"prettier": "^1.5.2",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-test-renderer": "^15.6.1",
"rimraf": "^2.6.1",
"rollup": "^0.45.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-filesize": "^1.4.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^1.1.1",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-uglify": "^2.0.1",
"ts-jest": "^20.0.6",
"tsc-watch": "^1.0.7",
"tslint": "^5.3.2",
"tslint-react": "^3.0.0",
"typescript": "2.3.4",
"yup": "^0.21.3"
"@types/enzyme": "2.8.4",
"@types/jest": "20.0.6",
"@types/node": "8.0.19",
"@types/prop-types": "15.5.1",
"@types/react": "16.0.0",
"@types/react-dom": "15.5.1",
"@types/react-test-renderer": "15.5.2",
"enzyme": "2.9.1",
"husky": "0.14.3",
"jest": "20.0.4",
"lint-staged": "4.0.2",
"lodash.camelcase": "4.3.0",
"prettier": "1.5.3",
"prop-types": "15.5.10",
"react": "15.6.1",
"react-dom": "15.6.1",
"react-test-renderer": "15.6.1",
"rimraf": "2.6.1",
"rollup": "0.45.2",
"rollup-plugin-commonjs": "8.1.0",
"rollup-plugin-filesize": "1.4.2",
"rollup-plugin-node-resolve": "3.0.0",
"rollup-plugin-replace": "1.1.1",
"rollup-plugin-sourcemaps": "0.4.2",
"rollup-plugin-uglify": "2.0.1",
"ts-jest": "20.0.9",
"tsc-watch": "1.0.7",
"tslint": "5.5.0",
"tslint-react": "3.2.0",
"typescript": "2.4.2",
"yup": "0.21.3"
},
"lint-staged": {
"*.(ts|tsx)": [
@@ -74,24 +74,15 @@
]
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{ts,tsx}"
],
"collectCoverageFrom": ["src/**/*.{ts,tsx}"],
"transform": {
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testMatch": [
"<rootDir>/test/**/*.ts?(x)",
"<rootDir>/test/**/?(*.)(spec|test).ts?(x)"
],
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"json"
]
"transformIgnorePatterns": ["[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"],
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
}
}
@@ -1,22 +1,51 @@
import resolve from 'rollup-plugin-node-resolve';
import sourceMaps from 'rollup-plugin-sourcemaps';

export default {
entry: `compiled/formik.js`,
targets: [{ dest: 'dist/formik.es6.js', format: 'es' }, { dest: 'dist/formik.js', format: 'cjs' }],
sourceMap: true,
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: ['react'],
globals: {
react: 'React',
export default [
{
entry: `compiled/formik.js`,
targets: [
{ dest: 'dist/formik.es6.js', format: 'es' },
{ dest: 'dist/formik.js', format: 'cjs' },
],
sourceMap: true,
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: ['react', 'prop-types'],
globals: {
react: 'React',
'prop-types': 'PropTypes',
},
exports: 'named',
plugins: [
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve(),
// Resolve source maps to the original source
sourceMaps(),
],
},
exports: 'named',
plugins: [
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve(),
// Resolve source maps to the original source
sourceMaps(),
],
};
{
entry: `compiled/next.js`,
targets: [
{ dest: 'dist/next.es6.js', format: 'es' },
{ dest: 'dist/next.js', format: 'cjs' },
],
sourceMap: true,
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: ['react', 'prop-types'],
globals: {
react: 'React',
'prop-types': 'PropTypes',
},
exports: 'named',
plugins: [
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve(),
// Resolve source maps to the original source
sourceMaps(),
],
},
];
@@ -4,21 +4,20 @@ import resolve from 'rollup-plugin-node-resolve';
import sourceMaps from 'rollup-plugin-sourcemaps';
import uglify from 'rollup-plugin-uglify';

const pkg = require('./package.json');
const camelCase = require('lodash.camelcase');

const libraryName = 'formik';

export default {
entry: `compiled/${libraryName}.js`,
entry: `compiled/formik.js`,
moduleName: 'Formik',
format: 'umd',
dest: process.env.NODE_ENV === 'production' ? './dist/formik.umd.min.js' : './dist/formik.umd.js',
dest:
process.env.NODE_ENV === 'production'
? './dist/formik.umd.min.js'
: './dist/formik.umd.js',
sourceMap: true,
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: ['react'],
external: ['react', 'prop-types'],
globals: {
react: 'React',
'prop-types': 'PropTypes',
},
exports: 'named',
plugins: [
@@ -28,7 +27,9 @@ export default {
resolve(),
replace({
exclude: 'node_modules/**',
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
'process.env.NODE_ENV': JSON.stringify(
process.env.NODE_ENV || 'development'
),
}),
// Resolve source maps to the original source
sourceMaps(),
@@ -174,16 +174,16 @@ export interface InferableComponentDecorator<TOwnProps> {
export function Formik<Props, Values extends FormikValues, Payload = Values>({
displayName,
mapPropsToValues = vanillaProps => {
let values: Values = {} as Values;
let val: Values = {} as Values;
for (let k in vanillaProps) {
if (
vanillaProps.hasOwnProperty(k) &&
typeof vanillaProps[k] !== 'function'
) {
values[k] = vanillaProps[k];
val[k] = vanillaProps[k];
}
}
return values;
return val;
},
mapValuesToPayload,
validate,
Oops, something went wrong.

0 comments on commit ec95e08

Please sign in to comment.