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; }
import React, { useState } from 'react';
import MD from 'react-markdown';
import styled from 'styled-components';
import { action } from '@storybook/addon-actions';
import { Provider } from '../../../../common/Links/ReactRouterLinkHelper';
import docs from './PillButton.md';
import { Flexbox, Typography, Icon, PillButton } from '../../../..';
import { Display } from '../../../../common/Display';
export default {
  title: 'DEPRECATED / Molecules / PillButton (use Button.Pill instead)',
  parameters: {
    component: PillButton
  }
};
var SecondaryBackground = styled.div.withConfig({
  displayName: "PillButtonstories__SecondaryBackground",
  componentId: "sc-jn6dsi-0"
})(["background:white;padding:", "px;"], function (p) {
  return p.theme.spacing.unit(3);
});
var NoPadding = styled.div.withConfig({
  displayName: "PillButtonstories__NoPadding",
  componentId: "sc-jn6dsi-1"
})(["background:red;"]);
export var Documentation = function Documentation() {
  return React.createElement(Typography, {
    type: "primary"
  }, React.createElement(MD, null, docs));
};
export var DefaultUsage = {
  render: function render() {
    return React.createElement(PillButton, {
      onClick: action('clicked')
    }, "PillButton");
  },
  name: 'Default usage'
};
export var PillButtonWithDifferentVariants = function PillButtonWithDifferentVariants() {
  return React.createElement(React.Fragment, null, React.createElement(Display, {
    horizontal: true,
    title: "Primary",
    items: [{
      title: 'Default',
      component: React.createElement(PillButton, {
        onClick: action('clicked')
      }, "Button")
    }, {
      title: 'Icon Left',
      component: React.createElement(PillButton, {
        icon: React.createElement(Icon.Add16, {
          color: "currentColor"
        }),
        onClick: action('clicked')
      }, "Button")
    }, {
      title: 'Icon Right',
      component: React.createElement(PillButton, {
        icon: React.createElement(Icon.ExternalLink16, {
          color: "currentColor"
        }),
        iconPlacement: "right",
        onClick: action('clicked')
      }, "Button")
    }]
  }), React.createElement(Display, {
    horizontal: true,
    items: [{
      title: 'Default Disabled',
      component: React.createElement(PillButton, {
        onClick: action('clicked'),
        disabled: true
      }, "Button")
    }, {
      title: 'Icon Left Disabled',
      component: React.createElement(PillButton, {
        icon: React.createElement(Icon.Add16, {
          color: "currentColor"
        }),
        onClick: action('clicked'),
        disabled: true
      }, "Button")
    }, {
      title: 'Icon Right Disabled',
      component: React.createElement(PillButton, {
        icon: React.createElement(Icon.ExternalLink16, {
          color: "currentColor"
        }),
        iconPlacement: "right",
        onClick: action('clicked'),
        disabled: true
      }, "Button")
    }]
  }), React.createElement(Display, {
    horizontal: true,
    items: [{
      title: 'Default Loading',
      component: React.createElement(PillButton, {
        onClick: action('clicked'),
        loading: true
      }, "Button")
    }, {
      title: 'Icon Left Loading',
      component: React.createElement(PillButton, {
        icon: React.createElement(Icon.Add16, {
          color: "currentColor"
        }),
        onClick: action('clicked'),
        loading: true
      }, "Button")
    }, {
      title: 'Icon Right Loading',
      component: React.createElement(PillButton, {
        icon: React.createElement(Icon.ExternalLink16, {
          color: "currentColor"
        }),
        iconPlacement: "right",
        onClick: action('clicked'),
        loading: true
      }, "Button")
    }]
  }), React.createElement(Display, {
    horizontal: true,
    title: "Secondary",
    items: [{
      title: 'Default',
      component: React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
        variant: "secondary",
        onClick: action('clicked')
      }, "Button"))
    }, {
      title: 'Icon Left',
      component: React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
        variant: "secondary",
        icon: React.createElement(Icon.Add16, {
          color: "currentColor"
        }),
        onClick: action('clicked')
      }, "Button"))
    }, {
      title: 'Icon Right',
      component: React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
        variant: "secondary",
        icon: React.createElement(Icon.ExternalLink16, {
          color: "currentColor"
        }),
        iconPlacement: "right",
        onClick: action('clicked')
      }, "Button"))
    }]
  }), React.createElement(Display, {
    horizontal: true,
    items: [{
      title: 'Default Disabled',
      component: React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
        variant: "secondary",
        onClick: action('clicked'),
        disabled: true
      }, "Button"))
    }, {
      title: 'Icon Left Disabled',
      component: React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
        variant: "secondary",
        icon: React.createElement(Icon.Add16, {
          color: "currentColor"
        }),
        onClick: action('clicked'),
        disabled: true
      }, "Button"))
    }, {
      title: 'Icon Right Disabled',
      component: React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
        variant: "secondary",
        icon: React.createElement(Icon.ExternalLink16, {
          color: "currentColor"
        }),
        iconPlacement: "right",
        onClick: action('clicked'),
        disabled: true
      }, "Button"))
    }]
  }), React.createElement(Display, {
    horizontal: true,
    items: [{
      title: 'Default Loading',
      component: React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
        variant: "secondary",
        onClick: action('clicked'),
        loading: true
      }, "Button"))
    }, {
      title: 'Icon Left Loading',
      component: React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
        variant: "secondary",
        icon: React.createElement(Icon.Add16, {
          color: "currentColor"
        }),
        onClick: action('clicked'),
        loading: true
      }, "Button"))
    }, {
      title: 'Icon Right Loading',
      component: React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
        variant: "secondary",
        icon: React.createElement(Icon.ExternalLink16, {
          color: "currentColor"
        }),
        iconPlacement: "right",
        onClick: action('clicked'),
        loading: true
      }, "Button"))
    }]
  }));
};
export var PillButtonWithLoadingState = {
  render: function render() {
    var LoadingExample = function LoadingExample() {
      var _useState = useState(true),
        _useState2 = _slicedToArray(_useState, 2),
        loading = _useState2[0],
        setLoading = _useState2[1];
      var toggleLoading = function toggleLoading() {
        return setLoading(!loading);
      };
      return React.createElement(React.Fragment, null, React.createElement(Display, {
        title: "Primary",
        items: [{
          title: 'PillButton',
          component: React.createElement(PillButton, {
            loading: loading
          }, "Button")
        }]
      }), React.createElement(Display, {
        title: "Secondary",
        items: [{
          title: 'PillButton',
          component: React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
            variant: "secondary",
            loading: loading
          }, "Button"))
        }]
      }), React.createElement("button", {
        type: "button",
        onClick: toggleLoading
      }, "toggle loading"));
    };
    return React.createElement(LoadingExample, null);
  },
  name: 'PillButton with loading state'
};
export var PillButtonWithLoadingStateWithoutTheSpinnerAnimationDelay = {
  render: function render() {
    return React.createElement(PillButton, {
      onClick: action('clicked'),
      loading: true,
      delayLoadingSpinnerAnimation: false
    }, "Button");
  },
  name: 'PillButton with loading state without the spinner animation delay'
};
export var PillButtonThatIsFullWidth = {
  render: function render() {
    return React.createElement(NoPadding, null, React.createElement(PillButton, {
      onClick: action('clicked'),
      fullWidth: true
    }, "Button"), React.createElement(PillButton, {
      variant: "secondary",
      onClick: action('clicked'),
      fullWidth: true
    }, "Button"));
  },
  name: 'PillButton that is full width'
};
export var PillButtonsComposedInAGroup = {
  render: function render() {
    return React.createElement(Flexbox, {
      container: true,
      gap: 2
    }, React.createElement(Flexbox, {
      item: true,
      flex: "1 1 50%"
    }, React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
      onClick: action('submit'),
      fullWidth: true
    }, "Submit"))), React.createElement(Flexbox, {
      item: true,
      flex: "1 1 50%"
    }, React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
      onClick: action('reset'),
      variant: "secondary",
      fullWidth: true
    }, "Reset"))));
  },
  name: 'PillButtons composed in a group'
};
export var LinksLookingLikePillButtons = {
  render: function render() {
    return React.createElement(Provider, null, React.createElement(Display, {
      items: [{
        title: 'Go to BlaBla',
        component: React.createElement(PillButton, {
          to: "/?path=/docs/molecules-pillbutton--pill-buttons-composed-in-a-group"
        }, "BlaBla")
      }, {
        title: 'Go to external BliBli',
        component: React.createElement(SecondaryBackground, null, React.createElement(PillButton, {
          to: "https://nordnet.se",
          external: true,
          variant: "secondary"
        }, "BliBli"))
      }]
    }));
  },
  name: 'Links looking like PillButtons'
};