rmwc
Version:
A thin React wrapper for Material Design (Web) Components
151 lines (115 loc) • 6.76 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TopAppBar = exports.TopAppBarFixedAdjust = exports.TopAppBarTitle = exports.TopAppBarActionItem = exports.TopAppBarNavigationIcon = exports.TopAppBarSection = exports.TopAppBarRow = exports.TopAppBarRoot = undefined;
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; }; }();
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _react = require('react');
var React = _interopRequireWildcard(_react);
var _mdc = require('@material/top-app-bar/dist/mdc.topAppBar');
var _Icon = require('../Icon');
var _Base = require('../Base');
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
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; }
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 TopAppBarRoot = exports.TopAppBarRoot = (0, _Base.simpleTag)({
displayName: 'TopAppBarRoot',
tag: 'header',
classNames: function classNames(props) {
return ['mdc-top-app-bar', {
'mdc-top-app-bar--fixed': props.fixed,
'mdc-top-app-bar--prominent': props.prominent,
'mdc-top-app-bar--short': props.short || props.shortCollapsed,
'mdc-top-app-bar--short-collapsed': props.shortCollapsed,
'mdc-top-app-bar--dense': props.dense
}];
},
consumeProps: ['fixed', 'prominent', 'short', 'shortCollapsed', 'dense']
});
/** A row for the app bar. */
var TopAppBarRow = exports.TopAppBarRow = (0, _Base.simpleTag)({
displayName: 'TopAppBarRow',
classNames: 'mdc-top-app-bar__row'
});
/** A section for the app bar. */
var TopAppBarSection = exports.TopAppBarSection = function (_simpleTag) {
_inherits(TopAppBarSection, _simpleTag);
function TopAppBarSection() {
_classCallCheck(this, TopAppBarSection);
return _possibleConstructorReturn(this, (TopAppBarSection.__proto__ || Object.getPrototypeOf(TopAppBarSection)).apply(this, arguments));
}
_createClass(TopAppBarSection, [{
key: 'render',
value: function render() {
return _get(TopAppBarSection.prototype.__proto__ || Object.getPrototypeOf(TopAppBarSection.prototype), 'render', this).call(this);
}
}]);
return TopAppBarSection;
}((0, _Base.simpleTag)({
tag: 'section',
classNames: function classNames(props) {
return ['mdc-top-app-bar__section', {
'mdc-top-app-bar__section--align-Start': props.alignStart,
'mdc-top-app-bar__section--align-end': props.alignEnd
}];
},
consumeProps: ['alignStart', 'alignEnd']
}));
/** A navigation icon for the top app bar. This is an instance of the Icon component. */
Object.defineProperty(TopAppBarSection, 'displayName', {
enumerable: true,
writable: true,
value: 'TopAppBarSection'
});
var TopAppBarNavigationIcon = exports.TopAppBarNavigationIcon = (0, _Base.simpleTag)({
displayName: 'TopAppBarNavigationIcon',
classNames: 'mdc-top-app-bar__navigation-icon',
tag: _Icon.Icon
});
/** Action items for the top app bar. This is an instance of the Icon component.*/
var TopAppBarActionItem = exports.TopAppBarActionItem = (0, _Base.simpleTag)({
displayName: 'TopAppBarActionItem',
classNames: 'mdc-top-app-bar__action-item',
tag: _Icon.Icon
});
/** A title for the top app bar. */
var TopAppBarTitle = exports.TopAppBarTitle = (0, _Base.simpleTag)({
displayName: 'TopAppBarTitle',
classNames: 'mdc-top-app-bar__title'
});
/** An optional component to fill the space when the TopAppBar is fixed. Place it directly after the TopAppBar. */
var TopAppBarFixedAdjust = exports.TopAppBarFixedAdjust = (0, _Base.simpleTag)({
displayName: 'TopAppBarFixedAdjust',
classNames: 'mdc-top-app-bar--fixed-adjust'
});
/** A TopAppBar component */
var TopAppBar = exports.TopAppBar = function (_withFoundation) {
_inherits(TopAppBar, _withFoundation);
function TopAppBar() {
_classCallCheck(this, TopAppBar);
return _possibleConstructorReturn(this, (TopAppBar.__proto__ || Object.getPrototypeOf(TopAppBar)).apply(this, arguments));
}
_createClass(TopAppBar, [{
key: 'render',
value: function render() {
var _props = this.props,
onNav = _props.onNav,
apiRef = _props.apiRef,
rest = _objectWithoutProperties(_props, ['onNav', 'apiRef']);
var root_ = this.foundationRefs.root_;
return React.createElement(TopAppBarRoot, Object.assign({}, rest, { elementRef: root_ }));
}
}]);
return TopAppBar;
}((0, _Base.withFoundation)({
constructor: _mdc.MDCTopAppBar,
adapter: {}
}));
Object.defineProperty(TopAppBar, 'displayName', {
enumerable: true,
writable: true,
value: 'TopAppBar'
});
;