UNPKG

colonel-kurtz

Version:
113 lines (87 loc) 3.37 kB
'use strict'; function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var React = _interopDefault(require('react')); var Ink = _interopDefault(require('react-ink')); var FocusTrap = _interopDefault(require('react-focus-trap')); function objectWithoutProperties (obj, exclude) { var target = {}; for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k) && exclude.indexOf(k) === -1) target[k] = obj[k]; return target; } var defaultProps = { className: 'col-btn', tagName: 'button', type: 'button' }; var Button = /*@__PURE__*/(function (superclass) { function Button () { superclass.apply(this, arguments); } if ( superclass ) Button.__proto__ = superclass; Button.prototype = Object.create( superclass && superclass.prototype ); Button.prototype.constructor = Button; Button.prototype.render = function render () { var ref = this.props; var tagName = ref.tagName; var children = ref.children; var rest = objectWithoutProperties( ref, ["tagName", "children"] ); var attrs = rest; return React.createElement(tagName, attrs, [ React.createElement( Ink, { key: "__ink__" }) ].concat( children )) }; return Button; }(React.Component)); Button.defaultProps = defaultProps; function objectWithoutProperties$1 (obj, exclude) { var target = {}; for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k) && exclude.indexOf(k) === -1) target[k] = obj[k]; return target; } var defaultProps$1 = { className: 'col-dialog-close', label: 'Close this dialog', type: 'button' }; function Close(ref) { var label = ref.label; var rest = objectWithoutProperties$1( ref, ["label"] ); var safe = rest; return ( React.createElement( Button, safe, React.createElement( 'span', { className: "col-hidden" }, label), React.createElement( 'svg', { width: "24", height: "24", viewBox: "0 0 24 24", 'aria-hidden': "true" }, React.createElement( 'path', { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) ) ) ) } Close.defaultProps = defaultProps$1; var defaultProps$2 = { className: 'col-dialog', headingComponent: 'h3' }; var Dialog = /*@__PURE__*/(function (superclass) { function Dialog () { superclass.apply(this, arguments); } if ( superclass ) Dialog.__proto__ = superclass; Dialog.prototype = Object.create( superclass && superclass.prototype ); Dialog.prototype.constructor = Dialog; Dialog.prototype.renderTitle = function renderTitle () { var ref = this.props; var Title = ref.headingComponent; var title = ref.title; return title ? React.createElement( Title, { className: "col-dialog-title" }, title) : null }; Dialog.prototype.render = function render () { var ref = this.props; var active = ref.active; var children = ref.children; var className = ref.className; var onExit = ref.onExit; return ( React.createElement( FocusTrap, { active: active, className: className, onExit: onExit }, this.renderTitle(), children, React.createElement( Close, { onClick: onExit }) ) ) }; return Dialog; }(React.Component)); Dialog.defaultProps = defaultProps$2; module.exports = Dialog; //# sourceMappingURL=dialog.js.map