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