UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

43 lines 3.06 kB
import * as tslib_1 from "tslib"; /* tslint:disable */ import * as React from 'react'; /* tslint:enable */ import { BaseComponent, css, getId, createRef } from '../../../../Utilities'; import { Persona, PersonaSize } from '../../../../Persona'; import { IconButton } from '../../../../Button'; import * as stylesImport from './ExtendedSelectedItem.scss'; // tslint:disable-next-line:no-any var styles = stylesImport; var ExtendedSelectedItem = /** @class */ (function (_super) { tslib_1.__extends(ExtendedSelectedItem, _super); function ExtendedSelectedItem(props) { var _this = _super.call(this, props) || this; _this.persona = createRef(); _this.state = { contextualMenuVisible: false }; return _this; } ExtendedSelectedItem.prototype.render = function () { var _a = this.props, item = _a.item, onExpandItem = _a.onExpandItem, onRemoveItem = _a.onRemoveItem, removeButtonAriaLabel = _a.removeButtonAriaLabel, index = _a.index, selected = _a.selected; var itemId = getId(); return (React.createElement("div", { ref: this.persona, className: css('ms-PickerPersona-container', styles.personaContainer, (_b = {}, _b['is-selected ' + styles.personaContainerIsSelected] = selected, _b), (_c = {}, _c['is-invalid ' + styles.validationError] = !item.isValid, _c)), "data-is-focusable": true, "data-is-sub-focuszone": true, "data-selection-index": index, role: 'listitem', "aria-labelledby": 'selectedItemPersona-' + itemId }, React.createElement("div", { hidden: !item.canExpand || onExpandItem === undefined }, React.createElement(IconButton, { onClick: this._onClickIconButton(onExpandItem), iconProps: { iconName: 'Add', style: { fontSize: '14px' } }, className: css('ms-PickerItem-removeButton', styles.expandButton, styles.actionButton), ariaLabel: removeButtonAriaLabel })), React.createElement("div", { className: css(styles.personaWrapper) }, React.createElement("div", { className: css('ms-PickerItem-content', styles.itemContent), id: 'selectedItemPersona-' + itemId }, React.createElement(Persona, tslib_1.__assign({}, item, { onRenderCoin: this.props.renderPersonaCoin, onRenderPrimaryText: this.props.renderPrimaryText, size: PersonaSize.size32 }))), React.createElement(IconButton, { onClick: this._onClickIconButton(onRemoveItem), iconProps: { iconName: 'Cancel', style: { fontSize: '14px' } }, className: css('ms-PickerItem-removeButton', styles.removeButton, styles.actionButton), ariaLabel: removeButtonAriaLabel })))); var _b, _c; }; ExtendedSelectedItem.prototype._onClickIconButton = function (action) { return function (ev) { ev.stopPropagation(); ev.preventDefault(); if (action) { action(); } }; }; return ExtendedSelectedItem; }(BaseComponent)); export { ExtendedSelectedItem }; //# sourceMappingURL=ExtendedSelectedItem.js.map