"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.MultipleChildren = exports.WithContext = exports.AlternateHeading = exports.CustomButtonStyles = exports.OpenByDefault = exports.Default = exports["default"] = void 0;

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

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

var _index = require("./index");

var _expander = _interopRequireDefault(require("./expander.mdx"));

var _typography = require("../../typography");

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

var _actions = require("../../actions");

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 _extends() { _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; }; return _extends.apply(this, arguments); }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var _default = {
  component: _index.Expander,
  title: 'Expander',
  parameters: {
    fileName: __filename,
    docs: {
      page: _expander["default"]
    }
  }
};
exports["default"] = _default;
var DEFAULT_PROPS = {
  onToggle: (0, _addonActions.action)('is open'),
  headingComponent: /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "p1",
    colorName: "brand-secondary-bg"
  }, /*#__PURE__*/_react["default"].createElement(_typography.Span, {
    colorName: "brand-secondary-fg",
    bold: true
  }, "I am a toggle"))
};

var Default = function Default() {
  var demoProps = {
    headingComponent: /*#__PURE__*/_react["default"].createElement(_box.Box, {
      spacing: ['mb1', 'ph1']
    }, /*#__PURE__*/_react["default"].createElement(_typography.Span, {
      colorName: "brand-primary-base",
      bold: true
    }, "I am a toggle"))
  };
  return /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "ph2"
  }, /*#__PURE__*/_react["default"].createElement(_index.Expander, _objectSpread(_objectSpread({}, DEFAULT_PROPS), demoProps), /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: ['pv3']
  }, "Something amazing I guess")));
};

exports.Default = Default;

var OpenByDefault = function OpenByDefault() {
  return /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "ph2"
  }, /*#__PURE__*/_react["default"].createElement(_index.Expander, _extends({}, DEFAULT_PROPS, {
    isOpen: true
  }), /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: ['pv3']
  }, "Already open!")));
};

exports.OpenByDefault = OpenByDefault;

var CustomButtonStyles = function CustomButtonStyles() {
  return /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "p2",
    colorName: "background"
  }, /*#__PURE__*/_react["default"].createElement(_index.Expander, _extends({}, DEFAULT_PROPS, {
    buttonStyles: {
      width: '100%'
    }
  }), /*#__PURE__*/_react["default"].createElement(_box.Box, {
    colorName: "white",
    spacing: "p2"
  }, "Something amazing I guess")));
};

exports.CustomButtonStyles = CustomButtonStyles;

var AlternateHeading = function AlternateHeading() {
  var demoProps = {
    buttonStyles: {
      boxShadow: 'none'
    },
    headingComponent: /*#__PURE__*/_react["default"].createElement(_typography.Span, {
      colorName: "brand-primary-base",
      bold: true
    }, "Show more"),
    headingComponentOpen: /*#__PURE__*/_react["default"].createElement(_typography.Span, {
      colorName: "brand-secondary-base"
    }, "Show less")
  };
  return /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "p2",
    colorName: "background"
  }, /*#__PURE__*/_react["default"].createElement(_index.Expander, _objectSpread(_objectSpread({}, DEFAULT_PROPS), demoProps), /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "mt3"
  }, "Something amazing I guess")));
};

exports.AlternateHeading = AlternateHeading;

var DemoWithContext = function DemoWithContext() {
  var _useContext = (0, _react.useContext)(_index.ExpanderContext),
      toggleExpander = _useContext.toggleExpander;

  return /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: ['pv3']
  }, /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "mb3"
  }, "Something amazing I guess"), /*#__PURE__*/_react["default"].createElement(_actions.Button, {
    onClick: toggleExpander
  }, "I am a child component accessing the Expander context"));
};

var WithContext = function WithContext() {
  return /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "ph2"
  }, /*#__PURE__*/_react["default"].createElement(_index.Expander, DEFAULT_PROPS, /*#__PURE__*/_react["default"].createElement(DemoWithContext, null)));
};

exports.WithContext = WithContext;

var MultipleChildren = function MultipleChildren() {
  return /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "p2",
    colorName: "background"
  }, /*#__PURE__*/_react["default"].createElement(_index.Expander, DEFAULT_PROPS, /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "mt3"
  }, "Something amazing"), /*#__PURE__*/_react["default"].createElement(_box.Box, {
    spacing: "mt3"
  }, "I guess")));
};

exports.MultipleChildren = MultipleChildren;