New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bee-datepicker

Package Overview
Dependencies
Maintainers
11
Versions
276
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bee-datepicker - npm Package Compare versions

Comparing version 1.0.31 to 1.0.32

32

build/RangePicker.js

@@ -55,3 +55,3 @@ "use strict";

function format(v, f) {
return v ? v.format(f) : '';
return v ? v.format && v.format(f) : '';
}

@@ -93,5 +93,7 @@

Picker.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
this.setState({
value: nextProps.defaultValue || []
});
if ("value" in nextProps) {
this.setState({
value: nextProps.value
});
}
};

@@ -107,2 +109,3 @@

var formatStr = props.format || 'YYYY-MM-DD';
var calendar = _react2["default"].createElement(_RangeCalendar2["default"], {

@@ -115,3 +118,3 @@ hoverValue: this.state.hoverValue,

locale: props.locale || _zh_CN2["default"],
onChange: this.handleCalendarChange,
onChange: this.onChange,
disabledDate: props.disabledDate,

@@ -152,3 +155,11 @@ showClear: props.showClear || false,

//console.log('onChange', value);
_this3.setState({ value: value });
var props = _this3.props;
var formatStr = props.format || 'YYYY-MM-DD';
_this3.setState({
value: value
});
//传入value和dateString
if (props.onChange && isValidRange(value)) {
props.onChange(value, "[\"" + format(value[0], formatStr) + "\" , \"" + format(value[1], formatStr) + "\"]");
}
};

@@ -165,10 +176,3 @@

this.handleCalendarChange = function (value) {
var props = _this3.props;
if (!("value" in props)) {
_this3.setState({ value: value });
}
props.onChange(value);
};
this.handleCalendarChange = function (value) {};
};

@@ -175,0 +179,0 @@

@@ -36,4 +36,4 @@ /**

}
onChange = d => {
console.log(d.format(format));
onChange = (d,dataString) => {
console.log(dataString);
this.setState({

@@ -40,0 +40,0 @@ value:d

@@ -13,3 +13,6 @@ /**

import moment from "moment/moment";
import Form from 'bee-form';
const FormItem = Form.FormItem;
const now = moment();

@@ -53,5 +56,3 @@

onChange (d) {
this.setState({
value:d,
})
console.log(d);
}

@@ -61,3 +62,5 @@

const props = this.props;
console.log(this.state.v);
const self = this;
const { getFieldProps, getFieldError } = this.props.form;
console.log(this.state.value)
return (

@@ -68,12 +71,6 @@ <div>

<RangePicker
format={"YYYY-MM-DD"}
locale={zhCN}
onSelect={onSelect}
onChange={this.onChange.bind(this)}
placeholder={'开始 ~ 结束'}
dateInputPlaceholder={['开始', '结束']}
showClear={true}
showOk={true}
className={'range-fixed'}
defaultValue={this.state.value}
placeholder={'开始时间 ~ 结束时间'}
dateInputPlaceholder={['开始时间', '结束时间']}
value={this.state.value}
/>

@@ -90,2 +87,2 @@ </Col>

export default Demo3;
export default Form.createForm()(Demo3)

@@ -13,3 +13,3 @@ import {Col, Row} from 'bee-layout';

var Demo1 = require("./demolist/Demo1");var Demo2 = require("./demolist/Demo2");var Demo3 = require("./demolist/Demo3");var Demo4 = require("./demolist/Demo4");var Demo5 = require("./demolist/Demo5");var Demo6 = require("./demolist/Demo6");var Demo7 = require("./demolist/Demo7");var Demo8 = require("./demolist/Demo8");var Demo9 = require("./demolist/Demo9");var DemoArray = [{"example":<Demo1 />,"title":" 选择日期","code":"/**\n *\n * @title 选择日期\n * @description 以「日期」为基本单位,基础的日期选择控件\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport enUS from \"rc-calendar/lib/locale/en_US\";\nimport moment from \"moment\";\nimport Icon from 'bee-icon';\nimport 'moment/locale/zh-cn';\nmoment.locale('zh-cn');\n\nconst format = \"YYYY-MM-DD dddd\";\n\nconst dateInputPlaceholder = \"选择日期\";\n\nfunction onSelect(d) {\n // console.log(d);\n}\n\nconsole.log(moment().format(format));\n\n\nclass Demo1 extends Component {\n constructor(props) {\n super(props);\n this.state = {\n value: ''\n };\n }\n onChange = d => {\n console.log(d.format(format));\n this.setState({\n value:d\n })\n };\n clear = d => {\n this.setState({\n value:''\n })\n }\n render() {\n var self = this;\n return (\n <div>\n <Row>\n <Col md={8}>\n <DatePicker\n format={format}\n onSelect={onSelect}\n onChange={this.onChange}\n locale={zhCN}\n //defaultValue={this.state.value}\n value={this.state.value}\n placeholder={dateInputPlaceholder}\n className={\"uuuu\"}\n autofocus={false}\n />\n </Col>\n <Col md={3}>\n <button className=\"u-button\" onClick={this.clear}>清空</button>\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「日期」为基本单位,基础的日期选择控件"},{"example":<Demo2 />,"title":" 选择年月","code":"/**\n *\n * @title 选择年月\n * @description 以「年月」为基本单位,基础的年月选择控件\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\nimport moment from \"moment\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport enUS from \"rc-calendar/lib/locale/en_US\";\n\nconst { MonthPicker } = DatePicker;\n\nconst format2 = \"YYYY-MM\";\n\nfunction onSelect(d) {\n console.log(d);\n}\n\nfunction onChange(d) {\n console.log(d);\n}\n\nclass Demo2 extends Component {\n render() {\n return (\n <div>\n <Row>\n <Col md={12}>\n <MonthPicker\n format={format2}\n onSelect={onSelect}\n onChange={onChange}\n locale={zhCN}\n defaultValue={moment()}\n placeholder={\"选择年月\"}\n />\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「年月」为基本单位,基础的年月选择控件"},{"example":<Demo3 />,"title":" 日期范围","code":"/**\n *\n * @title 日期范围\n * @description 以「日期范围」为基本单位,基础的日期范围选择控件\n */\n\nimport React, {Component} from \"react\";\nimport {Row, Col} from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport moment from \"moment/moment\";\n\nconst now = moment();\n\nconst {RangePicker} = DatePicker;\n\nconst format3 = \"YYYY-MM-DD\";\n\nfunction formatValue(value, format) {\n return (value && value.format(format)) || '';\n}\n\nfunction onSelect(d) {\n //console.log(d);\n}\n\n\n\nclass Demo3 extends Component {\n constructor(props) {\n super(props);\n this.state = {\n value: '',\n v:''\n };\n }\n\n onStartChange = (value) => {\n this.setState({\n startValue: value[0],\n startOpen: false,\n endOpen: true,\n });\n }\n\n remove() {\n this.setState({value: ''})\n }\n\n onChange (d) {\n this.setState({\n value:d,\n })\n }\n\n render() {\n const props = this.props;\n console.log(this.state.v);\n return (\n <div>\n <Row>\n <Col md={8}>\n <RangePicker\n format={\"YYYY-MM-DD\"}\n locale={zhCN}\n onSelect={onSelect}\n onChange={this.onChange.bind(this)}\n showClear={true}\n showOk={true}\n className={'range-fixed'}\n defaultValue={this.state.value}\n placeholder={'开始时间 ~ 结束时间'}\n dateInputPlaceholder={['开始时间', '结束时间']}\n />\n </Col>\n <Col md={3}>\n <button className=\"u-button\" onClick={this.remove.bind(this)}>清空</button>\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「日期范围」为基本单位,基础的日期范围选择控件"},{"example":<Demo4 />,"title":" 动态的改变时间","code":"/**\n *\n * @title 动态的改变时间\n * @description 以「日期时间」为基本单位,基础的日期时间选择控件\n */\n\nimport React, { Component } from \"react\";\nimport DatePicker from \"../../src/index\";\nimport moment from \"moment\";\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport { Row, Col } from \"bee-layout\";\nimport Button from \"bee-button\";\nconst format = \"YYYY-MM-DD HH:mm:ss\";\nconst dateInputPlaceholder = \"选择日期\";\n\nclass Demo4 extends Component {\n constructor(props) {\n super(props);\n this.state = {\n value: moment()\n };\n }\n\n handleChange = value => {\n this.setState({\n value: value\n });\n };\n onSelect = d => {\n console.log(d);\n };\n\n handlerChangeDate = () => {\n this.setState({\n value: moment(\"2011-11-11 11:11:11\")\n });\n console.log(\"click\");\n };\n render() {\n return (\n <div>\n <Row>\n <Col md={8}>\n <DatePicker\n format={format}\n locale={zhCN}\n onSelect={this.onSelect}\n onChange={this.handleChange}\n value={this.state.value}\n placeholder={dateInputPlaceholder}\n />\n </Col>\n <Col md={3}>\n <Button onClick={this.handlerChangeDate}>变</Button>\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「日期时间」为基本单位,基础的日期时间选择控件"},{"example":<Demo5 />,"title":" 选择周","code":"/**\n *\n * @title 选择周\n * @description 以「周」为基本单位,基础的周选择控件\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\nconst { WeekPicker } = DatePicker;\nimport moment from \"moment\";\n\nfunction onSelect(d) {\n console.log(d);\n}\n\nfunction onChange(d) {\n console.log(d);\n}\n\nclass Demo5 extends Component {\n render() {\n return (\n <div>\n <Row>\n <Col md={12}>\n <WeekPicker defaultValue={''} onChange={onChange} placeholder=\"选择周\" />\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「周」为基本单位,基础的周选择控件"},{"example":<Demo6 />,"title":" 选择日期时间","code":"/**\n *\n * @title 选择日期时间\n * @description 以「日期时间」为基本单位,可以选择日期和时间\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport enUS from \"rc-calendar/lib/locale/en_US\";\nimport moment from \"moment\";\n\nconst format = \"YYYY-MM-DD HH:mm:ss\";\n\nconst dateInputPlaceholder = \"选择日期\";\n\nfunction onSelect(d) {\n console.log(d);\n}\n\nfunction onChange(d) {\n console.log(d);\n}\n\nclass Demo6 extends Component {\n render() {\n return (\n <div>\n <Row>\n <Col md={12}>\n <DatePicker\n format={format}\n showTime={true}\n onSelect={onSelect}\n onChange={onChange}\n locale={zhCN}\n defaultValue={moment()}\n placeholder={dateInputPlaceholder}\n />\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「日期时间」为基本单位,可以选择日期和时间"},{"example":<Demo7 />,"title":" 禁用日期","code":"/**\n *\n * @title 禁用日期\n * @description 禁用日期\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport enUS from \"rc-calendar/lib/locale/en_US\";\nimport moment from \"moment\";\n\nconst format = \"YYYY-MM-DD\";\n\nconst dateInputPlaceholder = \"选择日期\";\n\nfunction onSelect(d) {\n console.log(d);\n}\n\nfunction onChange(d) {\n console.log(d);\n}\n\nclass Demo7 extends Component {\n render() {\n return (\n <div>\n <Row>\n <Col md={12}>\n <DatePicker\n format={format}\n onSelect={onSelect}\n onChange={onChange}\n locale={zhCN}\n defaultValue={moment()}\n placeholder={dateInputPlaceholder}\n disabled={true}\n />\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 禁用日期"},{"example":<Demo8 />,"title":" 不可选择日期和时间","code":"/**\n *\n * @title 不可选择日期和时间\n * @description 可用 disabledDate 和 disabledTime 分别禁止选择部分日期和时间,其中 disabledTime 需要和 showTime 一起使用。\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport moment from \"moment\";\n\nconst format = \"YYYY-MM-DD\";\n\nconst dateInputPlaceholder = \"选择日期\";\n\nfunction onSelect(d) {\n console.log(d);\n}\n\nfunction onChange(d) {\n console.log(d);\n}\n\nfunction disabledDate(current) {\n return current && current.valueOf() < Date.now();\n}\n\nclass Demo7 extends Component {\n render() {\n return (\n <div>\n <Row>\n <Col md={12}>\n <DatePicker\n format={format}\n onSelect={onSelect}\n onChange={onChange}\n locale={zhCN}\n disabledDate={disabledDate}\n defaultValue={moment()}\n placeholder={dateInputPlaceholder}\n />\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 可用 disabledDate 和 disabledTime 分别禁止选择部分日期和时间,其中 disabledTime 需要和 showTime 一起使用。"},{"example":<Demo9 />,"title":" 自定义日期渲染父级容器","code":"/**\n *\n * @title 自定义日期渲染父级容器\n * @description 以「日期」为基本单位,基础的日期选择控件\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport enUS from \"rc-calendar/lib/locale/en_US\";\nimport moment from \"moment\";\nimport Icon from 'bee-icon';\n\nconst format = \"YYYY-MM-DD\";\n\nconst dateInputPlaceholder = \"选择日期\";\n\nfunction onSelect(d) {\n // console.log(d);\n}\n\nfunction onChange(d) {\n this.setState({\n value: ''\n });\n}\n\nclass Demo1 extends Component {\n constructor(props) {\n super(props);\n this.state = {\n value: ''\n };\n }\n getCalendarContainer() {\n return this.d || document.getElementById('d');\n }\n onChange = d => {\n console.log(d)\n\n this.setState({\n value: ''\n });\n };\n render() {\n return (\n <div id=\"d\" ref=\"d\">\n <Row>\n <Col md={12}>\n <DatePicker\n format={format}\n onSelect={onSelect}\n onChange={this.onChange}\n locale={zhCN}\n defaultValue={this.state.value}\n placeholder={dateInputPlaceholder}\n getCalendarContainer={this.getCalendarContainer}\n />\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「日期」为基本单位,基础的日期选择控件"}]
var Demo1 = require("./demolist/Demo1");var Demo2 = require("./demolist/Demo2");var Demo3 = require("./demolist/Demo3");var Demo4 = require("./demolist/Demo4");var Demo5 = require("./demolist/Demo5");var Demo6 = require("./demolist/Demo6");var Demo7 = require("./demolist/Demo7");var Demo8 = require("./demolist/Demo8");var Demo9 = require("./demolist/Demo9");var DemoArray = [{"example":<Demo1 />,"title":" 选择日期","code":"/**\n *\n * @title 选择日期\n * @description 以「日期」为基本单位,基础的日期选择控件\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport enUS from \"rc-calendar/lib/locale/en_US\";\nimport moment from \"moment\";\nimport Icon from 'bee-icon';\nimport 'moment/locale/zh-cn';\nmoment.locale('zh-cn');\n\nconst format = \"YYYY-MM-DD dddd\";\n\nconst dateInputPlaceholder = \"选择日期\";\n\nfunction onSelect(d) {\n // console.log(d);\n}\n\nconsole.log(moment().format(format));\n\n\nclass Demo1 extends Component {\n constructor(props) {\n super(props);\n this.state = {\n value: ''\n };\n }\n onChange = (d,dataString) => {\n console.log(dataString);\n this.setState({\n value:d\n })\n };\n clear = d => {\n this.setState({\n value:''\n })\n }\n render() {\n var self = this;\n return (\n <div>\n <Row>\n <Col md={8}>\n <DatePicker\n format={format}\n onSelect={onSelect}\n onChange={this.onChange}\n locale={zhCN}\n //defaultValue={this.state.value}\n value={this.state.value}\n placeholder={dateInputPlaceholder}\n className={\"uuuu\"}\n autofocus={false}\n />\n </Col>\n <Col md={3}>\n <button className=\"u-button\" onClick={this.clear}>清空</button>\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「日期」为基本单位,基础的日期选择控件"},{"example":<Demo2 />,"title":" 选择年月","code":"/**\n *\n * @title 选择年月\n * @description 以「年月」为基本单位,基础的年月选择控件\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\nimport moment from \"moment\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport enUS from \"rc-calendar/lib/locale/en_US\";\n\nconst { MonthPicker } = DatePicker;\n\nconst format2 = \"YYYY-MM\";\n\nfunction onSelect(d) {\n console.log(d);\n}\n\nfunction onChange(d) {\n console.log(d);\n}\n\nclass Demo2 extends Component {\n render() {\n return (\n <div>\n <Row>\n <Col md={12}>\n <MonthPicker\n format={format2}\n onSelect={onSelect}\n onChange={onChange}\n locale={zhCN}\n defaultValue={moment()}\n placeholder={\"选择年月\"}\n />\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「年月」为基本单位,基础的年月选择控件"},{"example":<Demo3 />,"title":" 日期范围","code":"/**\n *\n * @title 日期范围\n * @description 以「日期范围」为基本单位,基础的日期范围选择控件\n */\n\nimport React, {Component} from \"react\";\nimport {Row, Col} from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport moment from \"moment/moment\";\nimport Form from 'bee-form';\nconst FormItem = Form.FormItem;\n\n\nconst now = moment();\n\nconst {RangePicker} = DatePicker;\n\nconst format3 = \"YYYY-MM-DD\";\n\nfunction formatValue(value, format) {\n return (value && value.format(format)) || '';\n}\n\nfunction onSelect(d) {\n //console.log(d);\n}\n\n\n\nclass Demo3 extends Component {\n constructor(props) {\n super(props);\n this.state = {\n value: '',\n v:''\n };\n }\n\n onStartChange = (value) => {\n this.setState({\n startValue: value[0],\n startOpen: false,\n endOpen: true,\n });\n }\n\n remove() {\n this.setState({value: ''})\n }\n\n onChange (d) {\n console.log(d);\n }\n\n render() {\n const props = this.props;\n const self = this;\n const { getFieldProps, getFieldError } = this.props.form;\n console.log(this.state.value)\n return (\n <div>\n <Row>\n <Col md={8}>\n <RangePicker\n placeholder={'开始 ~ 结束'}\n dateInputPlaceholder={['开始', '结束']}\n showClear={true}\n value={this.state.value}\n />\n </Col>\n <Col md={3}>\n <button className=\"u-button\" onClick={this.remove.bind(this)}>清空</button>\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「日期范围」为基本单位,基础的日期范围选择控件"},{"example":<Demo4 />,"title":" 动态的改变时间","code":"/**\n *\n * @title 动态的改变时间\n * @description 以「日期时间」为基本单位,基础的日期时间选择控件\n */\n\nimport React, { Component } from \"react\";\nimport DatePicker from \"../../src/index\";\nimport moment from \"moment\";\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport { Row, Col } from \"bee-layout\";\nimport Button from \"bee-button\";\nconst format = \"YYYY-MM-DD HH:mm:ss\";\nconst dateInputPlaceholder = \"选择日期\";\n\nclass Demo4 extends Component {\n constructor(props) {\n super(props);\n this.state = {\n value: moment()\n };\n }\n\n handleChange = value => {\n this.setState({\n value: value\n });\n };\n onSelect = d => {\n console.log(d);\n };\n\n handlerChangeDate = () => {\n this.setState({\n value: moment(\"2011-11-11 11:11:11\")\n });\n console.log(\"click\");\n };\n render() {\n return (\n <div>\n <Row>\n <Col md={8}>\n <DatePicker\n format={format}\n locale={zhCN}\n onSelect={this.onSelect}\n onChange={this.handleChange}\n value={this.state.value}\n placeholder={dateInputPlaceholder}\n />\n </Col>\n <Col md={3}>\n <Button onClick={this.handlerChangeDate}>变</Button>\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「日期时间」为基本单位,基础的日期时间选择控件"},{"example":<Demo5 />,"title":" 选择周","code":"/**\n *\n * @title 选择周\n * @description 以「周」为基本单位,基础的周选择控件\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\nconst { WeekPicker } = DatePicker;\nimport moment from \"moment\";\n\nfunction onSelect(d) {\n console.log(d);\n}\n\nfunction onChange(d) {\n console.log(d);\n}\n\nclass Demo5 extends Component {\n render() {\n return (\n <div>\n <Row>\n <Col md={12}>\n <WeekPicker defaultValue={''} onChange={onChange} placeholder=\"选择周\" />\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「周」为基本单位,基础的周选择控件"},{"example":<Demo6 />,"title":" 选择日期时间","code":"/**\n *\n * @title 选择日期时间\n * @description 以「日期时间」为基本单位,可以选择日期和时间\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport enUS from \"rc-calendar/lib/locale/en_US\";\nimport moment from \"moment\";\n\nconst format = \"YYYY-MM-DD HH:mm:ss\";\n\nconst dateInputPlaceholder = \"选择日期\";\n\nfunction onSelect(d) {\n console.log(d);\n}\n\nfunction onChange(d) {\n console.log(d);\n}\n\nclass Demo6 extends Component {\n render() {\n return (\n <div>\n <Row>\n <Col md={12}>\n <DatePicker\n format={format}\n showTime={true}\n onSelect={onSelect}\n onChange={onChange}\n locale={zhCN}\n defaultValue={moment()}\n placeholder={dateInputPlaceholder}\n />\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「日期时间」为基本单位,可以选择日期和时间"},{"example":<Demo7 />,"title":" 禁用日期","code":"/**\n *\n * @title 禁用日期\n * @description 禁用日期\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport enUS from \"rc-calendar/lib/locale/en_US\";\nimport moment from \"moment\";\n\nconst format = \"YYYY-MM-DD\";\n\nconst dateInputPlaceholder = \"选择日期\";\n\nfunction onSelect(d) {\n console.log(d);\n}\n\nfunction onChange(d) {\n console.log(d);\n}\n\nclass Demo7 extends Component {\n render() {\n return (\n <div>\n <Row>\n <Col md={12}>\n <DatePicker\n format={format}\n onSelect={onSelect}\n onChange={onChange}\n locale={zhCN}\n defaultValue={moment()}\n placeholder={dateInputPlaceholder}\n disabled={true}\n />\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 禁用日期"},{"example":<Demo8 />,"title":" 不可选择日期和时间","code":"/**\n *\n * @title 不可选择日期和时间\n * @description 可用 disabledDate 和 disabledTime 分别禁止选择部分日期和时间,其中 disabledTime 需要和 showTime 一起使用。\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport moment from \"moment\";\n\nconst format = \"YYYY-MM-DD\";\n\nconst dateInputPlaceholder = \"选择日期\";\n\nfunction onSelect(d) {\n console.log(d);\n}\n\nfunction onChange(d) {\n console.log(d);\n}\n\nfunction disabledDate(current) {\n return current && current.valueOf() < Date.now();\n}\n\nclass Demo7 extends Component {\n render() {\n return (\n <div>\n <Row>\n <Col md={12}>\n <DatePicker\n format={format}\n onSelect={onSelect}\n onChange={onChange}\n locale={zhCN}\n disabledDate={disabledDate}\n defaultValue={moment()}\n placeholder={dateInputPlaceholder}\n />\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 可用 disabledDate 和 disabledTime 分别禁止选择部分日期和时间,其中 disabledTime 需要和 showTime 一起使用。"},{"example":<Demo9 />,"title":" 自定义日期渲染父级容器","code":"/**\n *\n * @title 自定义日期渲染父级容器\n * @description 以「日期」为基本单位,基础的日期选择控件\n */\n\nimport React, { Component } from \"react\";\nimport { Row, Col } from \"bee-layout\";\nimport DatePicker from \"../../src/index\";\n\nimport zhCN from \"rc-calendar/lib/locale/zh_CN\";\nimport enUS from \"rc-calendar/lib/locale/en_US\";\nimport moment from \"moment\";\nimport Icon from 'bee-icon';\n\nconst format = \"YYYY-MM-DD\";\n\nconst dateInputPlaceholder = \"选择日期\";\n\nfunction onSelect(d) {\n // console.log(d);\n}\n\nfunction onChange(d) {\n this.setState({\n value: ''\n });\n}\n\nclass Demo1 extends Component {\n constructor(props) {\n super(props);\n this.state = {\n value: ''\n };\n }\n getCalendarContainer() {\n return this.d || document.getElementById('d');\n }\n onChange = d => {\n console.log(d)\n\n this.setState({\n value: ''\n });\n };\n render() {\n return (\n <div id=\"d\" ref=\"d\">\n <Row>\n <Col md={12}>\n <DatePicker\n format={format}\n onSelect={onSelect}\n onChange={this.onChange}\n locale={zhCN}\n defaultValue={this.state.value}\n placeholder={dateInputPlaceholder}\n getCalendarContainer={this.getCalendarContainer}\n />\n </Col>\n </Row>\n </div>\n );\n }\n}\n\n\n","desc":" 以「日期」为基本单位,基础的日期选择控件"}]

@@ -16,0 +16,0 @@

{
"name": "bee-datepicker",
"version": "1.0.31",
"version": "1.0.32",
"description": "DatePicker ui component for react",

@@ -5,0 +5,0 @@ "keywords": [

@@ -17,3 +17,3 @@ /**

function format(v,f) {
return v ? v.format(f) : '';
return v ? v.format&&v.format(f) : '';
}

@@ -48,5 +48,7 @@

componentWillReceiveProps(nextProps){
this.setState({
value:nextProps.defaultValue || []
})
if ("value" in nextProps) {
this.setState({
value: nextProps.value
});
}
}

@@ -56,3 +58,11 @@

//console.log('onChange', value);
this.setState({ value });
const props = this.props;
let formatStr = props.format || 'YYYY-MM-DD';
this.setState({
value:value
});
//传入value和dateString
if(props.onChange&&isValidRange(value)){
props.onChange(value,`["${format(value[0],formatStr)}" , "${format(value[1],formatStr)}"]`);
}
}

@@ -70,7 +80,2 @@

const props = this.props;
if (!("value" in props)) {
this.setState({ value });
}
props.onChange(value);
}

@@ -83,2 +88,3 @@

let formatStr = props.format || 'YYYY-MM-DD';
const calendar = (

@@ -92,3 +98,3 @@ <RangeCalendar

locale={props.locale || zhCN }
onChange={this.handleCalendarChange}
onChange={this.onChange}
disabledDate={props.disabledDate}

@@ -102,3 +108,3 @@ showClear={ props.showClear||false}

<DatePicker
value={this.state.value}
value = {this.state.value}
animation="slide-up"

@@ -105,0 +111,0 @@ calendar={calendar}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc