diff --git a/dist/DateRangePicker.js b/dist/DateRangePicker.js index 46f85a65..6d7cc17e 100644 --- a/dist/DateRangePicker.js +++ b/dist/DateRangePicker.js @@ -1,71 +1,92 @@ -"use strict"; -var _interopRequire = function (obj) { - return obj && (obj["default"] || obj); -}; +'use strict'; -var React = _interopRequire(require("react/addons")); +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _interopRequireDefault = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; + +var _React = require('react/addons'); + +var _React2 = _interopRequireDefault(_React); + +var _moment = require('moment'); + +var _moment2 = _interopRequireDefault(_moment); + +var _Immutable = require('immutable'); + +var _Immutable2 = _interopRequireDefault(_Immutable); + +var _BemMixin = require('./utils/BemMixin'); -var moment = _interopRequire(require("moment")); +var _BemMixin2 = _interopRequireDefault(_BemMixin); -var Immutable = _interopRequire(require("immutable")); +var _Legend = require('./Legend'); -var BemMixin = _interopRequire(require("./utils/BemMixin")); +var _Legend2 = _interopRequireDefault(_Legend); -var Legend = _interopRequire(require("./Legend")); +var _CalendarMonth = require('./calendar/CalendarMonth'); -var CalendarMonth = _interopRequire(require("./calendar/CalendarMonth")); +var _CalendarMonth2 = _interopRequireDefault(_CalendarMonth); -var CalendarDate = _interopRequire(require("./calendar/CalendarDate")); +var _CalendarDate = require('./calendar/CalendarDate'); -var PaginationArrow = _interopRequire(require("./PaginationArrow")); +var _CalendarDate2 = _interopRequireDefault(_CalendarDate); -var PureRenderMixin = React.addons.PureRenderMixin; +var _PaginationArrow = require('./PaginationArrow'); -var absoluteMinimum = moment(new Date(-8640000000000000 / 2)).startOf("day"); -var absoluteMaximum = moment(new Date(8640000000000000 / 2)).startOf("day"); +var _PaginationArrow2 = _interopRequireDefault(_PaginationArrow); -React.initializeTouchEvents(true); +'use strict'; + +var PureRenderMixin = _React2['default'].addons.PureRenderMixin; + +var absoluteMinimum = _moment2['default'](new Date(-8640000000000000 / 2)).startOf('day'); +var absoluteMaximum = _moment2['default'](new Date(8640000000000000 / 2)).startOf('day'); + +_React2['default'].initializeTouchEvents(true); function noop() {} +var DateRangePicker = _React2['default'].createClass({ + displayName: 'DateRangePicker', -var DateRangePicker = React.createClass({ - displayName: "DateRangePicker", - mixins: [BemMixin, PureRenderMixin], + mixins: [_BemMixin2['default'], PureRenderMixin], propTypes: { - bemNamespace: React.PropTypes.string, - bemBlock: React.PropTypes.string, - numberOfCalendars: React.PropTypes.number, - firstOfWeek: React.PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6]), - disableNavigation: React.PropTypes.bool, - initialDate: React.PropTypes.instanceOf(Date), - initialRange: React.PropTypes.object, - initialMonth: React.PropTypes.number, // Overrides values derived from initialDate/initialRange - initialYear: React.PropTypes.number, // Overrides values derived from initialDate/initialRange - minimumDate: React.PropTypes.instanceOf(Date), - maximumDate: React.PropTypes.instanceOf(Date), - selectionType: React.PropTypes.oneOf(["single", "range"]), - stateDefinitions: React.PropTypes.object, - selectedLabel: React.PropTypes.string, - dateStates: React.PropTypes.array, // an array of date ranges and their states - defaultState: React.PropTypes.string, - initialFromValue: React.PropTypes.bool, - showLegend: React.PropTypes.bool, - onSelect: React.PropTypes.func, - onSelectStart: React.PropTypes.func, - paginationArrowComponent: React.PropTypes.func, - value: function (props, propName, componentName) { + bemNamespace: _React2['default'].PropTypes.string, + bemBlock: _React2['default'].PropTypes.string, + numberOfCalendars: _React2['default'].PropTypes.number, + firstOfWeek: _React2['default'].PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6]), + disableNavigation: _React2['default'].PropTypes.bool, + initialDate: _React2['default'].PropTypes.instanceOf(Date), + initialRange: _React2['default'].PropTypes.object, + initialMonth: _React2['default'].PropTypes.number, // Overrides values derived from initialDate/initialRange + initialYear: _React2['default'].PropTypes.number, // Overrides values derived from initialDate/initialRange + minimumDate: _React2['default'].PropTypes.instanceOf(Date), + maximumDate: _React2['default'].PropTypes.instanceOf(Date), + selectionType: _React2['default'].PropTypes.oneOf(['single', 'range']), + stateDefinitions: _React2['default'].PropTypes.object, + selectedLabel: _React2['default'].PropTypes.string, + dateStates: _React2['default'].PropTypes.array, // an array of date ranges and their states + defaultState: _React2['default'].PropTypes.string, + initialFromValue: _React2['default'].PropTypes.bool, + showLegend: _React2['default'].PropTypes.bool, + onSelect: _React2['default'].PropTypes.func, + onSelectStart: _React2['default'].PropTypes.func, + paginationArrowComponent: _React2['default'].PropTypes.func, + value: function value(props, propName, componentName) { var val = props[propName]; if (!val) { return; - } else if (moment.isMoment(val)) { + } else if (_moment2['default'].isMoment(val)) { return; - } else if (val.start && val.end && moment.isMoment(val.start) && moment.isMoment(val.end)) { + } else if (val.start && val.end && _moment2['default'].isMoment(val.start) && _moment2['default'].isMoment(val.end)) { return; } - return new Error("Value must be a moment or a moment range"); + return new Error('Value must be a moment or a moment range'); } }, @@ -75,15 +96,15 @@ var DateRangePicker = React.createClass({ return { bemNamespace: null, - bemBlock: "DateRangePicker", + bemBlock: 'DateRangePicker', numberOfCalendars: 1, firstOfWeek: 0, disableNavigation: false, - nextLabel: "", - previousLabel: "", + nextLabel: '', + previousLabel: '', initialDate: initialDate, initialFromValue: true, - selectionType: "range", + selectionType: 'range', stateDefinitions: { __default: { color: null, @@ -91,12 +112,12 @@ var DateRangePicker = React.createClass({ label: null } }, - selectedLabel: "Your selected dates", - defaultState: "__default", + selectedLabel: 'Your selected dates', + defaultState: '__default', dateStates: [], showLegend: false, onSelect: noop, - paginationArrowComponent: PaginationArrow + paginationArrowComponent: _PaginationArrow2['default'] }; }, @@ -108,11 +129,13 @@ var DateRangePicker = React.createClass({ }, getInitialState: function getInitialState() { - var initialYear = this.props.initialYear; - var initialMonth = this.props.initialMonth; - var initialFromValue = this.props.initialFromValue; - var selectionType = this.props.selectionType; - var value = this.props.value; + var _props = this.props; + var initialYear = _props.initialYear; + var initialMonth = _props.initialMonth; + var initialFromValue = _props.initialFromValue; + var selectionType = _props.selectionType; + var value = _props.value; + var now = new Date(); var year = now.getFullYear(); var month = now.getMonth(); @@ -123,7 +146,7 @@ var DateRangePicker = React.createClass({ } if (initialFromValue && value) { - if (selectionType === "single") { + if (selectionType === 'single') { year = value.year(); month = value.month(); } else { @@ -145,32 +168,33 @@ var DateRangePicker = React.createClass({ }, getEnabledRange: function getEnabledRange(props) { - var min = props.minimumDate ? moment(props.minimumDate).startOf("day") : absoluteMinimum; - var max = props.maximumDate ? moment(props.maximumDate).startOf("day") : absoluteMaximum; + var min = props.minimumDate ? _moment2['default'](props.minimumDate).startOf('day') : absoluteMinimum; + var max = props.maximumDate ? _moment2['default'](props.maximumDate).startOf('day') : absoluteMaximum; - return moment().range(min, max); + return _moment2['default']().range(min, max); }, getDateStates: function getDateStates(props) { var dateStates = props.dateStates; var defaultState = props.defaultState; var stateDefinitions = props.stateDefinitions; + var actualStates = []; var minDate = absoluteMinimum; var maxDate = absoluteMaximum; - var dateCursor = moment(minDate).startOf("day"); + var dateCursor = _moment2['default'](minDate).startOf('day'); - var defs = Immutable.fromJS(stateDefinitions); + var defs = _Immutable2['default'].fromJS(stateDefinitions); dateStates.forEach((function (s) { var r = s.range; - var start = r.start.startOf("day"); - var end = r.end.startOf("day"); + var start = r.start.startOf('day'); + var end = r.end.startOf('day'); if (!dateCursor.isSame(start)) { actualStates.push({ state: defaultState, - range: moment().range(dateCursor, start) + range: _moment2['default']().range(dateCursor, start) }); } actualStates.push(s); @@ -179,46 +203,46 @@ var DateRangePicker = React.createClass({ actualStates.push({ state: defaultState, - range: moment().range(dateCursor, maxDate) + range: _moment2['default']().range(dateCursor, maxDate) }); // sanitize date states - return Immutable.List(actualStates).map((function (s) { + return _Immutable2['default'].List(actualStates).map((function (s) { var def = defs.get(s.state); - return Immutable.Map({ + return _Immutable2['default'].Map({ range: s.range, state: s.state, - selectable: def.get("selectable", true), - color: def.get("color") + selectable: def.get('selectable', true), + color: def.get('color') }); }).bind(this)); }, onSelect: function onSelect(date) { - this.props.onSelect(moment(date)); + this.props.onSelect(_moment2['default'](date)); }, startRangeSelection: function startRangeSelection(date) { this.setState({ selectedStartDate: date }); - if (typeof this.props.onSelectStart === "function") { - this.props.onSelectStart(moment(date)); + if (typeof this.props.onSelectStart === 'function') { + this.props.onSelectStart(_moment2['default'](date)); } }, statesForRange: function statesForRange(range) { if (range.start.isSame(range.end)) { return this.state.dateStates.filter(function (d) { - return range.start.within(d.get("range")); + return range.start.within(d.get('range')); }).map(function (d) { - return d.get("state"); + return d.get('state'); }); } return this.state.dateStates.filter(function (d) { - return d.get("range").intersect(range); + return d.get('range').intersect(range); }).map(function (d) { - return d.get("state"); + return d.get('state'); }); }, @@ -263,11 +287,11 @@ var DateRangePicker = React.createClass({ }, getMonthDate: function getMonthDate() { - return moment(new Date(this.state.year, this.state.month, 1)); + return _moment2['default'](new Date(this.state.year, this.state.month, 1)); }, canMoveBack: function canMoveBack() { - if (this.getMonthDate().subtract(1, "days").isBefore(this.state.enabledRange.start)) { + if (this.getMonthDate().subtract(1, 'days').isBefore(this.state.enabledRange.start)) { return false; } return true; @@ -278,7 +302,7 @@ var DateRangePicker = React.createClass({ if (this.canMoveBack()) { monthDate = this.getMonthDate(); - monthDate.subtract(1, "months"); + monthDate.subtract(1, 'months'); this.setState({ year: monthDate.year(), month: monthDate.month() @@ -293,7 +317,7 @@ var DateRangePicker = React.createClass({ }, canMoveForward: function canMoveForward() { - if (this.getMonthDate().add(this.props.numberOfCalendars, "months").isAfter(this.state.enabledRange.end)) { + if (this.getMonthDate().add(this.props.numberOfCalendars, 'months').isAfter(this.state.enabledRange.end)) { return false; } return true; @@ -304,7 +328,7 @@ var DateRangePicker = React.createClass({ if (this.canMoveForward()) { monthDate = this.getMonthDate(); - monthDate.add(1, "months"); + monthDate.add(1, 'months'); this.setState({ year: monthDate.year(), month: monthDate.month() @@ -319,15 +343,15 @@ var DateRangePicker = React.createClass({ }, changeYear: function changeYear(year) { - var enabledRange = this.state.enabledRange; - var month = this.state.month; + var _state = this.state; + var enabledRange = _state.enabledRange; + var month = _state.month; - - if (moment({ years: year, months: month, date: 1 }).unix() < enabledRange.start.unix()) { + if (_moment2['default']({ years: year, months: month, date: 1 }).unix() < enabledRange.start.unix()) { month = enabledRange.start.month(); } - if (moment({ years: year, months: month + 1, date: 1 }).unix() > enabledRange.end.unix()) { + if (_moment2['default']({ years: year, months: month + 1, date: 1 }).unix() > enabledRange.end.unix()) { month = enabledRange.end.month(); } @@ -344,27 +368,28 @@ var DateRangePicker = React.createClass({ }, renderCalendar: function renderCalendar(index) { - var bemBlock = this.props.bemBlock; - var bemNamespace = this.props.bemNamespace; - var firstOfWeek = this.props.firstOfWeek; - var numberOfCalendars = this.props.numberOfCalendars; - var selectionType = this.props.selectionType; - var value = this.props.value; - var dateStates = this.state.dateStates; - var enabledRange = this.state.enabledRange; - var highlightedDate = this.state.highlightedDate; - var highlightedRange = this.state.highlightedRange; - var highlightStartDate = this.state.highlightStartDate; - var selectedStartDate = this.state.selectedStartDate; - + var _props2 = this.props; + var bemBlock = _props2.bemBlock; + var bemNamespace = _props2.bemNamespace; + var firstOfWeek = _props2.firstOfWeek; + var numberOfCalendars = _props2.numberOfCalendars; + var selectionType = _props2.selectionType; + var value = _props2.value; + var _state2 = this.state; + var dateStates = _state2.dateStates; + var enabledRange = _state2.enabledRange; + var highlightedDate = _state2.highlightedDate; + var highlightedRange = _state2.highlightedRange; + var highlightStartDate = _state2.highlightStartDate; + var selectedStartDate = _state2.selectedStartDate; var monthDate = this.getMonthDate(); var year = monthDate.year(); var month = monthDate.month(); - var key = "" + index + "-" + year + "-" + month; + var key = '' + index + '-' + year + '-' + month; var props; - monthDate.add(index, "months"); + monthDate.add(index, 'months'); props = { bemBlock: bemBlock, @@ -391,31 +416,32 @@ var DateRangePicker = React.createClass({ startRangeSelection: this.startRangeSelection, completeSelection: this.completeSelection, completeRangeSelection: this.completeRangeSelection, - dateComponent: CalendarDate + dateComponent: _CalendarDate2['default'] }; - return React.createElement(CalendarMonth, props); + return _React2['default'].createElement(_CalendarMonth2['default'], props); }, - render: function () { - var PaginationArrow = this.props.paginationArrowComponent; - var numberOfCalendars = this.props.numberOfCalendars; - var stateDefinitions = this.props.stateDefinitions; - var selectedLabel = this.props.selectedLabel; - var showLegend = this.props.showLegend; - + render: function render() { + var _props3 = this.props; + var PaginationArrow = _props3.paginationArrowComponent; + var numberOfCalendars = _props3.numberOfCalendars; + var stateDefinitions = _props3.stateDefinitions; + var selectedLabel = _props3.selectedLabel; + var showLegend = _props3.showLegend; - var calendars = Immutable.Range(0, numberOfCalendars).map(this.renderCalendar); + var calendars = _Immutable2['default'].Range(0, numberOfCalendars).map(this.renderCalendar); - return React.createElement( - "div", + return _React2['default'].createElement( + 'div', { className: this.cx({ element: null }) }, - React.createElement(PaginationArrow, { direction: "previous", onMouseEnter: this.moveBackIfSelecting, onClick: this.moveBack, disabled: !this.canMoveBack() }), + _React2['default'].createElement(PaginationArrow, { direction: 'previous', onMouseEnter: this.moveBackIfSelecting, onClick: this.moveBack, disabled: !this.canMoveBack() }), calendars.toJS(), - React.createElement(PaginationArrow, { direction: "next", onMouseEnter: this.moveForwardIfSelecting, onClick: this.moveForward, disabled: !this.canMoveForward() }), - showLegend ? React.createElement(Legend, { stateDefinitions: stateDefinitions, selectedLabel: selectedLabel }) : null + _React2['default'].createElement(PaginationArrow, { direction: 'next', onMouseEnter: this.moveForwardIfSelecting, onClick: this.moveForward, disabled: !this.canMoveForward() }), + showLegend ? _React2['default'].createElement(_Legend2['default'], { stateDefinitions: stateDefinitions, selectedLabel: selectedLabel }) : null ); } }); -module.exports = DateRangePicker; \ No newline at end of file +exports['default'] = DateRangePicker; +module.exports = exports['default']; \ No newline at end of file diff --git a/dist/Legend.js b/dist/Legend.js index df982dc9..625953d1 100644 --- a/dist/Legend.js +++ b/dist/Legend.js @@ -1,25 +1,38 @@ -"use strict"; -var _interopRequire = function (obj) { - return obj && (obj["default"] || obj); -}; +'use strict'; -var React = _interopRequire(require("react/addons")); +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _interopRequireDefault = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; + +var _React = require('react/addons'); + +var _React2 = _interopRequireDefault(_React); -var bemCx = _interopRequire(require("./utils/bemCx")); +var _bemCx = require('./utils/bemCx'); -var BemMixin = _interopRequire(require("./utils/BemMixin")); +var _bemCx2 = _interopRequireDefault(_bemCx); -var PureRenderMixin = React.addons.PureRenderMixin; -var cx = React.addons.classSet; +var _BemMixin = require('./utils/BemMixin'); +var _BemMixin2 = _interopRequireDefault(_BemMixin); -var Legend = React.createClass({ - displayName: "Legend", - mixins: [BemMixin, PureRenderMixin], +'use strict'; + +var PureRenderMixin = _React2['default'].addons.PureRenderMixin; +var cx = _React2['default'].addons.classSet; + +var Legend = _React2['default'].createClass({ + displayName: 'Legend', + + mixins: [_BemMixin2['default'], PureRenderMixin], render: function render() { - var selectedLabel = this.props.selectedLabel; - var stateDefinitions = this.props.stateDefinitions; + var _props = this.props; + var selectedLabel = _props.selectedLabel; + var stateDefinitions = _props.stateDefinitions; + var block = this.getBemBlock(); var namespace = this.getBemNamespace(); var items = []; @@ -33,29 +46,29 @@ var Legend = React.createClass({ style = { backgroundColor: def.color }; - items.push(React.createElement( - "li", - { className: this.cx({ element: "LegendItem" }), key: name }, - React.createElement("span", { className: this.cx({ element: "LegendItemColor" }), style: style }), - React.createElement( - "span", - { className: this.cx({ element: "LegendItemLabel" }) }, + items.push(_React2['default'].createElement( + 'li', + { className: this.cx({ element: 'LegendItem' }), key: name }, + _React2['default'].createElement('span', { className: this.cx({ element: 'LegendItemColor' }), style: style }), + _React2['default'].createElement( + 'span', + { className: this.cx({ element: 'LegendItemLabel' }) }, def.label ) )); } } - return React.createElement( - "ul", + return _React2['default'].createElement( + 'ul', { className: this.cx() }, - React.createElement( - "li", - { className: this.cx({ element: "LegendItem" }) }, - React.createElement("span", { className: this.cx({ element: "LegendItemColor", modifiers: { selection: true } }) }), - React.createElement( - "span", - { className: this.cx({ element: "LegendItemLabel" }) }, + _React2['default'].createElement( + 'li', + { className: this.cx({ element: 'LegendItem' }) }, + _React2['default'].createElement('span', { className: this.cx({ element: 'LegendItemColor', modifiers: { selection: true } }) }), + _React2['default'].createElement( + 'span', + { className: this.cx({ element: 'LegendItemLabel' }) }, selectedLabel ) ), @@ -64,4 +77,5 @@ var Legend = React.createClass({ } }); -module.exports = Legend; \ No newline at end of file +exports['default'] = Legend; +module.exports = exports['default']; \ No newline at end of file diff --git a/dist/PaginationArrow.js b/dist/PaginationArrow.js index b7fee532..173bc321 100644 --- a/dist/PaginationArrow.js +++ b/dist/PaginationArrow.js @@ -1,44 +1,40 @@ -"use strict"; -var _objectWithoutProperties = function (obj, keys) { - var target = {}; - - for (var i in obj) { - if (keys.indexOf(i) >= 0) continue; - if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; - target[i] = obj[i]; - } +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _interopRequireDefault = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; - return target; -}; +var _objectWithoutProperties = function (obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }; -var _defineProperty = function (obj, key, value) { - return Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); -}; +var _defineProperty = function (obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); }; -var _interopRequire = function (obj) { - return obj && (obj["default"] || obj); -}; +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -var React = _interopRequire(require("react/addons")); +var _React = require('react/addons'); -var BemMixin = _interopRequire(require("./utils/BemMixin")); +var _React2 = _interopRequireDefault(_React); -var PureRenderMixin = React.addons.PureRenderMixin; +var _BemMixin = require('./utils/BemMixin'); +var _BemMixin2 = _interopRequireDefault(_BemMixin); -var PaginationArrow = React.createClass({ - displayName: "PaginationArrow", - mixins: [BemMixin, PureRenderMixin], +'use strict'; + +var PureRenderMixin = _React2['default'].addons.PureRenderMixin; + +var PaginationArrow = _React2['default'].createClass({ + displayName: 'PaginationArrow', + + mixins: [_BemMixin2['default'], PureRenderMixin], render: function render() { - var disabled = this.props.disabled; - var direction = this.props.direction; - var props = _objectWithoutProperties(this.props, ["disabled", "direction"]); + var _props = this.props; + var disabled = _props.disabled; + var direction = _props.direction; + + var props = _objectWithoutProperties(_props, ['disabled', 'direction']); var modifiers = _defineProperty({}, direction, true); var states = { disabled: disabled }; @@ -49,17 +45,18 @@ var PaginationArrow = React.createClass({ }; var iconOpts = { - element: "PaginationArrowIcon", + element: 'PaginationArrowIcon', modifiers: modifiers, states: states }; - return React.createElement( - "div", - React.__spread({ className: this.cx(elementOpts) }, props), - React.createElement("div", { className: this.cx(iconOpts) }) + return _React2['default'].createElement( + 'div', + _extends({ className: this.cx(elementOpts) }, props), + _React2['default'].createElement('div', { className: this.cx(iconOpts) }) ); } }); -module.exports = PaginationArrow; \ No newline at end of file +exports['default'] = PaginationArrow; +module.exports = exports['default']; \ No newline at end of file diff --git a/dist/calendar/CalendarDate.js b/dist/calendar/CalendarDate.js index c3a6d261..e51e638e 100644 --- a/dist/calendar/CalendarDate.js +++ b/dist/calendar/CalendarDate.js @@ -1,54 +1,71 @@ -"use strict"; +'use strict'; -var _interopRequire = function (obj) { - return obj && (obj["default"] || obj); -}; +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _interopRequireDefault = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; + +var _React = require('react/addons'); + +var _React2 = _interopRequireDefault(_React); + +var _moment = require('moment-range'); + +var _moment2 = _interopRequireDefault(_moment); + +var _Immutable = require('immutable'); -var React = _interopRequire(require("react/addons")); +var _Immutable2 = _interopRequireDefault(_Immutable); -var moment = _interopRequire(require("moment-range")); +var _BemMixin = require('../utils/BemMixin'); -var Immutable = _interopRequire(require("immutable")); +var _BemMixin2 = _interopRequireDefault(_BemMixin); -var BemMixin = _interopRequire(require("../utils/BemMixin")); +var _lightenDarkenColor = require('../utils/lightenDarkenColor'); -var lightenDarkenColor = _interopRequire(require("../utils/lightenDarkenColor")); +var _lightenDarkenColor2 = _interopRequireDefault(_lightenDarkenColor); -var CalendarDatePeriod = _interopRequire(require("./CalendarDatePeriod")); +var _CalendarDatePeriod = require('./CalendarDatePeriod'); -var CalendarHighlight = _interopRequire(require("./CalendarHighlight")); +var _CalendarDatePeriod2 = _interopRequireDefault(_CalendarDatePeriod); -var CalendarSelection = _interopRequire(require("./CalendarSelection")); +var _CalendarHighlight = require('./CalendarHighlight'); +var _CalendarHighlight2 = _interopRequireDefault(_CalendarHighlight); +var _CalendarSelection = require('./CalendarSelection'); +var _CalendarSelection2 = _interopRequireDefault(_CalendarSelection); -var PureRenderMixin = React.addons.PureRenderMixin; -var cx = React.addons.classSet; +'use strict'; +var PureRenderMixin = _React2['default'].addons.PureRenderMixin; +var cx = _React2['default'].addons.classSet; -var CalendarDate = React.createClass({ - displayName: "CalendarDate", - mixins: [BemMixin, PureRenderMixin], +var CalendarDate = _React2['default'].createClass({ + displayName: 'CalendarDate', + + mixins: [_BemMixin2['default'], PureRenderMixin], propTypes: { - date: React.PropTypes.object.isRequired, - - firstOfMonth: React.PropTypes.object.isRequired, - index: React.PropTypes.number.isRequired, - maxIndex: React.PropTypes.number.isRequired, - selectionType: React.PropTypes.string.isRequired, - - value: React.PropTypes.object, - highlightedRange: React.PropTypes.object, - highlightedDate: React.PropTypes.object, - selectedStartDate: React.PropTypes.object, - dateStates: React.PropTypes.instanceOf(Immutable.List), - - onHighlightDate: React.PropTypes.func, - onUnHighlightDate: React.PropTypes.func, - onStartSelection: React.PropTypes.func, - onCompleteSelection: React.PropTypes.func + date: _React2['default'].PropTypes.object.isRequired, + + firstOfMonth: _React2['default'].PropTypes.object.isRequired, + index: _React2['default'].PropTypes.number.isRequired, + maxIndex: _React2['default'].PropTypes.number.isRequired, + selectionType: _React2['default'].PropTypes.string.isRequired, + + value: _React2['default'].PropTypes.object, + highlightedRange: _React2['default'].PropTypes.object, + highlightedDate: _React2['default'].PropTypes.object, + selectedStartDate: _React2['default'].PropTypes.object, + dateStates: _React2['default'].PropTypes.instanceOf(_Immutable2['default'].List), + + onHighlightDate: _React2['default'].PropTypes.func, + onUnHighlightDate: _React2['default'].PropTypes.func, + onStartSelection: _React2['default'].PropTypes.func, + onCompleteSelection: _React2['default'].PropTypes.func }, getInitialState: function getInitialState() { @@ -63,19 +80,19 @@ var CalendarDate = React.createClass({ isDateSelectable: function isDateSelectable(date) { return this.dateRangesForDate(date).some(function (r) { - return r.get("selectable"); + return r.get('selectable'); }); }, nonSelectableStateRanges: function nonSelectableStateRanges() { return this.props.dateStates.filter(function (d) { - return !d.get("selectable"); + return !d.get('selectable'); }); }, dateRangesForDate: function dateRangesForDate(date) { return this.props.dateStates.filter(function (d) { - return d.get("range").contains(date); + return d.get('range').contains(date); }); }, @@ -85,7 +102,7 @@ var CalendarDate = React.createClass({ * which direction to work */ var blockedRanges = this.nonSelectableStateRanges().map(function (r) { - return r.get("range"); + return r.get('range'); }); var intersect; @@ -94,7 +111,7 @@ var CalendarDate = React.createClass({ return range.intersect(r); }); if (intersect) { - return moment().range(range.start, intersect.start); + return _moment2['default']().range(range.start, intersect.start); } } else { intersect = blockedRanges.findLast(function (r) { @@ -102,16 +119,16 @@ var CalendarDate = React.createClass({ }); if (intersect) { - return moment().range(intersect.end, range.end); + return _moment2['default']().range(intersect.end, range.end); } } if (range.start.isBefore(this.props.enabledRange.start)) { - return moment().range(this.props.enabledRange.start, range.end); + return _moment2['default']().range(this.props.enabledRange.start, range.end); } if (range.end.isAfter(this.props.enabledRange.end)) { - return moment().range(range.start, this.props.enabledRange.end); + return _moment2['default']().range(range.start, this.props.enabledRange.end); } return range; @@ -125,14 +142,14 @@ var CalendarDate = React.createClass({ mouseDown: false }); } - document.removeEventListener("mouseup", this.mouseUp); + document.removeEventListener('mouseup', this.mouseUp); }, mouseDown: function mouseDown() { this.setState({ mouseDown: true }); - document.addEventListener("mouseup", this.mouseUp); + document.addEventListener('mouseup', this.mouseUp); }, touchEnd: function touchEnd() { @@ -144,7 +161,7 @@ var CalendarDate = React.createClass({ mouseDown: false }); } - document.removeEventListener("touchend", this.touchEnd); + document.removeEventListener('touchend', this.touchEnd); }, touchStart: function touchStart(event) { @@ -152,7 +169,7 @@ var CalendarDate = React.createClass({ this.setState({ mouseDown: true }); - document.addEventListener("touchend", this.touchEnd); + document.addEventListener('touchend', this.touchEnd); }, mouseEnter: function mouseEnter() { @@ -171,21 +188,23 @@ var CalendarDate = React.createClass({ }, highlightDate: function highlightDate() { - var date = this.props.date; - var selectionType = this.props.selectionType; - var selectedStartDate = this.props.selectedStartDate; - var onHighlightRange = this.props.onHighlightRange; - var onHighlightDate = this.props.onHighlightDate; + var _props = this.props; + var date = _props.date; + var selectionType = _props.selectionType; + var selectedStartDate = _props.selectedStartDate; + var onHighlightRange = _props.onHighlightRange; + var onHighlightDate = _props.onHighlightDate; + var datePair; var range; var forwards; - if (selectionType === "range") { + if (selectionType === 'range') { if (selectedStartDate) { - datePair = Immutable.List.of(selectedStartDate, date).sortBy(function (d) { + datePair = _Immutable2['default'].List.of(selectedStartDate, date).sortBy(function (d) { return d.unix(); }); - range = moment().range(datePair.get(0), datePair.get(1)); + range = _moment2['default']().range(datePair.get(0), datePair.get(1)); forwards = range.start.unix() === selectedStartDate.unix(); range = this.sanitizeRange(range, forwards); onHighlightRange(range); @@ -204,15 +223,17 @@ var CalendarDate = React.createClass({ }, selectDate: function selectDate() { - var date = this.props.date; - var selectionType = this.props.selectionType; - var selectedStartDate = this.props.selectedStartDate; - var completeRangeSelection = this.props.completeRangeSelection; - var completeSelection = this.props.completeSelection; - var startRangeSelection = this.props.startRangeSelection; + var _props2 = this.props; + var date = _props2.date; + var selectionType = _props2.selectionType; + var selectedStartDate = _props2.selectedStartDate; + var completeRangeSelection = _props2.completeRangeSelection; + var completeSelection = _props2.completeSelection; + var startRangeSelection = _props2.startRangeSelection; + var range; - if (selectionType === "range") { + if (selectionType === 'range') { if (selectedStartDate) { completeRangeSelection(); } else if (!this.isDisabled(date) && this.isDateSelectable(date)) { @@ -226,9 +247,9 @@ var CalendarDate = React.createClass({ }, getBemModifiers: function getBemModifiers() { - var date = this.props.date; - var firstOfMonth = this.props.firstOfMonth; - + var _props3 = this.props; + var date = _props3.date; + var firstOfMonth = _props3.firstOfMonth; var otherMonth = false; var weekend = false; @@ -245,10 +266,12 @@ var CalendarDate = React.createClass({ }, getBemStates: function getBemStates() { - var date = this.props.date; - var value = this.props.value; - var highlightedRange = this.props.highlightedRange; - var highlightedDate = this.props.highlightedDate; + var _props4 = this.props; + var date = _props4.date; + var value = _props4.value; + var highlightedRange = _props4.highlightedRange; + var highlightedDate = _props4.highlightedDate; + var disabled = this.isDisabled(date); var highlighted = false; var selected = false; @@ -273,12 +296,12 @@ var CalendarDate = React.createClass({ }, render: function render() { - var value = this.props.value; - var firstOfMonth = this.props.firstOfMonth; - var date = this.props.date; - var highlightedRange = this.props.highlightedRange; - var highlightedDate = this.props.highlightedDate; - + var _props5 = this.props; + var value = _props5.value; + var firstOfMonth = _props5.firstOfMonth; + var date = _props5.date; + var highlightedRange = _props5.highlightedRange; + var highlightedDate = _props5.highlightedDate; var bemModifiers = this.getBemModifiers(); var bemStates = this.getBemStates(); @@ -296,86 +319,88 @@ var CalendarDate = React.createClass({ if (value && value.start) { if (value.start.isSame(date) && value.start.isSame(value.end)) { - selectionModifier = "single"; + selectionModifier = 'single'; } else if (value.contains(date)) { if (date.isSame(value.start)) { - selectionModifier = "start"; + selectionModifier = 'start'; } else if (date.isSame(value.end)) { - selectionModifier = "end"; + selectionModifier = 'end'; } else { - selectionModifier = "segment"; + selectionModifier = 'segment'; } } } else if (value && date.isSame(value)) { - selectionModifier = "single"; + selectionModifier = 'single'; } if (highlightedRange && highlightedRange.contains(date)) { if (date.isSame(highlightedRange.start)) { - highlightModifier = "start"; + highlightModifier = 'start'; } else if (date.isSame(highlightedRange.end)) { - highlightModifier = "end"; + highlightModifier = 'end'; } else { - highlightModifier = "segment"; + highlightModifier = 'segment'; } } if (highlightedDate && date.isSame(highlightedDate)) { - highlightModifier = "single"; + highlightModifier = 'single'; } if (numStates === 1) { // If there's only one state, it means we're not at a boundary - color = states.getIn([0, "color"]); + color = states.getIn([0, 'color']); if (color) { + style = { backgroundColor: color }; cellStyle = { - borderLeftColor: lightenDarkenColor(color, -10), - borderRightColor: lightenDarkenColor(color, -10) + borderLeftColor: _lightenDarkenColor2['default'](color, -10), + borderRightColor: _lightenDarkenColor2['default'](color, -10) }; } } else { - amColor = states.getIn([0, "color"]); - pmColor = states.getIn([1, "color"]); + amColor = states.getIn([0, 'color']); + pmColor = states.getIn([1, 'color']); if (amColor) { - cellStyle.borderLeftColor = lightenDarkenColor(amColor, -10); + cellStyle.borderLeftColor = _lightenDarkenColor2['default'](amColor, -10); } if (pmColor) { - cellStyle.borderRightColor = lightenDarkenColor(pmColor, -10); + cellStyle.borderRightColor = _lightenDarkenColor2['default'](pmColor, -10); } } - return React.createElement( - "td", - { className: this.cx({ element: "Date", modifiers: bemModifiers, states: bemStates }), + return _React2['default'].createElement( + 'td', + { className: this.cx({ element: 'Date', modifiers: bemModifiers, states: bemStates }), style: cellStyle, onTouchStart: this.touchStart, onMouseOver: this.mouseOver, onMouseEnter: this.mouseEnter, onMouseLeave: this.mouseLeave, onMouseDown: this.mouseDown }, - numStates > 1 && React.createElement( - "div", - { className: this.cx({ element: "HalfDateStates" }) }, - React.createElement(CalendarDatePeriod, { period: "am", color: amColor }), - React.createElement(CalendarDatePeriod, { period: "pm", color: pmColor }) + numStates > 1 && _React2['default'].createElement( + 'div', + { className: this.cx({ element: 'HalfDateStates' }) }, + _React2['default'].createElement(_CalendarDatePeriod2['default'], { period: 'am', color: amColor }), + _React2['default'].createElement(_CalendarDatePeriod2['default'], { period: 'pm', color: pmColor }) ), - numStates === 1 && React.createElement("div", { className: this.cx({ element: "FullDateStates" }), style: style }), - React.createElement( - "span", - { className: this.cx({ element: "DateLabel" }) }, - date.format("D") + numStates === 1 && _React2['default'].createElement('div', { className: this.cx({ element: 'FullDateStates' }), style: style }), + _React2['default'].createElement( + 'span', + { className: this.cx({ element: 'DateLabel' }) }, + date.format('D') ), - selectionModifier && React.createElement(CalendarSelection, { modifier: selectionModifier }), - highlightModifier && React.createElement(CalendarHighlight, { modifier: highlightModifier }) + selectionModifier && _React2['default'].createElement(_CalendarSelection2['default'], { modifier: selectionModifier }), + highlightModifier && _React2['default'].createElement(_CalendarHighlight2['default'], { modifier: highlightModifier }) ); } }); -module.exports = CalendarDate; \ No newline at end of file +exports['default'] = CalendarDate; +module.exports = exports['default']; \ No newline at end of file diff --git a/dist/calendar/CalendarDatePeriod.js b/dist/calendar/CalendarDatePeriod.js index b5131695..e2f15b04 100644 --- a/dist/calendar/CalendarDatePeriod.js +++ b/dist/calendar/CalendarDatePeriod.js @@ -1,30 +1,35 @@ -"use strict"; -var _defineProperty = function (obj, key, value) { - return Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); -}; +'use strict'; -var _interopRequire = function (obj) { - return obj && (obj["default"] || obj); -}; +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _interopRequireDefault = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; + +var _defineProperty = function (obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); }; + +var _React = require('react/addons'); -var React = _interopRequire(require("react/addons")); +var _React2 = _interopRequireDefault(_React); -var BemMixin = _interopRequire(require("../utils/BemMixin")); +var _BemMixin = require('../utils/BemMixin'); -var PureRenderMixin = React.addons.PureRenderMixin; +var _BemMixin2 = _interopRequireDefault(_BemMixin); -var CalendarDatePeriod = React.createClass({ - displayName: "CalendarDatePeriod", - mixins: [BemMixin, PureRenderMixin], +'use strict'; + +var PureRenderMixin = _React2['default'].addons.PureRenderMixin; + +var CalendarDatePeriod = _React2['default'].createClass({ + displayName: 'CalendarDatePeriod', + + mixins: [_BemMixin2['default'], PureRenderMixin], render: function render() { - var color = this.props.color; - var period = this.props.period; + var _props = this.props; + var color = _props.color; + var period = _props.period; + var modifiers = _defineProperty({}, period, true); var style; @@ -32,8 +37,9 @@ var CalendarDatePeriod = React.createClass({ style = { backgroundColor: color }; } - return React.createElement("div", { style: style, className: this.cx({ modifiers: modifiers }) }); + return _React2['default'].createElement('div', { style: style, className: this.cx({ modifiers: modifiers }) }); } }); -module.exports = CalendarDatePeriod; \ No newline at end of file +exports['default'] = CalendarDatePeriod; +module.exports = exports['default']; \ No newline at end of file diff --git a/dist/calendar/CalendarHighlight.js b/dist/calendar/CalendarHighlight.js index 2d144bff..36b6cd70 100644 --- a/dist/calendar/CalendarHighlight.js +++ b/dist/calendar/CalendarHighlight.js @@ -1,38 +1,43 @@ -"use strict"; -var _defineProperty = function (obj, key, value) { - return Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); -}; +'use strict'; -var _interopRequire = function (obj) { - return obj && (obj["default"] || obj); -}; +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _interopRequireDefault = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; + +var _defineProperty = function (obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); }; + +var _React = require('react/addons'); -var React = _interopRequire(require("react/addons")); +var _React2 = _interopRequireDefault(_React); -var BemMixin = _interopRequire(require("../utils/BemMixin")); +var _BemMixin = require('../utils/BemMixin'); -var PureRenderMixin = React.addons.PureRenderMixin; +var _BemMixin2 = _interopRequireDefault(_BemMixin); +'use strict'; -var CalendarHighlight = React.createClass({ - displayName: "CalendarHighlight", - mixins: [BemMixin, PureRenderMixin], +var PureRenderMixin = _React2['default'].addons.PureRenderMixin; + +var CalendarHighlight = _React2['default'].createClass({ + displayName: 'CalendarHighlight', + + mixins: [_BemMixin2['default'], PureRenderMixin], render: function render() { - var modifier = this.props.modifier; - var inOtherMonth = this.props.inOtherMonth; + var _props = this.props; + var modifier = _props.modifier; + var inOtherMonth = _props.inOtherMonth; + var modifiers = _defineProperty({}, modifier, true); var states = { inOtherMonth: inOtherMonth }; - return React.createElement("div", { className: this.cx({ states: states, modifiers: modifiers }) }); + return _React2['default'].createElement('div', { className: this.cx({ states: states, modifiers: modifiers }) }); } }); -module.exports = CalendarHighlight; \ No newline at end of file +exports['default'] = CalendarHighlight; +module.exports = exports['default']; \ No newline at end of file diff --git a/dist/calendar/CalendarMonth.js b/dist/calendar/CalendarMonth.js index a0cc1f19..98a7adee 100644 --- a/dist/calendar/CalendarMonth.js +++ b/dist/calendar/CalendarMonth.js @@ -1,79 +1,88 @@ -"use strict"; +'use strict'; -var _objectWithoutProperties = function (obj, keys) { - var target = {}; +Object.defineProperty(exports, '__esModule', { + value: true +}); - for (var i in obj) { - if (keys.indexOf(i) >= 0) continue; - if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; - target[i] = obj[i]; - } +var _interopRequireDefault = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; + +var _objectWithoutProperties = function (obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _React = require('react/addons'); - return target; -}; +var _React2 = _interopRequireDefault(_React); -var _interopRequire = function (obj) { - return obj && (obj["default"] || obj); -}; +var _moment = require('moment'); -var React = _interopRequire(require("react/addons")); +var _moment2 = _interopRequireDefault(_moment); -var moment = _interopRequire(require("moment")); +var _calendar = require('calendar'); -var calendar = _interopRequire(require("calendar")); +var _calendar2 = _interopRequireDefault(_calendar); -var Immutable = _interopRequire(require("immutable")); +var _Immutable = require('immutable'); -var BemMixin = _interopRequire(require("../utils/BemMixin")); +var _Immutable2 = _interopRequireDefault(_Immutable); -var PureRenderMixin = React.addons.PureRenderMixin; +var _BemMixin = require('../utils/BemMixin'); -var lang = moment().localeData(); +var _BemMixin2 = _interopRequireDefault(_BemMixin); -var WEEKDAYS = Immutable.List(lang._weekdays).zip(Immutable.List(lang._weekdaysShort)); -var MONTHS = Immutable.List(lang._months); +'use strict'; +var PureRenderMixin = _React2['default'].addons.PureRenderMixin; -var CalendarMonth = React.createClass({ - displayName: "CalendarMonth", - mixins: [BemMixin, PureRenderMixin], +var lang = _moment2['default']().localeData(); + +var WEEKDAYS = _Immutable2['default'].List(lang._weekdays).zip(_Immutable2['default'].List(lang._weekdaysShort)); +var MONTHS = _Immutable2['default'].List(lang._months); + +var CalendarMonth = _React2['default'].createClass({ + displayName: 'CalendarMonth', + + mixins: [_BemMixin2['default'], PureRenderMixin], renderDay: function renderDay(date, i) { - var CalendarDate = this.props.dateComponent; - var props = _objectWithoutProperties(this.props, ["dateComponent"]); + var _props = this.props; + var CalendarDate = _props.dateComponent; - return React.createElement(CalendarDate, React.__spread({}, props, { date: moment(date), key: i })); + var props = _objectWithoutProperties(_props, ['dateComponent']); + + return _React2['default'].createElement(CalendarDate, _extends({}, props, { date: _moment2['default'](date), key: i })); }, renderWeek: function renderWeek(dates, i) { var days = dates.map(this.renderDay); - return React.createElement( - "tr", - { className: this.cx({ element: "Week" }), key: i }, + return _React2['default'].createElement( + 'tr', + { className: this.cx({ element: 'Week' }), key: i }, days.toJS() ); }, renderDayHeaders: function renderDayHeaders() { var firstOfWeek = this.props.firstOfWeek; - var indices = Immutable.Range(firstOfWeek, 7).concat(Immutable.Range(0, firstOfWeek)); + + var indices = _Immutable2['default'].Range(firstOfWeek, 7).concat(_Immutable2['default'].Range(0, firstOfWeek)); var headers = indices.map((function (index) { var weekday = WEEKDAYS.get(index); - return React.createElement( - "th", - { className: this.cx({ element: "WeekdayHeading" }), key: weekday, scope: "col" }, - React.createElement( - "abbr", + return _React2['default'].createElement( + 'th', + { className: this.cx({ element: 'WeekdayHeading' }), key: weekday, scope: 'col' }, + _React2['default'].createElement( + 'abbr', { title: weekday[0] }, weekday[1] ) ); }).bind(this)); - return React.createElement( - "tr", - { className: this.cx({ element: "Weekdays" }) }, + return _React2['default'].createElement( + 'tr', + { className: this.cx({ element: 'Weekdays' }) }, headers.toJS() ); }, @@ -85,7 +94,6 @@ var CalendarMonth = React.createClass({ renderYearChoice: function renderYearChoice(year) { var enabledRange = this.props.enabledRange; - if (year < enabledRange.start.year()) { return; } @@ -94,8 +102,8 @@ var CalendarMonth = React.createClass({ return; } - return React.createElement( - "option", + return _React2['default'].createElement( + 'option', { key: year, value: year }, year ); @@ -103,18 +111,19 @@ var CalendarMonth = React.createClass({ renderHeaderYear: function renderHeaderYear() { var firstOfMonth = this.props.firstOfMonth; + var y = firstOfMonth.year(); - var years = Immutable.Range(y - 5, y).concat(Immutable.Range(y, y + 10)); + var years = _Immutable2['default'].Range(y - 5, y).concat(_Immutable2['default'].Range(y, y + 10)); var choices = years.map(this.renderYearChoice); var modifiers = { year: true }; - return React.createElement( - "span", - { className: this.cx({ element: "MonthHeaderLabel", modifiers: modifiers }) }, - firstOfMonth.format("YYYY"), - this.props.disableNavigation ? null : React.createElement( - "select", - { className: this.cx({ element: "MonthHeaderSelect" }), value: y, onChange: this.handleYearChange }, + return _React2['default'].createElement( + 'span', + { className: this.cx({ element: 'MonthHeaderLabel', modifiers: modifiers }) }, + firstOfMonth.format('YYYY'), + this.props.disableNavigation ? null : _React2['default'].createElement( + 'select', + { className: this.cx({ element: 'MonthHeaderSelect' }), value: y, onChange: this.handleYearChange }, choices.toJS() ) ); @@ -125,76 +134,79 @@ var CalendarMonth = React.createClass({ }, renderMonthChoice: function renderMonthChoice(month, i) { - var firstOfMonth = this.props.firstOfMonth; - var enabledRange = this.props.enabledRange; + var _props2 = this.props; + var firstOfMonth = _props2.firstOfMonth; + var enabledRange = _props2.enabledRange; + var disabled = false; var year = firstOfMonth.year(); - if (moment({ years: year, months: i + 1, date: 1 }).unix() < enabledRange.start.unix()) { + if (_moment2['default']({ years: year, months: i + 1, date: 1 }).unix() < enabledRange.start.unix()) { disabled = true; } - if (moment({ years: year, months: i, date: 1 }).unix() > enabledRange.end.unix()) { + if (_moment2['default']({ years: year, months: i, date: 1 }).unix() > enabledRange.end.unix()) { disabled = true; } - return React.createElement( - "option", - { key: month, value: i, disabled: disabled ? "disabled" : null }, + return _React2['default'].createElement( + 'option', + { key: month, value: i, disabled: disabled ? 'disabled' : null }, month ); }, renderHeaderMonth: function renderHeaderMonth() { var firstOfMonth = this.props.firstOfMonth; + var choices = MONTHS.map(this.renderMonthChoice); var modifiers = { month: true }; - return React.createElement( - "span", - { className: this.cx({ element: "MonthHeaderLabel", modifiers: modifiers }) }, - firstOfMonth.format("MMMM"), - this.props.disableNavigation ? null : React.createElement( - "select", - { className: this.cx({ element: "MonthHeaderSelect" }), value: firstOfMonth.month(), onChange: this.handleMonthChange }, + return _React2['default'].createElement( + 'span', + { className: this.cx({ element: 'MonthHeaderLabel', modifiers: modifiers }) }, + firstOfMonth.format('MMMM'), + this.props.disableNavigation ? null : _React2['default'].createElement( + 'select', + { className: this.cx({ element: 'MonthHeaderSelect' }), value: firstOfMonth.month(), onChange: this.handleMonthChange }, choices.toJS() ) ); }, renderHeader: function renderHeader() { - return React.createElement( - "div", - { className: this.cx({ element: "MonthHeader" }) }, + return _React2['default'].createElement( + 'div', + { className: this.cx({ element: 'MonthHeader' }) }, this.renderHeaderMonth(), - " ", + ' ', this.renderHeaderYear() ); }, render: function render() { - var firstOfWeek = this.props.firstOfWeek; - var firstOfMonth = this.props.firstOfMonth; - + var _props3 = this.props; + var firstOfWeek = _props3.firstOfWeek; + var firstOfMonth = _props3.firstOfMonth; - var cal = new calendar.Calendar(firstOfWeek); - var monthDates = Immutable.fromJS(cal.monthDates(firstOfMonth.year(), firstOfMonth.month())); + var cal = new _calendar2['default'].Calendar(firstOfWeek); + var monthDates = _Immutable2['default'].fromJS(cal.monthDates(firstOfMonth.year(), firstOfMonth.month())); var weeks = monthDates.map(this.renderWeek); - return React.createElement( - "div", - { className: this.cx({ element: "Month" }) }, + return _React2['default'].createElement( + 'div', + { className: this.cx({ element: 'Month' }) }, this.renderHeader(), - React.createElement( - "table", - { className: this.cx({ element: "MonthDates" }) }, - React.createElement( - "thead", + _React2['default'].createElement( + 'table', + { className: this.cx({ element: 'MonthDates' }) }, + _React2['default'].createElement( + 'thead', null, this.renderDayHeaders() ), - React.createElement( - "tbody", + _React2['default'].createElement( + 'tbody', null, weeks.toJS() ) @@ -203,4 +215,5 @@ var CalendarMonth = React.createClass({ } }); -module.exports = CalendarMonth; \ No newline at end of file +exports['default'] = CalendarMonth; +module.exports = exports['default']; \ No newline at end of file diff --git a/dist/calendar/CalendarSelection.js b/dist/calendar/CalendarSelection.js index 44feb9ed..054a2599 100644 --- a/dist/calendar/CalendarSelection.js +++ b/dist/calendar/CalendarSelection.js @@ -1,38 +1,43 @@ -"use strict"; -var _defineProperty = function (obj, key, value) { - return Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); -}; +'use strict'; -var _interopRequire = function (obj) { - return obj && (obj["default"] || obj); -}; +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _interopRequireDefault = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; + +var _defineProperty = function (obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); }; + +var _React = require('react/addons'); -var React = _interopRequire(require("react/addons")); +var _React2 = _interopRequireDefault(_React); -var BemMixin = _interopRequire(require("../utils/BemMixin")); +var _BemMixin = require('../utils/BemMixin'); -var PureRenderMixin = React.addons.PureRenderMixin; +var _BemMixin2 = _interopRequireDefault(_BemMixin); +'use strict'; -var CalendarSelection = React.createClass({ - displayName: "CalendarSelection", - mixins: [BemMixin, PureRenderMixin], +var PureRenderMixin = _React2['default'].addons.PureRenderMixin; + +var CalendarSelection = _React2['default'].createClass({ + displayName: 'CalendarSelection', + + mixins: [_BemMixin2['default'], PureRenderMixin], render: function render() { - var modifier = this.props.modifier; - var inOtherMonth = this.props.inOtherMonth; + var _props = this.props; + var modifier = _props.modifier; + var inOtherMonth = _props.inOtherMonth; + var modifiers = _defineProperty({}, modifier, true); var states = { inOtherMonth: inOtherMonth }; - return React.createElement("div", { className: this.cx({ states: states, modifiers: modifiers }) }); + return _React2['default'].createElement('div', { className: this.cx({ states: states, modifiers: modifiers }) }); } }); -module.exports = CalendarSelection; \ No newline at end of file +exports['default'] = CalendarSelection; +module.exports = exports['default']; \ No newline at end of file diff --git a/dist/utils/BemMixin.js b/dist/utils/BemMixin.js index 9456a3eb..41520ab4 100644 --- a/dist/utils/BemMixin.js +++ b/dist/utils/BemMixin.js @@ -1,30 +1,35 @@ -"use strict"; +'use strict'; -var _interopRequire = function (obj) { - return obj && (obj["default"] || obj); -}; +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _interopRequireDefault = function (obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }; -var React = _interopRequire(require("react")); +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -var bemCx = _interopRequire(require("./bemCx")); +var _React = require('react'); +var _React2 = _interopRequireDefault(_React); +var _bemCx = require('./bemCx'); +var _bemCx2 = _interopRequireDefault(_bemCx); var BemMixin = { propTypes: { - bemNamespace: React.PropTypes.string, - bemBlock: React.PropTypes.string + bemNamespace: _React2['default'].PropTypes.string, + bemBlock: _React2['default'].PropTypes.string }, contextTypes: { - bemNamespace: React.PropTypes.string, - bemBlock: React.PropTypes.string + bemNamespace: _React2['default'].PropTypes.string, + bemBlock: _React2['default'].PropTypes.string }, childContextTypes: { - bemNamespace: React.PropTypes.string, - bemBlock: React.PropTypes.string + bemNamespace: _React2['default'].PropTypes.string, + bemBlock: _React2['default'].PropTypes.string }, getChildContext: function getChildContext() { @@ -56,14 +61,16 @@ var BemMixin = { cx: function cx() { var options = arguments[0] === undefined ? {} : arguments[0]; + var opts = { namespace: this.getBemNamespace(), element: this.constructor.displayName, block: this.getBemBlock() }; - Object.assign(opts, options); - return bemCx(opts); + _extends(opts, options); + return _bemCx2['default'](opts); } }; -module.exports = BemMixin; \ No newline at end of file +exports['default'] = BemMixin; +module.exports = exports['default']; \ No newline at end of file diff --git a/dist/utils/bemCx.js b/dist/utils/bemCx.js index c0996b79..5164b662 100644 --- a/dist/utils/bemCx.js +++ b/dist/utils/bemCx.js @@ -1,6 +1,10 @@ -"use strict"; +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports['default'] = bemCx; -module.exports = bemCx; function bemCx() { var options = arguments[0] === undefined ? {} : arguments[0]; var block = options.block; @@ -8,18 +12,19 @@ function bemCx() { var namespace = options.namespace; var modifiers = options.modifiers; var states = options.states; + var bemClasses = []; var baseClassName; if (element) { if (namespace) { - baseClassName = "" + namespace + "-" + block + "__" + element; + baseClassName = '' + namespace + '-' + block + '__' + element; } else { - baseClassName = "" + block + "__" + element; + baseClassName = '' + block + '__' + element; } } else { if (namespace) { - baseClassName = "" + namespace + "-" + block; + baseClassName = '' + namespace + '-' + block; } else { baseClassName = block; } @@ -28,34 +33,36 @@ function bemCx() { bemClasses.push(baseClassName); if (states) { - if (typeof states == "object") { + if (typeof states == 'object') { states = Object.keys(states).filter(function (s) { return states[s]; }); } states.forEach(function (state) { - bemClasses.push("" + baseClassName + "--is-" + state); + bemClasses.push('' + baseClassName + '--is-' + state); }); } if (modifiers) { - if (typeof modifiers == "object") { + if (typeof modifiers == 'object') { modifiers = Object.keys(modifiers).filter(function (m) { return modifiers[m]; }); } modifiers.forEach(function (modifier) { - bemClasses.push("" + baseClassName + "--" + modifier); + bemClasses.push('' + baseClassName + '--' + modifier); if (states) { states.forEach(function (state) { - bemClasses.push("" + baseClassName + "--" + modifier + "--is-" + state); + bemClasses.push('' + baseClassName + '--' + modifier + '--is-' + state); }); } }); } - return bemClasses.join(" "); -} \ No newline at end of file + return bemClasses.join(' '); +} + +module.exports = exports['default']; \ No newline at end of file diff --git a/dist/utils/lightenDarkenColor.js b/dist/utils/lightenDarkenColor.js index 9f6a34b2..e31c2cf6 100644 --- a/dist/utils/lightenDarkenColor.js +++ b/dist/utils/lightenDarkenColor.js @@ -1,6 +1,10 @@ "use strict"; -module.exports = lightenDarkenColor; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = lightenDarkenColor; + function lightenDarkenColor(col, amt) { var usePound = false; var num; @@ -40,4 +44,6 @@ function lightenDarkenColor(col, amt) { } return (usePound ? "#" : "") + (g | b << 8 | r << 16).toString(16); -} \ No newline at end of file +} + +module.exports = exports["default"]; \ No newline at end of file diff --git a/example/components/code-snippet.jsx b/example/components/code-snippet.jsx index 41b47205..05955ae6 100644 --- a/example/components/code-snippet.jsx +++ b/example/components/code-snippet.jsx @@ -1,4 +1,3 @@ -/** @jsx React.DOM */ /* global hljs */ "use strict"; diff --git a/example/components/features.jsx b/example/components/features.jsx index 62bd1292..b33c905f 100644 --- a/example/components/features.jsx +++ b/example/components/features.jsx @@ -1,4 +1,3 @@ -/** @jsx React.DOM */ "use strict"; var React = require('react/addons'); diff --git a/example/components/footer.jsx b/example/components/footer.jsx index 74511bc2..86e5c190 100644 --- a/example/components/footer.jsx +++ b/example/components/footer.jsx @@ -1,4 +1,3 @@ -/** @jsx React.DOM */ "use strict"; var React = require('react/addons'); diff --git a/example/components/github-ribbon.jsx b/example/components/github-ribbon.jsx index 2a539e2c..f70ad1ca 100644 --- a/example/components/github-ribbon.jsx +++ b/example/components/github-ribbon.jsx @@ -1,4 +1,3 @@ -/** @jsx React.DOM */ "use strict"; var React = require('react/addons'); diff --git a/example/components/header.jsx b/example/components/header.jsx index cacae7d5..6f2ba68a 100644 --- a/example/components/header.jsx +++ b/example/components/header.jsx @@ -1,4 +1,3 @@ -/** @jsx React.DOM */ "use strict"; var React = require('react/addons'); diff --git a/example/components/install.jsx b/example/components/install.jsx index bc5d5488..8f63ce97 100644 --- a/example/components/install.jsx +++ b/example/components/install.jsx @@ -1,4 +1,3 @@ -/** @jsx React.DOM */ "use strict"; var React = require('react/addons'); diff --git a/gulpfile.js b/gulpfile.js index b6a52663..1d34fa48 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,7 +6,7 @@ var gulp = require('gulp'); var autoprefixer = require('gulp-autoprefixer'); var extReplace = require('gulp-ext-replace'); var watch = require('gulp-watch'); -var to5 = require('gulp-6to5'); +var babel = require('gulp-babel'); var render = require('gulp-render'); var connect = require('gulp-connect'); var sass = require('gulp-sass'); @@ -15,7 +15,10 @@ var deploy = require('gulp-gh-pages'); gulp.task('build-js', function() { // build javascript files return gulp.src('src/**/*.{js,jsx}') - .pipe(to5({experimental: true, runtime: false})) + .pipe(babel({ + stage: 1, + plugins: ['object-assign'] + })) .pipe(extReplace('.js')) .pipe(gulp.dest('dist')); }); @@ -29,7 +32,10 @@ gulp.task('watch-js', function() { gulp.task('build-example', ['build-js'], function() { return gulp.src('./example/index.jsx') - .pipe(to5({experimental: true, runtime: false})) + .pipe(babel({ + stage: 1, + plugins: ['object-assign'] + })) .pipe(render({ template: '' + '<%=body%>' diff --git a/package.json b/package.json index 062a81ed..18fc9c85 100644 --- a/package.json +++ b/package.json @@ -30,15 +30,16 @@ "calendar": "^0.1.0", "immutable": "^3.6.2", "moment": "^2.8.3", - "moment-range": "^1.0.5", - "object.assign": "^1.1.1" + "moment-range": "^1.0.5" }, "devDependencies": { - "6to5-loader": "^2.0.0", + "babel-core": "^5.2.6", + "babel-loader": "^5.0.0", + "babel-plugin-object-assign": "^1.0.1", "brfs": "^1.2.0", "gulp": "^3.8.9", - "gulp-6to5": "^2.0.2", "gulp-autoprefixer": "^2.1.0", + "gulp-babel": "^5.1.0", "gulp-connect": "^2.2.0", "gulp-ext-replace": "^0.1.0", "gulp-gh-pages": "^0.4.0", @@ -47,6 +48,7 @@ "gulp-sourcemaps": "^1.2.4", "gulp-util": "^3.0.1", "gulp-watch": "^1.1.0", + "object.assign": "^1.1.1", "timekeeper": "0.0.5", "transform-loader": "^0.2.1", "webpack": "^1.5.3" diff --git a/webpack.config.js b/webpack.config.js index a0ccd91a..84a005e3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,3 +1,5 @@ +var webpack = require('webpack'); + module.exports = { cache: true, context: __dirname, @@ -12,14 +14,14 @@ module.exports = { test: /\.jsx$/, exclude: /node_modules\//, loaders: [ - '6to5-loader?experimental=true&runtime=true' + 'babel-loader?stage=1&plugins[]=object-assign' ] }, { test: /\.js$/, exclude: /node_modules\//, loaders: [ - '6to5-loader?experimental=true&react=false&runtime=true' + 'babel-loader?stage=1&plugins[]=object-assign' ] }, ], @@ -31,5 +33,10 @@ module.exports = { }, resolve: { extensions: ['', '.js', '.jsx'] - } + }, + plugins: [ + // Fix for moment including all locales + // Ref: http://stackoverflow.com/a/25426019 + new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/) + ] };