"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.ZindexWars = exports.WrapChild = exports.WithVeryLongWord = exports.WithPosition = exports.WithOffsetAsAFunction = exports.WithOffset = exports.WithMode = exports.WithClickableContent = exports.StyledPopOver = exports.InvertedColorsStory = exports.DefaultStory = exports.CustomMaxWidth = exports.CustomBoundary = exports.ControlledOpen = exports.BrokenPositioning = exports.BottomSheetNotControlled = exports.BottomSheetInvertedColors = exports.BottomSheet = void 0;
var _react = _interopRequireWildcard(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _ = require("../..");
var _2 = _interopRequireDefault(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 / Tooltip',
  parameters: {
    component: _2.default
  }
};
var label = 'Information in a Tooltip should not be vital for the user to complete a task';
var Button = _styledComponents.default.button.withConfig({
  displayName: "Tooltipstories__Button",
  componentId: "sc-j9k610-0"
})(["display:block;"]);
var StyledDiv = _styledComponents.default.div.withConfig({
  displayName: "Tooltipstories__StyledDiv",
  componentId: "sc-j9k610-1"
})(["margin:20px 0 20px 20px;"]);
var DefaultStory = exports.DefaultStory = {
  render: function render() {
    return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(StyledDiv, null, "Default delays", _react.default.createElement(_2.default, {
      label: label,
      position: "top"
    }, _react.default.createElement(Button, {
      type: "button"
    }, "Hover me"))), _react.default.createElement(StyledDiv, null, "Open delay: 2000ms; Close delay: 3000ms", _react.default.createElement(_2.default, {
      label: label,
      position: "top",
      openDelay: 2000,
      closeDelay: 3000
    }, _react.default.createElement(Button, {
      type: "button"
    }, "Hover me"))), _react.default.createElement(StyledDiv, null, "Open delay: 10ms; Close delay: 10ms", _react.default.createElement(_2.default, {
      label: label,
      position: "top",
      openDelay: 10,
      closeDelay: 10
    }, _react.default.createElement(Button, {
      type: "button"
    }, "Hover me"))), _react.default.createElement(StyledDiv, null, "Open delay: 0ms; Close delay: 0ms", _react.default.createElement(_2.default, {
      label: label,
      position: "top",
      openDelay: 0,
      closeDelay: 0
    }, _react.default.createElement(Button, {
      type: "button"
    }, "Hover me"))));
  },
  name: 'Default'
};
var InvertedColorsStory = exports.InvertedColorsStory = {
  render: function render() {
    return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(StyledDiv, null, "Inverted colors", _react.default.createElement(_2.default, {
      label: "inverted label",
      position: "top",
      invertedColors: true
    }, _react.default.createElement(Button, {
      type: "button"
    }, "Hover me"))));
  },
  name: 'Inverted colors'
};
var WithMode = exports.WithMode = {
  render: function render() {
    return _react.default.createElement(_2.default, {
      label: label,
      mode: "click"
    }, _react.default.createElement(Button, {
      type: "button"
    }, "Click me"));
  },
  name: 'With On Click Mode'
};
var veryLongLabel = 'Llanfairpwllgwyngyllgogerychwyrndrob';
var WithVeryLongWord = exports.WithVeryLongWord = {
  render: function render() {
    return _react.default.createElement(_2.default, {
      label: veryLongLabel
    }, _react.default.createElement(Button, {
      type: "button"
    }, "Hover me"));
  }
};
var WithPosition = exports.WithPosition = {
  render: function render() {
    return _react.default.createElement(_Display.Display, {
      items: [{
        component: _react.default.createElement(_2.default, {
          label: label,
          position: "bottom"
        }, _react.default.createElement(Button, {
          type: "button"
        }, "Hover me")),
        title: 'bottom'
      }, {
        component: _react.default.createElement(_2.default, {
          label: label,
          position: "left"
        }, _react.default.createElement(Button, {
          type: "button"
        }, "Hover me")),
        title: 'left'
      }, {
        component: _react.default.createElement(_2.default, {
          label: label,
          position: "top"
        }, _react.default.createElement(Button, {
          type: "button"
        }, "Hover me")),
        title: 'top'
      }, {
        component: _react.default.createElement(_2.default, {
          label: label,
          position: "right"
        }, _react.default.createElement(Button, {
          type: "button"
        }, "Hover me")),
        title: 'right'
      }, {
        component: _react.default.createElement(_2.default, {
          label: label,
          position: "right-start"
        }, _react.default.createElement(Button, {
          type: "button"
        }, "Hover me")),
        title: 'right-start'
      }, {
        component: _react.default.createElement(_2.default, {
          label: label,
          position: "right-end"
        }, _react.default.createElement(Button, {
          type: "button"
        }, "Hover me")),
        title: 'right-end'
      }, {
        component: _react.default.createElement(_2.default, {
          label: label,
          position: "top-start"
        }, _react.default.createElement(Button, {
          type: "button"
        }, "Hover me")),
        title: 'top-start'
      }, {
        component: _react.default.createElement(_2.default, {
          label: label,
          position: "top-end"
        }, _react.default.createElement(Button, {
          type: "button"
        }, "Hover me")),
        title: 'top-end'
      }, {
        component: _react.default.createElement(_2.default, {
          label: label,
          position: "left-start"
        }, _react.default.createElement(Button, {
          type: "button"
        }, "Hover me")),
        title: 'left-start'
      }, {
        component: _react.default.createElement(_2.default, {
          label: label,
          position: "left-end"
        }, _react.default.createElement(Button, {
          type: "button"
        }, "Hover me")),
        title: 'left-end'
      }, {
        component: _react.default.createElement(_2.default, {
          label: label,
          position: "bottom-start"
        }, _react.default.createElement(Button, {
          type: "button"
        }, "Hover me")),
        title: 'bottom-start'
      }, {
        component: _react.default.createElement(_2.default, {
          label: label,
          position: "bottom-end"
        }, _react.default.createElement(Button, {
          type: "button"
        }, "Hover me")),
        title: 'bottom-end'
      }]
    });
  },
  name: 'With position defined'
};
var ZindexWars = exports.ZindexWars = {
  render: function render() {
    var Example = function Example() {
      var _useState = (0, _react.useState)(false),
        _useState2 = _slicedToArray(_useState, 2),
        open = _useState2[0],
        setOpen = _useState2[1];
      var openModal = function openModal() {
        setOpen(true);
      };
      var closeModal = function closeModal() {
        setOpen(false);
      };
      return _react.default.createElement(_.Drawer, null, _react.default.createElement(_.Box, {
        mb: 4
      }, _react.default.createElement(_2.default, {
        label: label
      }, _react.default.createElement(Button, null, "Hover me"))), _react.default.createElement(Button, {
        onClick: openModal
      }, "Open modal"), _react.default.createElement(_.Modal, {
        open: open,
        onClose: closeModal
      }, _react.default.createElement(_2.default, {
        label: label,
        inModal: true
      }, _react.default.createElement(Button, null, "Hover me"))));
    };
    return _react.default.createElement(Example, null);
  },
  name: 'Integration: With Drawer and Modal'
};
var CustomMaxWidth = exports.CustomMaxWidth = {
  render: function render() {
    return _react.default.createElement(_2.default, {
      label: label,
      maxWidth: 100
    }, _react.default.createElement(Button, {
      type: "button"
    }, "Hover me"));
  },
  name: 'Custom max-width'
};
var ControlledOpen = exports.ControlledOpen = function ControlledOpen() {
  var _useState3 = (0, _react.useState)(true),
    _useState4 = _slicedToArray(_useState3, 2),
    isOpen = _useState4[0],
    setOpen = _useState4[1];
  return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(Button, {
    onClick: function onClick() {
      return setOpen(!isOpen);
    }
  }, "Toogle Tooltip"), _react.default.createElement(_.Flexbox, {
    container: true
  }, _react.default.createElement(_.Box, {
    mt: 10
  }, _react.default.createElement(_2.default, {
    isOpen: isOpen,
    label: "This is a controlled tooltip.",
    position: "right"
  }, _react.default.createElement("div", null, _react.default.createElement(_.Icon.Edit16, null))))));
};
var WrapChild = exports.WrapChild = function WrapChild() {
  var _useState5 = (0, _react.useState)(true),
    _useState6 = _slicedToArray(_useState5, 1),
    isOpen = _useState6[0];
  return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_.Flexbox, {
    container: true
  }, _react.default.createElement(_.Box, {
    mt: 20
  }, _react.default.createElement(_2.default, {
    isOpen: isOpen,
    label: "With the wrapChiild prop, a DOM element of type span wraps the children, this guarantees a element in the DOM to work properly with ref (and thus positioning).",
    position: "right",
    wrapChild: true
  }, _react.default.createElement(_.Icon.Edit16, null)))), _react.default.createElement(_.Flexbox, {
    container: true
  }, _react.default.createElement(_.Box, {
    mt: 40
  }, _react.default.createElement(_2.default, {
    isOpen: isOpen,
    label: "This tooltip doesn't use the wrapChild prop, but has a children that correctly handles refs",
    position: "right"
  }, _react.default.createElement("div", null, _react.default.createElement(_.Icon.Edit16, null))))));
};
var BrokenPositioning = exports.BrokenPositioning = function BrokenPositioning() {
  var _useState7 = (0, _react.useState)(true),
    _useState8 = _slicedToArray(_useState7, 1),
    isOpen = _useState8[0];
  return _react.default.createElement(_.Flexbox, {
    container: true
  }, _react.default.createElement(_.Box, {
    mt: 40
  }, _react.default.createElement(_2.default, {
    isOpen: isOpen,
    label: "This tooltip has children which doesn't handle refs correctly. Thus, it's positioning doesn't work properly. See wrapChild for examples of how to fix this.",
    position: "right"
  }, _react.default.createElement(_.Icon.Edit16, null))));
};
var WithClickableContent = exports.WithClickableContent = function WithClickableContent() {
  var _useState9 = (0, _react.useState)(false),
    _useState10 = _slicedToArray(_useState9, 2),
    isOpen = _useState10[0],
    setIsOpen = _useState10[1];
  return _react.default.createElement(_.Flexbox, {
    container: true
  }, _react.default.createElement(_.Box, {
    mt: 40
  }, _react.default.createElement(_2.default, {
    isOpen: isOpen,
    label: _react.default.createElement(Button, {
      onClick: function onClick() {
        return alert('You clicked me!');
      }
    }, "Try to click me"),
    position: "right",
    pointerEvents: true,
    wrapChild: true
  }, _react.default.createElement(_.Button, {
    variant: "neutral",
    onClick: function onClick() {
      return setIsOpen(!isOpen);
    }
  }, _react.default.createElement(_.Icon.Edit16, null)))));
};
var WithOffset = exports.WithOffset = function WithOffset() {
  return _react.default.createElement(_.Box, {
    p: 20
  }, _react.default.createElement(_.Flexbox, {
    container: true,
    gap: 4,
    alignItems: "center"
  }, _react.default.createElement(_.Typography, {
    type: "primary"
  }, "Hover the pen!"), _react.default.createElement(_2.default, {
    label: "This tooltip has offset",
    wrapChild: true,
    offset: [-20, 40]
  }, _react.default.createElement(_.Icon.Edit16, null))));
};
var WithOffsetAsAFunction = exports.WithOffsetAsAFunction = function WithOffsetAsAFunction() {
  return _react.default.createElement(_.Box, {
    p: 20
  }, _react.default.createElement(_.Flexbox, {
    container: true,
    gap: 4,
    alignItems: "center"
  }, _react.default.createElement(_.Typography, {
    type: "primary"
  }, "Hover the pen!"), _react.default.createElement(_2.default, {
    position: "bottom",
    label: "This tooltip has offset",
    wrapChild: true,
    offset: function offset(_ref) {
      var placement = _ref.placement,
        reference = _ref.reference,
        popper = _ref.popper;
      if (placement === 'bottom') {
        return [0, popper.height * 4];
      }
      return [];
    }
  }, _react.default.createElement(_.Icon.Edit16, null))));
};
var OverflowBox = (0, _styledComponents.default)(_.Box).withConfig({
  displayName: "Tooltipstories__OverflowBox",
  componentId: "sc-j9k610-2"
})(["border:5px solid red;height:50vh;width:400px;overflow:scroll;"]);
var CustomBoundary = exports.CustomBoundary = function CustomBoundary() {
  var _useState11 = (0, _react.useState)(),
    _useState12 = _slicedToArray(_useState11, 2),
    boundaryElement = _useState12[0],
    setBoundaryElement = _useState12[1];
  return _react.default.createElement(_.Flexbox, {
    container: true,
    alignItems: "center",
    justifyContent: "space-around"
  }, _react.default.createElement(OverflowBox, {
    pb: 40,
    pt: 0,
    my: 40,
    ref: setBoundaryElement
  }, _react.default.createElement("div", {
    style: {
      height: '80vh',
      background: 'orange'
    }
  }), _react.default.createElement(_2.default, {
    label: "This tooltip is positioned bottom but it flips to the top because when there's no portal we have better control over what the container is.",
    position: "bottom",
    pointerEvents: true,
    customBoundary: boundaryElement
  }, _react.default.createElement("span", null, "custom boundary")), _react.default.createElement("div", {
    style: {
      height: '80vh',
      background: 'orange'
    }
  })), _react.default.createElement(OverflowBox, {
    pb: 40,
    pt: 0
  }, _react.default.createElement(_2.default, {
    label: _react.default.createElement("span", null, "This tooltip is positioned bottom, and as its portal wrapped, it will only reposition when outside the border of the page"),
    position: "bottom",
    pointerEvents: true
  }, _react.default.createElement("span", null, "Default with portal"))));
};
var StyledTooltip = (0, _styledComponents.default)(_2.default).withConfig({
  displayName: "Tooltipstories__StyledTooltip",
  componentId: "sc-j9k610-3"
})(["", "{background:red;}"], _.PopOver.components.TooltipContent);
var StyledPopOver = exports.StyledPopOver = function StyledPopOver() {
  return _react.default.createElement(_.Box, {
    py: 20
  }, _react.default.createElement(StyledTooltip, {
    label: "label",
    position: "top",
    wrapChild: true
  }, _react.default.createElement(_.Typography, {
    type: "primary"
  }, "hover me")));
};
var BottomSheet = exports.BottomSheet = function BottomSheet() {
  var _useState13 = (0, _react.useState)(false),
    _useState14 = _slicedToArray(_useState13, 2),
    open = _useState14[0],
    setOpen = _useState14[1];
  return _react.default.createElement(_.Box, {
    py: 20
  }, _react.default.createElement(_2.default, {
    label: _react.default.createElement(_react.default.Fragment, null, "popover content ", _react.default.createElement(Button, {
      onClick: function onClick() {
        return alert('You clicked me!');
      }
    }, "click")),
    position: "bottom",
    wrapChild: true,
    pointerEvents: true,
    bottomSheetQuery: function bottomSheetQuery(t) {
      return t.media.lessThan(t.breakpoints.sm);
    },
    bottomSheetTitle: "BottomSheet Title",
    isOpen: open,
    onBottomSheetClose: function onBottomSheetClose() {
      return setOpen(false);
    }
  }, _react.default.createElement(_.Button, {
    variant: "neutral",
    onClick: function onClick() {
      return setOpen(!open);
    }
  }, _react.default.createElement(_.Typography, {
    type: "primary"
  }, "CLICK ME"))));
};
var BottomSheetNotControlled = exports.BottomSheetNotControlled = function BottomSheetNotControlled() {
  return _react.default.createElement(_.Box, {
    py: 20
  }, _react.default.createElement(_2.default, {
    label: _react.default.createElement(_react.default.Fragment, null, "popover content ", _react.default.createElement(Button, {
      onClick: function onClick() {
        return alert('You clicked me!');
      }
    }, "click")),
    position: "bottom",
    wrapChild: true,
    pointerEvents: true,
    bottomSheetQuery: function bottomSheetQuery(t) {
      return t.media.lessThan(t.breakpoints.sm);
    },
    bottomSheetTitle: "BottomSheet Title",
    bottomSheetHeight: 300
  }, _react.default.createElement(_.Button, {
    variant: "neutral"
  }, _react.default.createElement(_.Typography, {
    type: "primary"
  }, "CLICK ME"))));
};
var BottomSheetInvertedColors = exports.BottomSheetInvertedColors = function BottomSheetInvertedColors() {
  var _useState15 = (0, _react.useState)(false),
    _useState16 = _slicedToArray(_useState15, 2),
    open = _useState16[0],
    setOpen = _useState16[1];
  return _react.default.createElement(_.Box, {
    py: 20
  }, _react.default.createElement(_2.default, {
    label: _react.default.createElement(_react.default.Fragment, null, "popover content ", _react.default.createElement(Button, {
      onClick: function onClick() {
        return alert('You clicked me!');
      }
    }, "click")),
    position: "bottom",
    wrapChild: true,
    pointerEvents: true,
    bottomSheetQuery: function bottomSheetQuery(t) {
      return t.media.lessThan(t.breakpoints.sm);
    },
    bottomSheetTitle: "BottomSheet Title",
    bottomSheetHeight: 300,
    invertedColors: true,
    isOpen: open,
    onBottomSheetClose: function onBottomSheetClose() {
      return setOpen(false);
    }
  }, _react.default.createElement(_.Button, {
    variant: "neutral",
    onClick: function onClick() {
      return setOpen(!open);
    }
  }, _react.default.createElement(_.Typography, {
    type: "primary"
  }, "CLICK ME"))));
};