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

react-period-of-stay-input

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-period-of-stay-input - npm Package Compare versions

Comparing version 5.0.2 to 5.0.3

.editorconfig

10

browser.js
(function () {
'use strict';
'use strict'
exports.Klass = require('./src/PeriodOfStayInput');
exports.Model = require('./src/Model');
exports.Environment = require('./src/Environment');
}());
exports.Klass = require('./src/PeriodOfStayInput')
exports.Model = require('./src/Model')
exports.Environment = require('./src/Environment')
}())
(function () {
'use strict';
'use strict'
exports.Klass = require('./src/PeriodOfStayInput');
exports.Model = require('./src/Model');
exports.Environment = require('./src/Environment');
exports.intlMessages = require('./src/intlMessages');
}());
exports.Klass = require('./src/PeriodOfStayInput')
exports.Model = require('./src/Model')
exports.Environment = require('./src/Environment')
exports.intlMessages = require('./src/intlMessages')
}())
{
"name": "react-period-of-stay-input",
"version": "5.0.2",
"version": "5.0.3",
"description": "React.js component for entering a period of stay in a hotel: check-in + check-out date",

@@ -8,7 +8,8 @@ "main": "index.js",

"scripts": {
"build": "browserify demo.js | uglifyjs -mc > www/bundle.js",
"dev-build": "browserify demo.js -o www/bundle.js",
"lint": "eslint tests src index.js browser.js demo.js",
"test": "mocha --require tests/helpers/jsdom-bootstrap -b tests/*.spec.js",
"tdd": "mocha --require tests/helpers/jsdom-bootstrap -b -R min -w tests/*.spec.js",
"build": "browserify demo.js | uglifyjs -m > www/bundle.js",
"dev-build": "browserify demo.js -o www/bundle.js",
"pretest": "npm run lint",
"tdd": "mocha -r tests/helpers/jsdom -b -R min -w tests/*.spec.js",
"test": "mocha -r tests/helpers/jsdom -b tests/*.spec.js",
"watch": "watchify demo.js -vo www/bundle.js"

@@ -50,12 +51,18 @@ },

"devDependencies": {
"browserify": "^13.1.1",
"eslint": "^3.12.2",
"eslint-plugin-react": "^6.8.0",
"jsdom": "^9.9.1",
"mocha": "^3.2.0",
"browserify": "^16.1.1",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.10.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-react": "^7.7.0",
"eslint-plugin-standard": "^3.0.1",
"jsdom": "^11.7.0",
"mocha": "^5.0.5",
"raf": "^3.4.0",
"react": "^0.13.3",
"sinon": "^1.14.1",
"uglify-js": "^2.4.20",
"sinon": "^4.5.0",
"uglify-es": "^3.3.9",
"watchify": "^3.8.0"
}
}
/* global window */
(function () {
'use strict';
const React = require('react')
const moment = require('moment')
var React = require('react'),
moment = require('moment'),
function isValidDate (str) {
return (
/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.test(str) &&
moment(str, 'YYYY-MM-DD').isValid()
)
}
isValidDate = function (str) {
return (
/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.test(str) &&
moment(str, 'YYYY-MM-DD').isValid()
);
},
function isPolyfilled () {
return !!window.Modernizr && !window.Modernizr.inputtypes.date
}
isPolyfilled = function () {
return !!window.Modernizr && !window.Modernizr.inputtypes.date;
};
module.exports = React.createClass({
displayName: 'DateInput',
module.exports = React.createClass({
displayName: 'DateInput',
propTypes: {
value: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func.isRequired
},
propTypes: {
value: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func.isRequired
},
render () {
return React.DOM.input({
type: 'date',
value: this.valueToRender(),
onChange: this.handleEdit,
className: this.classToRender()
})
},
render: function () {
return React.DOM.input({
type: 'date',
value: this.valueToRender(),
onChange: this.handleEdit,
className: this.classToRender()
});
},
componentDidMount: function () {
setTimeout(function () {
if (isPolyfilled()) {
window.$(this.getDOMNode()).datepicker({
dateFormat: 'yy-mm-dd',
firstDay: 1
}).on('change', this.handleEdit).on('blur', function () {
this.setState({draftValue: null});
}.bind(this));
}
}.bind(this), 500);
},
componentWillUnmount: function () {
componentDidMount () {
setTimeout(function () {
if (isPolyfilled()) {
window.$(this.getDOMNode()).off();
window.$(this.getDOMNode()).datepicker({
dateFormat: 'yy-mm-dd',
firstDay: 1
}).on('change', this.handleEdit).on('blur', function () {
this.setState({draftValue: null})
}.bind(this))
}
},
}.bind(this), 500)
},
valueToRender: function () {
return (this.isDrafting() ? this.state.draftValue : this.props.value);
},
componentWillUnmount () {
if (isPolyfilled()) {
window.$(this.getDOMNode()).off()
}
},
classToRender: function () {
return (this.isDrafting() ? 'form-control error' : 'form-control');
},
valueToRender () {
return (this.isDrafting() ? this.state.draftValue : this.props.value)
},
isDrafting: function () {
return (this.state && this.state.draftValue !== null);
},
classToRender () {
return (this.isDrafting() ? 'form-control error' : 'form-control')
},
handleEdit: function (event) {
var v = event.target.value;
isDrafting () {
return (this.state && this.state.draftValue !== null)
},
if (isValidDate(v)) {
this.setState({draftValue: null});
this.props.onChange(v);
}
else {
this.setState({draftValue: v});
}
handleEdit (event) {
var v = event.target.value
if (isValidDate(v)) {
this.setState({draftValue: null})
this.props.onChange(v)
} else {
this.setState({draftValue: v})
}
});
}());
}
})
(function () {
'use strict';
'use strict'
module.exports = function (zeroNightsAllowed, today) {
this.zeroNightsAllowed = zeroNightsAllowed;
this.today = today;
};
}());
this.zeroNightsAllowed = zeroNightsAllowed
this.today = today
}
}())
(function () {
'use strict';
'use strict'

@@ -21,4 +21,4 @@ module.exports = function () {

}
};
};
}());
}
}
}())

@@ -1,73 +0,69 @@

(function () {
'use strict';
const moment = require('moment')
var moment = require('moment'),
function Model (checkInDate, checkOutDate) {
this.checkInDate = checkInDate
this.checkOutDate = checkOutDate
}
Model = function (checkInDate, checkOutDate) {
this.checkInDate = checkInDate;
this.checkOutDate = checkOutDate;
},
function maxNightsCount () {
return 27
}
maxNightsCount = function () {
return 27;
},
function fmt () {
return 'YYYY-MM-DD'
}
fmt = function () {
return 'YYYY-MM-DD';
},
function itsOk (mCheckIn, mCheckOut, environment) {
return (
mCheckOut.isBefore(mCheckIn) ||
(!environment.zeroNightsAllowed && mCheckIn.isSame(mCheckOut, 'day')) ||
(mCheckOut.diff(mCheckIn, 'days') > maxNightsCount())
)
}
itsOk = function (mCheckIn, mCheckOut, environment) {
return (
mCheckOut.isBefore(mCheckIn) ||
(!environment.zeroNightsAllowed && mCheckIn.isSame(mCheckOut, 'day')) ||
(mCheckOut.diff(mCheckIn, 'days') > maxNightsCount())
);
};
Model.prototype.newCheckIn = function (checkInDate, environment) {
const mCheckOut = moment(this.checkOutDate, fmt())
const mCheckIn = moment(checkInDate, fmt())
Model.prototype.newCheckIn = function (checkInDate, environment) {
var mCheckOut = moment(this.checkOutDate, fmt()),
mCheckIn = moment(checkInDate, fmt());
if (mCheckIn.isBefore(moment(environment.today, fmt()))) {
return this
}
if (mCheckIn.isBefore(moment(environment.today, fmt()))) {
return this;
}
if (itsOk(mCheckIn, mCheckOut, environment)) {
return new Model(checkInDate, mCheckIn.add(1, 'days').format(fmt()))
}
if (itsOk(mCheckIn, mCheckOut, environment)) {
return new Model(checkInDate, mCheckIn.add(1, 'days').format(fmt()));
}
return new Model(checkInDate, this.checkOutDate)
}
return new Model(checkInDate, this.checkOutDate);
};
Model.prototype.newCheckOut = function (checkOutDate, environment) {
const mCheckIn = moment(this.checkInDate, fmt())
const mCheckOut = moment(checkOutDate, fmt())
const mToday = moment(environment.today, fmt())
Model.prototype.newCheckOut = function (checkOutDate, environment) {
var mCheckIn = moment(this.checkInDate, fmt()),
mCheckOut = moment(checkOutDate, fmt()),
mToday = moment(environment.today, fmt());
if (
mCheckOut.isBefore(mToday) ||
(!environment.zeroNightsAllowed && mCheckOut.isSame(mToday, 'day'))
) {
return this
}
if (
mCheckOut.isBefore(mToday) ||
(!environment.zeroNightsAllowed && mCheckOut.isSame(mToday, 'day'))
) {
return this;
}
if (environment.zeroNightsAllowed && mCheckOut.isSame(mToday, 'day')) {
return new Model(checkOutDate, checkOutDate)
}
if (environment.zeroNightsAllowed && mCheckOut.isSame(mToday, 'day')) {
return new Model(checkOutDate, checkOutDate);
}
if (itsOk(mCheckIn, mCheckOut, environment)) {
return new Model(mCheckOut.subtract(1, 'days').format(fmt()), checkOutDate)
}
if (itsOk(mCheckIn, mCheckOut, environment)) {
return new Model(mCheckOut.subtract(1, 'days').format(fmt()), checkOutDate);
}
return new Model(this.checkInDate, checkOutDate)
}
return new Model(this.checkInDate, checkOutDate);
};
Model.prototype.nightsCount = function () {
return moment(this.checkOutDate, fmt()).diff(
moment(this.checkInDate, fmt()),
'days'
)
}
Model.prototype.nightsCount = function () {
return moment(this.checkOutDate, fmt()).diff(
moment(this.checkInDate, fmt()),
'days'
);
};
module.exports = Model;
}());
module.exports = Model

@@ -1,87 +0,83 @@

(function () {
'use strict';
const React = require('react')
const DateInput = require('./DateInput')
const Environment = require('./Environment')
const Model = require('./Model')
const ReactIntl = require('react-intl')
const FormattedMessage = ReactIntl.FormattedMessage
const IntlMixin = ReactIntl.IntlMixin
var React = require('react'),
DateInput = require('./DateInput'),
Environment = require('./Environment'),
Model = require('./Model'),
ReactIntl = require('react-intl'),
FormattedMessage = ReactIntl.FormattedMessage,
IntlMixin = ReactIntl.IntlMixin;
module.exports = React.createClass({
displayName: 'PeriodOfStayInput',
mixins: [IntlMixin],
module.exports = React.createClass({
displayName: 'PeriodOfStayInput',
mixins: [IntlMixin],
propTypes: {
environment: React.PropTypes.instanceOf(Environment),
model: React.PropTypes.instanceOf(Model),
onChange: React.PropTypes.func,
className: React.PropTypes.string
},
propTypes: {
environment: React.PropTypes.instanceOf(Environment),
model: React.PropTypes.instanceOf(Model),
onChange: React.PropTypes.func,
className: React.PropTypes.string
},
render: function () {
return React.DOM.div(
{className: this.props.className + ' period-of-stay-input'},
this.valueInputs()
)
},
render: function () {
return React.DOM.div(
{className: this.props.className + ' period-of-stay-input'},
this.valueInputs()
);
},
valueInputs: function () {
var m = this.props.model
valueInputs: function () {
var m = this.props.model;
return [
React.DOM.div(
{className: 'period-of-stay-check-in', key: 'k0'},
return [
React.DOM.div(
{className: 'period-of-stay-check-in', key: 'k0'},
React.DOM.label({}, React.createElement(
FormattedMessage,
{message: this.getIntlMessage('react-period-of-stay-input.checkInDay')}
)),
React.DOM.label({}, React.createElement(
FormattedMessage,
{message: this.getIntlMessage('react-period-of-stay-input.checkInDay')}
)),
React.createElement(DateInput, {
ref: 'checkIn',
value: m.checkInDate,
onChange: this.handleCheckInChange
}),
React.createElement(DateInput, {
ref: 'checkIn',
value: m.checkInDate,
onChange: this.handleCheckInChange
}),
React.DOM.i({className: 'fa fa-calendar calendar-icon'}, '')
React.DOM.i({className:'fa fa-calendar calendar-icon'}, '')
),
),
React.DOM.div(
{className: 'period-of-stay-check-out', key: 'k1'},
React.DOM.div(
{className: 'period-of-stay-check-out', key: 'k1'},
React.DOM.label({}, React.createElement(
FormattedMessage,
{message: this.getIntlMessage('react-period-of-stay-input.checkOutDay')}
)),
React.DOM.label({}, React.createElement(
FormattedMessage,
{message: this.getIntlMessage('react-period-of-stay-input.checkOutDay')}
)),
React.createElement(DateInput, {
ref: 'checkOut',
value: m.checkOutDate,
onChange: this.handleCheckOutChange
}),
React.createElement(DateInput, {
ref: 'checkOut',
value: m.checkOutDate,
onChange: this.handleCheckOutChange
}),
React.DOM.i({className: 'fa fa-calendar calendar-icon'}, '')
),
React.DOM.i({className:'fa fa-calendar calendar-icon'}, '')
),
React.DOM.span(
{className: 'period-of-stay-nights', key: 'k2'},
React.createElement(
FormattedMessage,
{message: this.getIntlMessage('react-period-of-stay-input.period'), count: m.nightsCount()}
)
React.DOM.span(
{className: 'period-of-stay-nights', key: 'k2'},
React.createElement(
FormattedMessage,
{message: this.getIntlMessage('react-period-of-stay-input.period'), count: m.nightsCount()}
)
];
},
)
]
},
handleCheckInChange: function (value) {
this.props.onChange(this.props.model.newCheckIn(value, this.props.environment));
},
handleCheckInChange: function (value) {
this.props.onChange(this.props.model.newCheckIn(value, this.props.environment))
},
handleCheckOutChange: function (value) {
this.props.onChange(this.props.model.newCheckOut(value, this.props.environment));
}
});
}());
handleCheckOutChange: function (value) {
this.props.onChange(this.props.model.newCheckOut(value, this.props.environment))
}
})

Sorry, the diff of this file is not supported yet

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