"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.PillButtonsComposedInAGroup = exports.PillButtonWithLoadingStateWithoutTheSpinnerAnimationDelay = exports.PillButtonWithLoadingState = exports.PillButtonWithDifferentVariants = exports.PillButtonThatIsFullWidth = exports.LinksLookingLikePillButtons = exports.Documentation = exports.DefaultUsage = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactMarkdown = _interopRequireDefault(require("react-markdown"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _addonActions = require("@storybook/addon-actions");
var _ReactRouterLinkHelper = require("../../../../common/Links/ReactRouterLinkHelper");
var _PillButton = _interopRequireDefault(require("./PillButton.md"));
var _ = require("../../../..");
var _Display = require("../../../../common/Display");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
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(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var _default = exports.default = {
  title: 'DEPRECATED / Molecules / PillButton (use Button.Pill instead)',
  parameters: {
    component: _.PillButton
  }
};
var SecondaryBackground = _styledComponents.default.div.withConfig({
  displayName: "PillButtonstories__SecondaryBackground",
  componentId: "sc-jn6dsi-0"
})(["background:white;padding:", "px;"], function (p) {
  return p.theme.spacing.unit(3);
});
var NoPadding = _styledComponents.default.div.withConfig({
  displayName: "PillButtonstories__NoPadding",
  componentId: "sc-jn6dsi-1"
})(["background:red;"]);
var Documentation = exports.Documentation = function Documentation() {
  return _react.default.createElement(_.Typography, {
    type: "primary"
  }, _react.default.createElement(_reactMarkdown.default, null, _PillButton.default));
};
var DefaultUsage = exports.DefaultUsage = {
  render: function render() {
    return _react.default.createElement(_.PillButton, {
      onClick: (0, _addonActions.action)('clicked')
    }, "PillButton");
  },
  name: 'Default usage'
};
var PillButtonWithDifferentVariants = exports.PillButtonWithDifferentVariants = function PillButtonWithDifferentVariants() {
  return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_Display.Display, {
    horizontal: true,
    title: "Primary",
    items: [{
      title: 'Default',
      component: _react.default.createElement(_.PillButton, {
        onClick: (0, _addonActions.action)('clicked')
      }, "Button")
    }, {
      title: 'Icon Left',
      component: _react.default.createElement(_.PillButton, {
        icon: _react.default.createElement(_.Icon.Add16, {
          color: "currentColor"
        }),
        onClick: (0, _addonActions.action)('clicked')
      }, "Button")
    }, {
      title: 'Icon Right',
      component: _react.default.createElement(_.PillButton, {
        icon: _react.default.createElement(_.Icon.ExternalLink16, {
          color: "currentColor"
        }),
        iconPlacement: "right",
        onClick: (0, _addonActions.action)('clicked')
      }, "Button")
    }]
  }), _react.default.createElement(_Display.Display, {
    horizontal: true,
    items: [{
      title: 'Default Disabled',
      component: _react.default.createElement(_.PillButton, {
        onClick: (0, _addonActions.action)('clicked'),
        disabled: true
      }, "Button")
    }, {
      title: 'Icon Left Disabled',
      component: _react.default.createElement(_.PillButton, {
        icon: _react.default.createElement(_.Icon.Add16, {
          color: "currentColor"
        }),
        onClick: (0, _addonActions.action)('clicked'),
        disabled: true
      }, "Button")
    }, {
      title: 'Icon Right Disabled',
      component: _react.default.createElement(_.PillButton, {
        icon: _react.default.createElement(_.Icon.ExternalLink16, {
          color: "currentColor"
        }),
        iconPlacement: "right",
        onClick: (0, _addonActions.action)('clicked'),
        disabled: true
      }, "Button")
    }]
  }), _react.default.createElement(_Display.Display, {
    horizontal: true,
    items: [{
      title: 'Default Loading',
      component: _react.default.createElement(_.PillButton, {
        onClick: (0, _addonActions.action)('clicked'),
        loading: true
      }, "Button")
    }, {
      title: 'Icon Left Loading',
      component: _react.default.createElement(_.PillButton, {
        icon: _react.default.createElement(_.Icon.Add16, {
          color: "currentColor"
        }),
        onClick: (0, _addonActions.action)('clicked'),
        loading: true
      }, "Button")
    }, {
      title: 'Icon Right Loading',
      component: _react.default.createElement(_.PillButton, {
        icon: _react.default.createElement(_.Icon.ExternalLink16, {
          color: "currentColor"
        }),
        iconPlacement: "right",
        onClick: (0, _addonActions.action)('clicked'),
        loading: true
      }, "Button")
    }]
  }), _react.default.createElement(_Display.Display, {
    horizontal: true,
    title: "Secondary",
    items: [{
      title: 'Default',
      component: _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
        variant: "secondary",
        onClick: (0, _addonActions.action)('clicked')
      }, "Button"))
    }, {
      title: 'Icon Left',
      component: _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
        variant: "secondary",
        icon: _react.default.createElement(_.Icon.Add16, {
          color: "currentColor"
        }),
        onClick: (0, _addonActions.action)('clicked')
      }, "Button"))
    }, {
      title: 'Icon Right',
      component: _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
        variant: "secondary",
        icon: _react.default.createElement(_.Icon.ExternalLink16, {
          color: "currentColor"
        }),
        iconPlacement: "right",
        onClick: (0, _addonActions.action)('clicked')
      }, "Button"))
    }]
  }), _react.default.createElement(_Display.Display, {
    horizontal: true,
    items: [{
      title: 'Default Disabled',
      component: _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
        variant: "secondary",
        onClick: (0, _addonActions.action)('clicked'),
        disabled: true
      }, "Button"))
    }, {
      title: 'Icon Left Disabled',
      component: _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
        variant: "secondary",
        icon: _react.default.createElement(_.Icon.Add16, {
          color: "currentColor"
        }),
        onClick: (0, _addonActions.action)('clicked'),
        disabled: true
      }, "Button"))
    }, {
      title: 'Icon Right Disabled',
      component: _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
        variant: "secondary",
        icon: _react.default.createElement(_.Icon.ExternalLink16, {
          color: "currentColor"
        }),
        iconPlacement: "right",
        onClick: (0, _addonActions.action)('clicked'),
        disabled: true
      }, "Button"))
    }]
  }), _react.default.createElement(_Display.Display, {
    horizontal: true,
    items: [{
      title: 'Default Loading',
      component: _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
        variant: "secondary",
        onClick: (0, _addonActions.action)('clicked'),
        loading: true
      }, "Button"))
    }, {
      title: 'Icon Left Loading',
      component: _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
        variant: "secondary",
        icon: _react.default.createElement(_.Icon.Add16, {
          color: "currentColor"
        }),
        onClick: (0, _addonActions.action)('clicked'),
        loading: true
      }, "Button"))
    }, {
      title: 'Icon Right Loading',
      component: _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
        variant: "secondary",
        icon: _react.default.createElement(_.Icon.ExternalLink16, {
          color: "currentColor"
        }),
        iconPlacement: "right",
        onClick: (0, _addonActions.action)('clicked'),
        loading: true
      }, "Button"))
    }]
  }));
};
var PillButtonWithLoadingState = exports.PillButtonWithLoadingState = {
  render: function render() {
    var LoadingExample = function LoadingExample() {
      var _useState = (0, _react.useState)(true),
        _useState2 = _slicedToArray(_useState, 2),
        loading = _useState2[0],
        setLoading = _useState2[1];
      var toggleLoading = function toggleLoading() {
        return setLoading(!loading);
      };
      return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_Display.Display, {
        title: "Primary",
        items: [{
          title: 'PillButton',
          component: _react.default.createElement(_.PillButton, {
            loading: loading
          }, "Button")
        }]
      }), _react.default.createElement(_Display.Display, {
        title: "Secondary",
        items: [{
          title: 'PillButton',
          component: _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
            variant: "secondary",
            loading: loading
          }, "Button"))
        }]
      }), _react.default.createElement("button", {
        type: "button",
        onClick: toggleLoading
      }, "toggle loading"));
    };
    return _react.default.createElement(LoadingExample, null);
  },
  name: 'PillButton with loading state'
};
var PillButtonWithLoadingStateWithoutTheSpinnerAnimationDelay = exports.PillButtonWithLoadingStateWithoutTheSpinnerAnimationDelay = {
  render: function render() {
    return _react.default.createElement(_.PillButton, {
      onClick: (0, _addonActions.action)('clicked'),
      loading: true,
      delayLoadingSpinnerAnimation: false
    }, "Button");
  },
  name: 'PillButton with loading state without the spinner animation delay'
};
var PillButtonThatIsFullWidth = exports.PillButtonThatIsFullWidth = {
  render: function render() {
    return _react.default.createElement(NoPadding, null, _react.default.createElement(_.PillButton, {
      onClick: (0, _addonActions.action)('clicked'),
      fullWidth: true
    }, "Button"), _react.default.createElement(_.PillButton, {
      variant: "secondary",
      onClick: (0, _addonActions.action)('clicked'),
      fullWidth: true
    }, "Button"));
  },
  name: 'PillButton that is full width'
};
var PillButtonsComposedInAGroup = exports.PillButtonsComposedInAGroup = {
  render: function render() {
    return _react.default.createElement(_.Flexbox, {
      container: true,
      gap: 2
    }, _react.default.createElement(_.Flexbox, {
      item: true,
      flex: "1 1 50%"
    }, _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
      onClick: (0, _addonActions.action)('submit'),
      fullWidth: true
    }, "Submit"))), _react.default.createElement(_.Flexbox, {
      item: true,
      flex: "1 1 50%"
    }, _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
      onClick: (0, _addonActions.action)('reset'),
      variant: "secondary",
      fullWidth: true
    }, "Reset"))));
  },
  name: 'PillButtons composed in a group'
};
var LinksLookingLikePillButtons = exports.LinksLookingLikePillButtons = {
  render: function render() {
    return _react.default.createElement(_ReactRouterLinkHelper.Provider, null, _react.default.createElement(_Display.Display, {
      items: [{
        title: 'Go to BlaBla',
        component: _react.default.createElement(_.PillButton, {
          to: "/?path=/docs/molecules-pillbutton--pill-buttons-composed-in-a-group"
        }, "BlaBla")
      }, {
        title: 'Go to external BliBli',
        component: _react.default.createElement(SecondaryBackground, null, _react.default.createElement(_.PillButton, {
          to: "https://nordnet.se",
          external: true,
          variant: "secondary"
        }, "BliBli"))
      }]
    }));
  },
  name: 'Links looking like PillButtons'
};