-
-
Save sevdog/78a1a19646776ef5822fc4bb6b27d004 to your computer and use it in GitHub Desktop.
Test react-popper 1.0.2 UMD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" /> | |
<link rel="stylesheet" href="https://unpkg.com/react-bootstrap-typeahead/css/Typeahead.css"> | |
</head> | |
<body> | |
<div id="my-app" ></div> | |
<hr> | |
<hr> | |
<div id="destination" style="border: 2px solid red"></div> | |
<hr> | |
<hr> | |
<div id="my-type" ></div> | |
<!-- Required dependencies --> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.6.2/prop-types.min.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/16.4.2/umd/react.development.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.4.2/umd/react-dom.development.js"></script> | |
<!-- Optional dependencies --> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react-transition-group/2.4.0/react-transition-group.min.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.4/umd/popper.min.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react-popper/1.0.2/index.umd.min.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/reactstrap/6.4.0/reactstrap.min.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react-bootstrap-typeahead/3.2.3/react-bootstrap-typeahead.min.js"></script> | |
<!-- Lastly, include your app --> | |
<script type="text/javascript"> | |
"use strict"; | |
var Example = function Example() { | |
return React.createElement( | |
ReactPopper.Manager, | |
null, | |
React.createElement( | |
ReactPopper.Reference, | |
null, | |
function (_ref) { | |
var ref = _ref.ref; | |
return React.createElement( | |
"button", | |
{ type: "button", ref: ref }, | |
"Reference element" | |
); | |
} | |
), | |
ReactDOM.createPortal(React.createElement( | |
ReactPopper.Popper, | |
{ placement: "right" }, | |
function (_ref2) { | |
var ref = _ref2.ref, | |
style = _ref2.style, | |
placement = _ref2.placement, | |
arrowProps = _ref2.arrowProps; | |
return React.createElement( | |
"div", | |
{ ref: ref, style: style, "data-placement": placement }, | |
"Popper element", | |
React.createElement("div", { ref: arrowProps.ref, style: arrowProps.style }) | |
); | |
} | |
), document.querySelector('#destination')) | |
); | |
}; | |
"use strict"; | |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | |
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | |
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | |
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | |
var Control = function Control(_ref) { | |
var children = _ref.children, | |
isBS3 = _ref.isBS3, | |
type = _ref.type, | |
props = _objectWithoutProperties(_ref, ['children', 'isBS3', 'type']); | |
var Component = type === 'radio' ? Reactstrap.Radio : Reactstrap.Checkbox; | |
return isBS3 ? React.createElement( | |
Component, | |
props, | |
children | |
) : React.createElement( | |
Reactstrap.FormGroup, | |
{ check: true }, | |
React.createElement( | |
Reactstrap.Label, | |
{ check: true }, | |
React.createElement(Reactstrap.Input, _extends({}, props, { type: type })), | |
' ', | |
children | |
) | |
); | |
}; | |
var BasicExample = function (_React$Component) { | |
_inherits(BasicExample, _React$Component); | |
function BasicExample(props) { | |
_classCallCheck(this, BasicExample); | |
var _this = _possibleConstructorReturn(this, (BasicExample.__proto__ || Object.getPrototypeOf(BasicExample)).call(this, props)); | |
_this.state = { | |
multiple: false | |
}; | |
return _this; | |
} | |
_createClass(BasicExample, [{ | |
key: "render", | |
value: function render() { | |
var _this2 = this; | |
var multiple = this.state.multiple; | |
return React.createElement( | |
React.Fragment, | |
null, | |
React.createElement(ReactBootstrapTypeahead.Typeahead, { | |
labelKey: "name", | |
multiple: multiple, | |
options: ['test', 'a test', 'this is a test'], | |
placeholder: "Choose a state..." | |
}), | |
React.createElement( | |
Reactstrap.FormGroup, | |
null, | |
React.createElement( | |
Control, | |
{ | |
checked: multiple, | |
onChange: function onChange(e) { | |
return _this2.setState({ multiple: e.target.checked }); | |
}, | |
type: "checkbox" }, | |
"Multi-Select" | |
) | |
) | |
); | |
} | |
}]); | |
return BasicExample; | |
}(React.Component); | |
console.log(ReactPopper); | |
ReactDOM.render(React.createElement(Example, null), document.getElementById('my-app')); | |
ReactDOM.render(React.createElement(BasicExample, null), document.getElementById('my-type')); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment