UNPKG

preact-material-components

Version:
185 lines (147 loc) 4.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _preact = require("preact"); var _MaterialComponent = _interopRequireDefault(require("../MaterialComponent")); var _Icon = _interopRequireDefault(require("../Icon")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _extends() { _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; }; return _extends.apply(this, arguments); } /** * @prop dense = false * @prop two-line = false * @prop interactive = false */ class List extends _MaterialComponent.default { constructor() { super(); this.componentName = 'list'; this._mdcProps = ['dense', 'two-line', 'avatar-list']; } materialDom(props) { if (props.interactive) { return (0, _preact.h)("nav", _extends({ ref: this.setControlRef }, props), props.children); } return (0, _preact.h)("ul", _extends({}, props, { ref: this.setControlRef }), props.children); } } class ListItem extends _MaterialComponent.default { constructor() { super(); this.componentName = 'list-item'; } materialDom(props) { return (0, _preact.h)("li", _extends({ role: "option" }, props, { ref: this.setControlRef }), props.children); } } class LinkItem extends _MaterialComponent.default { constructor() { super(); this.componentName = 'list-item'; } componentDidMount() { super.attachRipple(); } materialDom(props) { return (0, _preact.h)("a", _extends({ role: "option" }, props, { ref: this.setControlRef }), props.children); } } class ListItemGraphic extends _MaterialComponent.default { constructor() { super(); this.componentName = 'list-item__graphic'; } materialDom(props) { return (0, _preact.h)("span", _extends({}, props, { ref: this.setControlRef, role: "presentation" }), (0, _preact.h)(_Icon.default, { "aria-hidden": "true" }, props.children)); } } class ListItemMeta extends ListItemGraphic { constructor() { super(); this.componentName = 'list-item__meta'; } } class ListDivider extends _MaterialComponent.default { constructor() { super(); this.componentName = 'list-divider'; this._mdcProps = ['inset']; } materialDom(props) { return (0, _preact.h)("li", _extends({ role: "separator" }, props, { ref: this.setControlRef })); } } class ListTextContainer extends _MaterialComponent.default { constructor() { super(); this.componentName = 'list-item__text'; } materialDom(props) { return (0, _preact.h)("span", _extends({}, props, { ref: this.setControlRef }), props.children); } } class ListPrimaryText extends ListTextContainer { constructor() { super(); this.componentName = 'list-item__text__primary'; } } class ListSecondaryText extends ListTextContainer { constructor() { super(); this.componentName = 'list-item__secondary-text'; } } class ListGroup extends _MaterialComponent.default { constructor() { super(); this.componentName = 'list-group'; } } class ListGroupHeader extends _MaterialComponent.default { constructor() { super(); this.componentName = 'list-group__subheader'; } materialDom(props) { return (0, _preact.h)("h3", _extends({}, props, { ref: this.setControlRef }), props.children); } } List.Item = ListItem; List.LinkItem = LinkItem; List.ItemGraphic = ListItemGraphic; List.ItemMeta = ListItemMeta; List.Divider = ListDivider; List.TextContainer = ListTextContainer; List.PrimaryText = ListPrimaryText; List.SecondaryText = ListSecondaryText; List.Group = ListGroup; List.GroupHeader = ListGroupHeader; var _default = List; exports.default = _default;