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, { useRef, useState } from 'react';
import { action } from '@storybook/addon-actions';
import MD from 'react-markdown';
import docs from './Button.md';
import { Button, Flexbox, Typography } from '../../../..';
import { Display } from '../../../../common/Display';
export default {
  title: 'Molecules / Button / Button',
  parameters: {
    component: Button
  }
};
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(Button, {
      onClick: action('clicked')
    }, "Button");
  },
  name: 'Default usage'
};
export var ButtonWithDifferentVariants = {
  render: function render() {
    return React.createElement(React.Fragment, null, React.createElement(Display, {
      horizontal: true,
      items: [{
        title: 'primary',
        component: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "primary"
        }, "Button")
      }, {
        title: 'secondary',
        component: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "secondary"
        }, "Button")
      }, {
        title: 'neutral',
        component: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "neutral"
        }, "Button")
      }, {
        title: 'negative',
        component: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "negative"
        }, "Button")
      }]
    }), React.createElement(Display, {
      horizontal: true,
      items: [{
        title: 'primary - disabled',
        component: React.createElement(Button, {
          disabled: true,
          onClick: action('clicked'),
          variant: "primary"
        }, "Button")
      }, {
        title: 'secondary - disabled',
        component: React.createElement(Button, {
          disabled: true,
          onClick: action('clicked'),
          variant: "secondary"
        }, "Button")
      }, {
        title: 'neutral - disabled',
        component: React.createElement(Button, {
          disabled: true,
          onClick: action('clicked'),
          variant: "neutral"
        }, "Button")
      }]
    }));
  },
  name: 'Button with different variants'
};
export var DisabledButtonWithDifferentVariants = {
  render: function render() {
    return React.createElement(Display, {
      horizontal: true,
      items: [{
        title: 'primary',
        component: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "primary",
          disabled: true
        }, "Button")
      }, {
        title: 'secondary',
        component: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "secondary",
          disabled: true
        }, "Button")
      }, {
        title: 'neutral',
        component: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "neutral",
          disabled: true
        }, "Button")
      }, {
        title: 'negative',
        component: React.createElement(Button, {
          onClick: action('clicked'),
          variant: "negative",
          disabled: true
        }, "Button")
      }]
    });
  },
  name: 'Disabled Button with different variants'
};
export var ButtonPrimaryWithColors = {
  render: function render() {
    return React.createElement(Display, {
      horizontal: true,
      items: [{
        title: 't => t.color.cta',
        component: React.createElement(Button, {
          variant: "primary",
          color: function color(t) {
            return t.color.cta;
          },
          onClick: action('clicked')
        }, "Button")
      }, {
        title: 't => t.color.negative',
        component: React.createElement(Button, {
          variant: "primary",
          color: function color(t) {
            return t.color.negative;
          },
          onClick: action('clicked')
        }, "Button")
      }, {
        title: 't => t.color.error',
        component: React.createElement(Button, {
          variant: "primary",
          color: function color(t) {
            return t.color.error;
          },
          onClick: action('clicked')
        }, "Button")
      }]
    });
  },
  name: 'Button primary with colors'
};
export var ButtonSecondaryWithColors = {
  render: function render() {
    return React.createElement(Display, {
      horizontal: true,
      items: [{
        title: 't => t.color.cta',
        component: React.createElement(Button, {
          variant: "secondary",
          color: function color(t) {
            return t.color.cta;
          },
          onClick: action('clicked')
        }, "Button")
      }, {
        title: 't => t.color.negative',
        component: React.createElement(Button, {
          variant: "secondary",
          color: function color(t) {
            return t.color.negative;
          },
          onClick: action('clicked')
        }, "Button")
      }]
    });
  },
  name: 'Button secondary with colors'
};
export var ButtonWithSizeModified = {
  render: function render() {
    return React.createElement(React.Fragment, null, React.createElement(Display, {
      title: "Primary",
      horizontal: true,
      items: [{
        title: 'Medium',
        component: React.createElement(Button, {
          size: "m",
          onClick: action('clickMedium')
        }, "Medium")
      }, {
        title: 'Large',
        component: React.createElement(Button, {
          size: "l",
          onClick: action('clickLarge')
        }, "Large")
      }]
    }), React.createElement(Display, {
      title: "Secondary",
      horizontal: true,
      items: [{
        title: 'Medium',
        component: React.createElement(Button, {
          size: "m",
          variant: "secondary",
          onClick: action('clickMedium')
        }, "Medium")
      }, {
        title: 'Large',
        component: React.createElement(Button, {
          size: "l",
          variant: "secondary",
          onClick: action('clickLarge')
        }, "Large")
      }]
    }));
  },
  name: 'Button with size modified'
};
export var ButtonWithFocusOn = {
  render: function render() {
    var FocusExample = function FocusExample() {
      var ref = useRef(null);
      var handleFocus = function handleFocus() {
        if (ref.current !== null) {
          ref.current.focus();
        }
      };
      return React.createElement(Flexbox, {
        container: true,
        gap: 5
      }, React.createElement(Flexbox, {
        item: true
      }, React.createElement(Button, {
        onClick: handleFocus
      }, "Click to focus")), React.createElement(Flexbox, {
        item: true
      }, React.createElement(Button, {
        color: function color(t) {
          return t.color.negative;
        },
        ref: ref
      }, "Focus me")));
    };
    return React.createElement(FocusExample, null);
  },
  name: 'Button which sets focus on another button'
};
export var ButtonWithLoadingState = {
  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",
        horizontal: true,
        items: [{
          title: 'Medium',
          component: React.createElement(Button, {
            size: "m",
            loading: loading
          }, "Medium")
        }, {
          title: 'Large',
          component: React.createElement(Button, {
            size: "l",
            loading: loading
          }, "Large")
        }]
      }), React.createElement(Display, {
        title: "Primary with custom color",
        horizontal: true,
        items: [{
          title: 'Medium',
          component: React.createElement(Button, {
            size: "m",
            color: function color(t) {
              return t.color.negative;
            },
            loading: loading
          }, "Medium")
        }, {
          title: 'Large',
          component: React.createElement(Button, {
            size: "l",
            color: function color(t) {
              return t.color.negative;
            },
            loading: loading
          }, "Large")
        }]
      }), React.createElement(Display, {
        title: "Secondary",
        horizontal: true,
        items: [{
          title: 'Medium',
          component: React.createElement(Button, {
            size: "m",
            variant: "secondary",
            loading: loading
          }, "Medium")
        }, {
          title: 'Large',
          component: React.createElement(Button, {
            size: "l",
            variant: "secondary",
            loading: loading
          }, "Large")
        }]
      }), React.createElement(Display, {
        title: "Secondary with custom color",
        horizontal: true,
        items: [{
          title: 'Medium',
          component: React.createElement(Button, {
            size: "m",
            variant: "secondary",
            color: function color(t) {
              return t.color.negative;
            },
            loading: loading
          }, "Medium")
        }, {
          title: 'Large',
          component: React.createElement(Button, {
            size: "l",
            variant: "secondary",
            color: function color(t) {
              return t.color.negative;
            },
            loading: loading
          }, "Large")
        }]
      }), React.createElement("button", {
        type: "button",
        onClick: toggleLoading
      }, "toggle loading"));
    };
    return React.createElement(LoadingExample, null);
  },
  name: 'Button with loading state'
};
export var ButtonWithLoadingStateWithCustomSpinnerAnimationDelay = {
  render: function render() {
    return React.createElement(Button, {
      onClick: action('clicked'),
      loading: true,
      delayLoadingSpinnerAnimation: 400
    }, "Button");
  },
  name: 'Button with loading state with custom spinner animation delay'
};
export var ButtonWithLoadingStateWithoutTheSpinnerAnimationDelay = {
  render: function render() {
    return React.createElement(Button, {
      onClick: action('clicked'),
      loading: true,
      delayLoadingSpinnerAnimation: false
    }, "Button");
  },
  name: 'Button with loading state without the spinner animation delay'
};
export var ButtonWithTypeModified = {
  render: function render() {
    return React.createElement(Display, {
      items: [{
        title: 'Reset',
        component: React.createElement(Button, {
          type: "reset",
          onClick: action('reset')
        }, "Reset")
      }, {
        title: 'Submit',
        component: React.createElement(Button, {
          type: "submit",
          onClick: action('submit')
        }, "Submit")
      }]
    });
  },
  name: 'Button with type modified'
};
export var ButtonThatIsFullWidth = {
  render: function render() {
    return React.createElement(Button, {
      onClick: action('clicked'),
      fullWidth: true
    }, "Button");
  },
  name: 'Button that is full width'
};
export var ButtonsComposedInAGroup = {
  render: function render() {
    return React.createElement(Flexbox, {
      container: true,
      gap: 2
    }, React.createElement(Flexbox, {
      item: true,
      flex: "1 1 50%"
    }, React.createElement(Button, {
      type: "submit",
      onClick: action('submit'),
      fullWidth: true
    }, "Submit")), React.createElement(Flexbox, {
      item: true,
      flex: "1 1 50%"
    }, React.createElement(Button, {
      type: "reset",
      onClick: action('reset'),
      variant: "secondary",
      fullWidth: true
    }, "Reset")));
  },
  name: 'Buttons composed in a group'
};