From 32971800fdea71918f5fb2efcc0a818f8c133082 Mon Sep 17 00:00:00 2001 From: rainie <463103063@qq.com> Date: Sun, 15 Oct 2017 23:13:09 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=20[feature]=20Add=20a=20function:?= =?UTF-8?q?=20Customize=20the=20header(https://github.com/lanjingling0510/?= =?UTF-8?q?react-mobile-datepicker/pull/16)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintignore | 5 + .eslintrc | 35 +- README.md | 2 + config.js | 3 - lib/DatePicker.js | 9 +- lib/index.css | 23 +- lib/index.js | 1 + package-lock.json | 6292 +++++++++++++++++++++++---------------------- package.json | 16 +- webpack.config.js | 1 - 10 files changed, 3239 insertions(+), 3148 deletions(-) delete mode 100644 config.js diff --git a/.eslintignore b/.eslintignore index dc5b4a0..6192758 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,8 @@ dist/* node_modules/* test/* +stories/* +postcss.config.js +rollup.config.js +examples/* +coverage/* diff --git a/.eslintrc b/.eslintrc index 8917d59..f275ce0 100755 --- a/.eslintrc +++ b/.eslintrc @@ -1,28 +1,7 @@ -{ - "extends": "airbnb", - "parser": "babel-eslint", - "rules": { - "camelcase": 0, - "indent": [2, 4, {"SwitchCase": 1}], - "no-use-before-define": 0, - "no-restricted-syntax": ["error", "WithStatement"], - "space-before-function-paren": [2, {"anonymous": "always", "named": "never"}], - "no-param-reassign": 0, - "func-names": 0, - "new-cap": 0, - "no-underscore-dangle": 0, - "arrow-body-style": 0, - "no-console": 0, - "no-nested-ternary": 0, - "block-scoped-var": 0, - "global-require": 0, - "no-confusing-arrow": 0, - "react/jsx-indent-props": [2, 4], - "react/jsx-boolean-value": 0, - "react/jsx-indent": [2, 4], - "react/jsx-closing-bracket-location": [2, {"location": "after-props"}] - }, - "env": { - "jquery": true - } -} +{ + "extends": ["cqaso-kit"], + "rules": { + "flowtype/define-flow-type": 1, + "flowtype/use-flow-type": 1 + } +} diff --git a/README.md b/README.md index 33f8b67..0d68af7 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,8 @@ ReactDOM.render(, document.getElementById('react-box')); | value | Date | new Date() | date value | | min | Date | new Date(1970, 0, 1) | minimum date | | max | Date | new Date(2050, 0, 1) | maximum date | +| showHeader | Boolean | true | whether to show the header | +| customHeader | ReactElement | undefined | customize the header, if you set this property, it will replace `showFormat`| | confirmText | String | 完成 | customize the selection time button text | | cancelText | String | 取消 | customize the cancel button text | | onSelect | Function | () => {} | the callback function after click button of done, Date object as a parameter | diff --git a/config.js b/config.js deleted file mode 100644 index f779793..0000000 --- a/config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - name: 'mobile-datepicker', -}; diff --git a/lib/DatePicker.js b/lib/DatePicker.js index b1e8613..e308105 100644 --- a/lib/DatePicker.js +++ b/lib/DatePicker.js @@ -12,6 +12,8 @@ type Props = { value: Object, min: Object, max: Object, + customHeader?: React.Element<*>, + showHeader: boolean, dateFormat: Array<*>, showFormat: string, confirmText: string, @@ -82,7 +84,7 @@ class DatePicker extends Component { * @return {Object} JSX对象 */ render() { - const { min, max, theme, dateFormat, confirmText, cancelText, showFormat } = this.props; + const { min, max, theme, dateFormat, confirmText, cancelText, showFormat, showHeader, customHeader } = this.props; const value = this.state.value; const themeClassName = ['default', 'dark', 'ios', 'android', 'android-dark'].indexOf(theme) === -1 ? @@ -91,7 +93,8 @@ class DatePicker extends Component { return (
-
{convertDate(value, showFormat)}
+ {showHeader && +
{customHeader || convertDate(value, showFormat)}
}
{dateFormat.map((format, index) => ( { max={max} format={format} onSelect={this.handleDateSelect} /> - ))} + ))}
=0.14" }, "license": "ISC" -} \ No newline at end of file +} diff --git a/webpack.config.js b/webpack.config.js index 8bf1ade..7eabfa1 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,7 +3,6 @@ var path = require('path'); var fs = require('fs'); var webpack = require('webpack'); var HtmlWebpackPlugin = require('html-webpack-plugin'); -var config = require('./config.js'); var postNested = require('postcss-nested'); var cssnext = require('cssnext');