"use strict";

var _react = _interopRequireDefault(require("react"));

var _react2 = require("@storybook/react");

var _addonKnobs = require("@storybook/addon-knobs");

var _addonActions = require("@storybook/addon-actions");

var _Token = _interopRequireDefault(require("../Token"));

var _Container = _interopRequireDefault(require("./Container"));

var _Row = _interopRequireDefault(require("./Row"));

var _Col = _interopRequireDefault(require("./Col"));

var _ColWithNubbin = _interopRequireDefault(require("./ColWithNubbin"));

var _NavBar = _interopRequireDefault(require("../NavBar"));

var _Attention = _interopRequireDefault(require("../Attention"));

var _Spinner = _interopRequireDefault(require("../Spinner"));

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

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

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

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

var openLogoUrl = "https://app.optimizely.com/dist/static/img/rebrand/logo-f64d2aed989db744b609666199d7d2a2.svg";

var ConfigPanelExample =
/*#__PURE__*/
function (_React$Component) {
  _inherits(ConfigPanelExample, _React$Component);

  function ConfigPanelExample(props) {
    var _this;

    _classCallCheck(this, ConfigPanelExample);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(ConfigPanelExample).call(this, props)); // 1) Create the reference here.

    _this.pointingRef = _react["default"].createRef();
    _this.state = {
      nubbinPointingRef: null
    };
    return _this;
  }

  _createClass(ConfigPanelExample, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      // 2) Use the ref to store the node in state
      this.setState({
        nubbinPointingRef: this.pointingRef.current
      });
    }
  }, {
    key: "render",
    value: function render() {
      return _react["default"].createElement("div", {
        style: {
          height: "500px",
          width: "100%"
        }
      }, _react["default"].createElement(_Container["default"], {
        fluid: true,
        isFullHeight: true
      }, _react["default"].createElement(_Row["default"], null, _react["default"].createElement(_Col["default"], {
        small: 6
      }, _react["default"].createElement("div", {
        className: "height--1-1 soft-double"
      }, _react["default"].createElement("h3", null, "Rules"), _react["default"].createElement("p", null, "Explanatory content here"), _react["default"].createElement("div", {
        style: {
          height: "100px"
        }
      }), _react["default"].createElement("div", {
        className: " flex flex--column border--all" // 3) Assign ref to element you want nubbin pointing to
        ,
        ref: this.pointingRef
      }, "The nubbin should point in the middle of this area", _react["default"].createElement(_Token["default"], {
        isDraggable: true,
        name: "This is option 1 for reordering",
        order: 1,
        showWell: false
      }), _react["default"].createElement(_Token["default"], {
        isDraggable: true,
        name: "This is option 2 for reordering",
        order: 2,
        showWell: false
      }), _react["default"].createElement(_Token["default"], {
        isDraggable: true,
        name: "This is option 3 for reordering",
        order: 3,
        showWell: false
      })))), _react["default"].createElement(_ColWithNubbin["default"], {
        small: 6 // 4) Pass ref to ColWithNubbin
        ,
        nubbinRef: this.state.nubbinPointingRef
      }, _react["default"].createElement("h3", null, "Rule Configuration")))));
    }
  }]);

  return ConfigPanelExample;
}(_react["default"].Component);

var storiesForTemplates = (0, _react2.storiesOf)("Templates (deprecated)", module);
storiesForTemplates.addDecorator(_addonKnobs.withKnobs).addDecorator(function (story) {
  return _react["default"].createElement("div", {
    id: "root-preview"
  }, story());
});
storiesForTemplates.add("Config Panel", function () {
  return _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement("div", {
    className: "push-double--bottom"
  }, _react["default"].createElement(_Attention["default"], {
    type: "brand"
  }, "Use a ref passed to ColWithNubbin to place the nubbin properly")), _react["default"].createElement(ConfigPanelExample, null));
}).add("Entire App Frame", function () {
  return _react["default"].createElement(_Container["default"], {
    outlineDebug: (0, _addonKnobs["boolean"])("outlineDebug", true),
    pushRowsTop: (0, _addonKnobs["boolean"])("pushRowsTop", true),
    paddedContent: (0, _addonKnobs.text)("paddedContent", "none"),
    fluid: (0, _addonKnobs["boolean"])("fluid", true)
  }, _react["default"].createElement(_Row["default"], {
    removeGutters: (0, _addonKnobs["boolean"])("gutters", false),
    shouldWrap: false
  }, _react["default"].createElement(_Col["default"], {
    small: "fitContent"
  }, _react["default"].createElement(_NavBar["default"], {
    isOpen: true,
    logoUrl: openLogoUrl,
    title: "Test Project",
    badgeText: "WEB",
    badgeColor: "draft",
    homeUrl: "http://optimizely.com",
    trialContent: _react["default"].createElement("div", {
      className: "push-double--bottom push-double--left truncate"
    }, (0, _addonKnobs["boolean"])("isOpen", true) && "5 days left in your trial")
  }, _react["default"].createElement(_NavBar["default"].PrimaryLink, {
    iconName: "projects",
    type: "pushstate",
    linkLabel: "Projects",
    testSection: "projects"
  }), _react["default"].createElement(_NavBar["default"].PrimaryLink, {
    iconName: "experiment",
    type: "link",
    linkLabel: "Experiment",
    testSection: "experiment",
    isActive: true
  }), _react["default"].createElement(_NavBar["default"].PrimaryLink, {
    iconName: "rollouts",
    type: "link",
    linkLabel: "Features",
    testSection: "features"
  }), _react["default"].createElement(_NavBar["default"].PrimaryLink, {
    iconName: "audiences",
    type: "link",
    linkLabel: "Audiences",
    testSection: "audiences"
  }), _react["default"].createElement(_NavBar["default"].PrimaryLink, {
    iconName: "events",
    type: "button",
    linkLabel: "Events",
    testSection: "events"
  }), _react["default"].createElement(_NavBar["default"].PrimaryLink, {
    iconName: "settings",
    type: "link",
    linkLabel: "Settings",
    testSection: "settings"
  }), _react["default"].createElement(_NavBar["default"].PrimaryLink, {
    iconName: "getting-started",
    type: "pushstate",
    linkLabel: "Getting Started",
    testSection: "getting-started",
    hasSeparator: true
  }), _react["default"].createElement(_NavBar["default"].SecondaryLink, {
    iconName: "program-management",
    type: "button",
    linkLabel: "Program Management",
    testSection: "program-management"
  }), _react["default"].createElement(_NavBar["default"].SecondaryLink, {
    iconName: "help",
    type: "link",
    linkLabel: "Help",
    testSection: "help"
  }), _react["default"].createElement(_NavBar["default"].SecondaryLink, {
    iconName: "feedback",
    type: "link",
    linkLabel: "Feedback",
    testSection: "feedback"
  }), _react["default"].createElement(_NavBar["default"].CurrentUserMenu, {
    showEmulate: (0, _addonKnobs["boolean"])("showEmulate", true),
    onEmulateClick: (0, _addonActions.action)("onEmulateClick"),
    accountSwitcherItems: [{
      text: "Account 1",
      url: "#",
      description: "Account 1 Description",
      isCurrent: false
    }, {
      text: "Account 3",
      url: "#",
      description: "Account 3 Description",
      isCurrent: false
    }, {
      text: "Account 2",
      url: "#",
      description: "Account 2 Description",
      isCurrent: true
    }],
    accountSwitcherHandler: (0, _addonActions.action)("accountSwitcherHandler"),
    userName: "Hassan Khalid",
    accountSettingsUrl: "#",
    profileUrl: "#",
    logoutUrl: "#",
    profileAvatarUrl: (0, _addonKnobs.text)("profileAvatarUrl", "https://optimizely-profile-images-devel.s3.amazonaws.com/img/user/hassan.khalid%40optimizely.com/c57517e7ee4941d0a5e71f3d89df0c0d.jpg")
  }))), _react["default"].createElement(_Col["default"], {
    small: "fitContent"
  }, _react["default"].createElement("div", {
    style: {
      width: "285px"
    }
  }, "Tabs/Header")), _react["default"].createElement(_Col["default"], {
    small: "fillSpace",
    isReadingColumn: true
  }, _react["default"].createElement("div", null, "Stage (using isReadingColumn on the Col)"))));
}).add("Spinner", function () {
  return _react["default"].createElement("div", {
    style: {
      height: "550px"
    }
  }, _react["default"].createElement(_Container["default"], {
    isFullHeight: true,
    outlineDebug: (0, _addonKnobs["boolean"])("outlineDebug", true)
  }, _react["default"].createElement(_Row["default"], {
    verticalAlignment: "center"
  }, _react["default"].createElement(_Col["default"], null, _react["default"].createElement(_Spinner["default"], {
    hasOverlay: true
  })))));
});