Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/calendar / dist / react-big-calendar / TimeSlotGroup.js
Size: Mime:
'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

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 _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _isEqual = require('lodash/isEqual');

var _isEqual2 = _interopRequireDefault(_isEqual);

var _NoopWrapper = require('./NoopWrapper');

var _NoopWrapper2 = _interopRequireDefault(_NoopWrapper);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var TimeSlotGroup = function (_Component) {
  _inherits(TimeSlotGroup, _Component);

  function TimeSlotGroup() {
    _classCallCheck(this, TimeSlotGroup);

    return _possibleConstructorReturn(this, (TimeSlotGroup.__proto__ || Object.getPrototypeOf(TimeSlotGroup)).apply(this, arguments));
  }

  _createClass(TimeSlotGroup, [{
    key: 'shouldComponentUpdate',
    value: function shouldComponentUpdate(nextProps) {
      if (this.props.renderSlot) return true;
      return this.props.group.length !== nextProps.group.length || !(0, _isEqual2.default)(this.props.group, nextProps.group) || this.props.minNotice !== nextProps.minNotice || this.props.maxHorizon !== nextProps.maxHorizon;
    }
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props,
          renderSlot = _props.renderSlot,
          resource = _props.resource,
          group = _props.group,
          isTimeGutter = _props.isTimeGutter,
          isGenericCalendarMode = _props.isGenericCalendarMode,
          getters = _props.getters,
          maxHorizon = _props.maxHorizon,
          minNotice = _props.minNotice,
          _props$components = _props.components;
      _props$components = _props$components === undefined ? {} : _props$components;
      var _props$components$tim = _props$components.timeSlotWrapper,
          Wrapper = _props$components$tim === undefined ? _NoopWrapper2.default : _props$components$tim;


      return _react2.default.createElement(
        'div',
        { className: 'rbc-timeslot-group' },
        group.map(function (timeslot, idx) {
          var slotProps = getters ? getters.slotProp(timeslot.value, resource) : {};
          var slotOutOfHorizons = false;
          if (maxHorizon) {
            slotOutOfHorizons = +timeslot.value > +maxHorizon;
          }
          if (minNotice) {
            slotOutOfHorizons = +timeslot.value < +minNotice || slotOutOfHorizons;
          }
          return _react2.default.createElement(
            Wrapper,
            {
              key: idx,
              value: timeslot.value,
              resource: resource,
              notAllowed: timeslot.notAllowed,
              isTimeGutter: isTimeGutter,
              isInThePast: timeslot.isInThePast
            },
            _react2.default.createElement(
              'div',
              _extends({}, slotProps, {
                className: (0, _classnames2.default)('rbc-time-slot', { 'rbc-time-slot-pc--excluded': slotOutOfHorizons }, { 'rbc-time-slot--excluded': !isTimeGutter && timeslot.isInThePast && !slotOutOfHorizons }, slotProps.className)
              }),
              renderSlot && renderSlot(timeslot.value, idx)
            )
          );
        })
      );
    }
  }]);

  return TimeSlotGroup;
}(_react.Component);

TimeSlotGroup.propTypes = {
  renderSlot: _propTypes2.default.func,
  group: _propTypes2.default.array.isRequired,
  resource: _propTypes2.default.any,
  isTimeGutter: _propTypes2.default.bool,
  isGenericCalendarMode: _propTypes2.default.bool,
  components: _propTypes2.default.object,
  getters: _propTypes2.default.object,
  maxHorizon: _propTypes2.default.instanceOf(Date),
  minNotice: _propTypes2.default.instanceOf(Date)
};
TimeSlotGroup.defaultProps = {
  isTimeGutter: false,
  isGenericCalendarMode: false,
  renderSlot: null,
  maxHorizon: null,
  minNotice: null
};
exports.default = TimeSlotGroup;