Skip to content

Commit

Permalink
Add formik-next
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpalmer committed Aug 4, 2017
1 parent e20a98b commit ec95e08
Show file tree
Hide file tree
Showing 9 changed files with 1,836 additions and 1,141 deletions.
1,012 changes: 226 additions & 786 deletions README.md

Large diffs are not rendered by default.

79 changes: 35 additions & 44 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)": [
Expand All @@ -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"]
}
}
65 changes: 47 additions & 18 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -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(),
],
},
];
19 changes: 10 additions & 9 deletions rollup.config.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions src/formik.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit ec95e08

Please sign in to comment.