"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; 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); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.MixinsMenuItemStacked = exports.MixinsMenuItemSpacing = exports.ClosedCustomItem = exports.OpenCustomItem = exports.ClosedCustomTrigger = exports.OpenFlatTopCorners = exports.OpenCustomTrigger = exports.ClosedBasic = exports.OpenBasic = exports.MixinsStackee = exports.MixinsSpacing = exports.InteractiveCustomized = exports.InteractiveBasic = exports["default"] = void 0;

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

var _styledComponents = _interopRequireDefault(require("styled-components"));

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

var _menu = require("./menu.component");

var _menuItem = require("./menu-item");

var _text = require("../../typography/text");

var _box = require("../../../primitives/box");

var _info = require("../../icon/info");

var _span = require("../../typography/span");

var _branding = require("../../../mixins/branding");

var _marginChecker = require("../../../mixins/spacing/story-support/margin-checker");

var _paddingChecker = require("../../../mixins/spacing/story-support/padding-checker");

var _stackeeChecker = require("../../../mixins/stackee/story-support/stackee-checker");

var _stackedChecker = require("../../../mixins/stacking/story-support/stacked-checker");

var _menu2 = _interopRequireDefault(require("./menu.mdx"));

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

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

var _default = {
  component: _menu.Menu,
  title: 'Components/Overlays/Menu',
  parameters: {
    docs: {
      page: _menu2["default"]
    }
  }
};
exports["default"] = _default;
var StyledBox = (0, _styledComponents["default"])(_box.Box).withConfig({
  displayName: "StyledBox",
  componentId: "lctfnk-0"
})(["background:", ";border:solid 2px ", ";border-radius:10px;color:", ";&:hover{background:", ";}"], (0, _branding.getPaletteColor)('background'), (0, _branding.getPaletteColor)('brand-secondary-fg'), (0, _branding.getPaletteColor)('brand-secondary-fg'), (0, _branding.getPaletteColor)('brand-secondary-bg'));

var CustomTrigger = function CustomTrigger(_ref) {
  var label = _ref.label;
  return /*#__PURE__*/_react["default"].createElement(StyledBox, {
    spacing: ['ph2', 'pv1']
  }, /*#__PURE__*/_react["default"].createElement(_span.Span, {
    bold: true
  }, label));
};
/**
 * Documentation stories:
 */


var InteractiveBasic = function InteractiveBasic() {
  var _useState = (0, _react.useState)(false),
      _useState2 = _slicedToArray(_useState, 2),
      isOpen = _useState2[0],
      setIsOpen = _useState2[1];

  return /*#__PURE__*/_react["default"].createElement(_menu.Menu, {
    label: "Basic menu",
    isOpen: isOpen,
    onToggle: function onToggle() {
      return setIsOpen(function (old) {
        return !old;
      });
    }
  }, /*#__PURE__*/_react["default"].createElement(_menuItem.MenuItem, {
    onClick: (0, _addonActions.action)('menu item 1 selected'),
    spacing: ['pv2', 'ph3']
  }, "Item 1"), /*#__PURE__*/_react["default"].createElement(_menuItem.MenuItem, {
    onClick: (0, _addonActions.action)('menu item 2 selected'),
    spacing: ['pv2', 'ph3']
  }, "Item 2"), /*#__PURE__*/_react["default"].createElement(_menuItem.MenuItem, {
    onClick: (0, _addonActions.action)('menu item 3 selected'),
    spacing: ['pv2', 'ph3']
  }, "Item 3"));
};

exports.InteractiveBasic = InteractiveBasic;

var InteractiveCustomized = function InteractiveCustomized() {
  var _useState3 = (0, _react.useState)(false),
      _useState4 = _slicedToArray(_useState3, 2),
      isOpen = _useState4[0],
      setIsOpen = _useState4[1];

  return /*#__PURE__*/_react["default"].createElement(_box.Box, {
    stacked: "column",
    align: "end"
  }, /*#__PURE__*/_react["default"].createElement(_menu.Menu, {
    label: "Customized Menu",
    TriggerComponent: CustomTrigger,
    isOpen: isOpen,
    onToggle: function onToggle() {
      return setIsOpen(function (old) {
        return !old;
      });
    },
    dropdownSpacing: ['pv1', 'mv1'],
    direction: "left"
  }, /*#__PURE__*/_react["default"].createElement(_menuItem.MenuItem, {
    onClick: (0, _addonActions.action)('menu item 1 selected'),
    spacing: ['pv2', 'ph3'],
    stacked: "row",
    align: "center",
    justify: "space-between"
  }, /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "mr2"
  }, /*#__PURE__*/_react["default"].createElement(_text.Text, {
    bold: true,
    spacing: "m0"
  }, "Complex Item 1"), /*#__PURE__*/_react["default"].createElement(_text.Text, {
    colorName: "greyscale-dark",
    spacing: "m0"
  }, "Here is a description of the item.")), /*#__PURE__*/_react["default"].createElement(_info.Info, null)), /*#__PURE__*/_react["default"].createElement(_menuItem.MenuItem, {
    onClick: (0, _addonActions.action)('menu item 2 selected'),
    spacing: ['pv2', 'ph3'],
    stacked: "row",
    align: "center",
    justify: "space-between"
  }, /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "mr2"
  }, /*#__PURE__*/_react["default"].createElement(_text.Text, {
    bold: true,
    spacing: "m0"
  }, "Complex Item 2"), /*#__PURE__*/_react["default"].createElement(_text.Text, {
    colorName: "greyscale-dark",
    spacing: "m0"
  }, "Here is a description of the item.")), /*#__PURE__*/_react["default"].createElement(_info.Info, null))));
};

exports.InteractiveCustomized = InteractiveCustomized;

var MixinsSpacing = function MixinsSpacing() {
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_marginChecker.MarginChecker, {
    Component: _menu.Menu,
    label: "Hello"
  }), /*#__PURE__*/_react["default"].createElement(_paddingChecker.PaddingChecker, {
    Component: _menu.Menu,
    label: "Hello"
  }));
};

exports.MixinsSpacing = MixinsSpacing;

var MixinsStackee = function MixinsStackee() {
  return /*#__PURE__*/_react["default"].createElement(_stackeeChecker.StackeeChecker, {
    Component: _menu.Menu,
    label: "Hello"
  });
};
/**
 * Structural tests (static renders for Chromatic).
 */


exports.MixinsStackee = MixinsStackee;

var OpenBasic = function OpenBasic() {
  return /*#__PURE__*/_react["default"].createElement(_menu.Menu, {
    label: "Menu",
    isOpen: true,
    onToggle: (0, _addonActions.action)('onToggle')
  }, /*#__PURE__*/_react["default"].createElement(_menuItem.MenuItem, {
    onClick: (0, _addonActions.action)('menu Item 1'),
    spacing: "p1"
  }, "Item 1"));
};

exports.OpenBasic = OpenBasic;

var ClosedBasic = function ClosedBasic() {
  return /*#__PURE__*/_react["default"].createElement(_menu.Menu, {
    label: "Menu",
    isOpen: false,
    onToggle: (0, _addonActions.action)('onToggle')
  }, /*#__PURE__*/_react["default"].createElement(_menuItem.MenuItem, {
    onClick: (0, _addonActions.action)('menu Item 1'),
    spacing: "p1"
  }, "Item 1"));
};

exports.ClosedBasic = ClosedBasic;

var OpenCustomTrigger = function OpenCustomTrigger() {
  return /*#__PURE__*/_react["default"].createElement(_menu.Menu, {
    label: "Menu",
    TriggerComponent: CustomTrigger,
    isOpen: true,
    onToggle: (0, _addonActions.action)('onToggle')
  }, /*#__PURE__*/_react["default"].createElement(_menuItem.MenuItem, {
    onClick: (0, _addonActions.action)('menu Item 1'),
    spacing: "p1"
  }, "Item 1"));
};

exports.OpenCustomTrigger = OpenCustomTrigger;

var OpenFlatTopCorners = function OpenFlatTopCorners() {
  return /*#__PURE__*/_react["default"].createElement(_menu.Menu, {
    label: "Menu",
    TriggerComponent: CustomTrigger,
    isOpen: true,
    onToggle: (0, _addonActions.action)('onToggle'),
    flatTopCorners: true
  }, /*#__PURE__*/_react["default"].createElement(_menuItem.MenuItem, {
    onClick: (0, _addonActions.action)('menu Item 1'),
    spacing: "p1"
  }, "Item 1"));
};

exports.OpenFlatTopCorners = OpenFlatTopCorners;

var ClosedCustomTrigger = function ClosedCustomTrigger() {
  return /*#__PURE__*/_react["default"].createElement(_menu.Menu, {
    label: "Menu",
    TriggerComponent: CustomTrigger,
    isOpen: false,
    onToggle: (0, _addonActions.action)('onToggle')
  }, /*#__PURE__*/_react["default"].createElement(_menuItem.MenuItem, {
    onClick: (0, _addonActions.action)('menu Item 1'),
    spacing: "p1"
  }, "Item 1"));
};

exports.ClosedCustomTrigger = ClosedCustomTrigger;

var OpenCustomItem = function OpenCustomItem() {
  return /*#__PURE__*/_react["default"].createElement(_menu.Menu, {
    label: "Menu",
    isOpen: true,
    onToggle: (0, _addonActions.action)('onToggle')
  }, /*#__PURE__*/_react["default"].createElement(_menuItem.MenuItem, {
    onClick: (0, _addonActions.action)('menu item 1 selected'),
    spacing: ['pv2', 'ph3'],
    stacked: "row",
    align: "center",
    justify: "space-between"
  }, /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "mr2"
  }, /*#__PURE__*/_react["default"].createElement(_text.Text, {
    bold: true,
    spacing: "m0"
  }, "Complex Item 1"), /*#__PURE__*/_react["default"].createElement(_text.Text, {
    colorName: "greyscale-dark",
    spacing: "m0"
  }, "Here is a description of the item.")), /*#__PURE__*/_react["default"].createElement(_info.Info, null)));
};

exports.OpenCustomItem = OpenCustomItem;

var ClosedCustomItem = function ClosedCustomItem() {
  return /*#__PURE__*/_react["default"].createElement(_menu.Menu, {
    label: "Menu",
    isOpen: false,
    onToggle: (0, _addonActions.action)('onToggle')
  }, /*#__PURE__*/_react["default"].createElement(_menuItem.MenuItem, {
    onClick: (0, _addonActions.action)('menu item 4 selected'),
    spacing: ['pv2', 'ph3'],
    stacked: "row",
    align: "center",
    justify: "space-between"
  }, /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "mr2"
  }, /*#__PURE__*/_react["default"].createElement(_text.Text, {
    bold: true,
    spacing: "m0"
  }, "Complex Item 1"), /*#__PURE__*/_react["default"].createElement(_text.Text, {
    colorName: "greyscale-dark",
    spacing: "m0"
  }, "Here is a description of the item.")), /*#__PURE__*/_react["default"].createElement(_info.Info, null)));
};

exports.ClosedCustomItem = ClosedCustomItem;

var MixinsMenuItemSpacing = function MixinsMenuItemSpacing() {
  return /*#__PURE__*/_react["default"].createElement(_menu.Menu, {
    isOpen: true,
    label: "Menu Items with Spacing",
    onToggle: (0, _addonActions.action)('onToggle')
  }, /*#__PURE__*/_react["default"].createElement(_marginChecker.MarginChecker, {
    Component: _menuItem.MenuItem
  }, "Menu Item"), /*#__PURE__*/_react["default"].createElement(_paddingChecker.PaddingChecker, {
    Component: _menuItem.MenuItem
  }, "Menu Item"));
};

exports.MixinsMenuItemSpacing = MixinsMenuItemSpacing;

var MixinsMenuItemStacked = function MixinsMenuItemStacked() {
  return /*#__PURE__*/_react["default"].createElement(_menu.Menu, {
    isOpen: true,
    label: "Menu Items with Stacking",
    onToggle: (0, _addonActions.action)('onToggle')
  }, /*#__PURE__*/_react["default"].createElement(_stackedChecker.StackedChecker, {
    Component: _menuItem.MenuItem
  }));
};

exports.MixinsMenuItemStacked = MixinsMenuItemStacked;