Socket
Socket
Sign inDemoInstall

react-bootstrap-daterangepicker

Package Overview
Dependencies
45
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.0.4

124

lib/index.js

@@ -8,67 +8,65 @@ 'use strict';

*/
(function (window) {
var React = require('react');
window.jQuery = window.jQuery || require('jquery');
var DateRangePicker = require('bootstrap-daterangepicker');
var getOptions = require('./get-options.js');
var React = require('react');
var $ = require('jquery');
var DateRangePicker = require('bootstrap-daterangepicker');
var getOptions = require('./get-options.js');
/* this is our export React class */
module.exports = React.createClass({
$picker: null,
options: getOptions(),
makeEventHandler: function (eventType) {
return function (event, picker) {
if (typeof this.props.onEvent === 'function') {
this.props.onEvent(event, picker);
}
if (typeof this.props[eventType] === 'function') {
this.props[eventType](event, picker);
}
}.bind(this);
},
getOptionsFromProps: function () {
var options, props = this.props;
this.options.forEach(function (option) {
if (props.hasOwnProperty(option)) {
options = options || {};
options[option] = props[option];
}
});
return options || {};
},
setOptionsFromProps: function () {
var currentOptions = this.getOptionsFromProps();
var keys = Object.keys(currentOptions);
var $this = this;
if ($this.$picker) {
if (currentOptions) {
keys.forEach(function (key) {
$this.$picker.data('daterangepicker')[key] = currentOptions[key];
});
}
/* this is our export React class */
module.exports = React.createClass({
$picker: null,
options: getOptions(),
makeEventHandler: function (eventType) {
return function (event, picker) {
if (typeof this.props.onEvent === 'function') {
this.props.onEvent(event, picker);
}
},
componentDidMount: function () {
var $this = this;
$this.$picker = window.jQuery(this.refs.picker);
// initialize
$this.$picker.daterangepicker(this.getOptionsFromProps());
// attach event listeners
['Show', 'Hide', 'ShowCalendar', 'HideCalendar', 'Apply', 'Cancel'].forEach(function (event) {
var lcase = event.toLowerCase();
$this.$picker.on(lcase + '.daterangepicker', $this.makeEventHandler('on' + event));
});
},
componentWillUnmount: function () {
this.$picker.data('daterangepicker').remove();
},
render: function () {
this.setOptionsFromProps();
return React.createElement(
'div',
React.__spread({ref: 'picker'}, this.props),
this.props.children
);
if (typeof this.props[eventType] === 'function') {
this.props[eventType](event, picker);
}
}.bind(this);
},
getOptionsFromProps: function () {
var options, props = this.props;
this.options.forEach(function (option) {
if (props.hasOwnProperty(option)) {
options = options || {};
options[option] = props[option];
}
});
return options || {};
},
setOptionsFromProps: function () {
var currentOptions = this.getOptionsFromProps();
var keys = Object.keys(currentOptions);
var $this = this;
if ($this.$picker) {
if (currentOptions) {
keys.forEach(function (key) {
$this.$picker.data('daterangepicker')[key] = currentOptions[key];
});
}
}
});
}(window || {}));
},
componentDidMount: function () {
var $this = this;
$this.$picker = $(this.refs.picker);
// initialize
$this.$picker.daterangepicker(this.getOptionsFromProps());
// attach event listeners
['Show', 'Hide', 'ShowCalendar', 'HideCalendar', 'Apply', 'Cancel'].forEach(function (event) {
var lcase = event.toLowerCase();
$this.$picker.on(lcase + '.daterangepicker', $this.makeEventHandler('on' + event));
});
},
componentWillUnmount: function () {
this.$picker.data('daterangepicker').remove();
},
render: function () {
this.setOptionsFromProps();
return React.createElement(
'div',
React.__spread({ref: 'picker'}, this.props),
this.props.children
);
}
});
{
"name": "react-bootstrap-daterangepicker",
"version": "1.0.3",
"version": "1.0.4",
"description": "A date/time picker for react (using bootstrap). This is a react port of: https://github.com/dangrossman/bootstrap-daterangepicker",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc