UNPKG

suomifi-ui-components

Version:
98 lines (95 loc) 4.2 kB
import { __extends, __rest, __assign, __makeTemplateObject } from 'tslib'; import React, { Component } from 'react'; import { styled } from 'styled-components'; import { SuomifiThemeConsumer } from '../../../../theme/SuomifiThemeProvider/SuomifiThemeProvider.js'; import '../../../../theme/SuomifiTheme/SuomifiTheme.js'; import '../../../../theme/SpacingProvider/SpacingProvider.js'; import '../../../../../reset/HtmlA/HtmlA.js'; import '../../../../../reset/HtmlButton/HtmlButton.js'; import { HtmlDiv } from '../../../../../reset/HtmlDiv/HtmlDiv.js'; import '../../../../../reset/HtmlFieldSet/HtmlFieldSet.js'; import '../../../../../reset/HtmlH/HtmlH.js'; import '../../../../../reset/HtmlInput/HtmlInput.js'; import '../../../../../reset/HtmlLabel/HtmlLabel.js'; import '../../../../../reset/HtmlLegend/HtmlLegend.js'; import { HtmlLi } from '../../../../../reset/HtmlLi/HtmlLi.js'; import '../../../../../reset/HtmlNav/HtmlNav.js'; import '../../../../../reset/HtmlOl/HtmlOl.js'; import '../../../../../reset/HtmlSpan/HtmlSpan.js'; import '../../../../../reset/HtmlTextarea/HtmlTextarea.js'; import '../../../../../reset/HtmlUl/HtmlUl.js'; import '../../../../../reset/HtmlTable/HtmlTable.js'; import '../../../../../reset/HtmlTable/HtmlTableCaption.js'; import '../../../../../reset/HtmlTable/HtmlTableHeader.js'; import '../../../../../reset/HtmlTable/HtmlTableRow.js'; import '../../../../../reset/HtmlTable/HtmlTableBody.js'; import '../../../../../reset/HtmlTable/HtmlTableHeaderCell.js'; import '../../../../../reset/HtmlTable/HtmlTableCell.js'; import { selectItemAdditionStyles } from './SelectItemAddition.baseStyles.js'; import classnames from 'classnames'; var baseClassName = 'fi-select-item-addition'; var classNames = { hint_text: "".concat(baseClassName, "_hint-text"), item: "".concat(baseClassName, "_item"), hasKeyboardFocus: "".concat(baseClassName, "_item--hasKeyboardFocus") }; var BaseSelectItemAddition = function (_super) { __extends(BaseSelectItemAddition, _super); function BaseSelectItemAddition() { return _super !== null && _super.apply(this, arguments) || this; } BaseSelectItemAddition.prototype.render = function () { var _a; var _b = this.props, hintText = _b.hintText, _onClick = _b.onClick, hasKeyboardFocus = _b.hasKeyboardFocus, id = _b.id; _b.theme; var children = _b.children, passProps = __rest(_b, ["hintText", "onClick", "hasKeyboardFocus", "id", "theme", "children"]); return /*#__PURE__*/React.createElement(HtmlDiv, __assign({}, passProps), /*#__PURE__*/React.createElement(HtmlDiv, { className: classNames.hint_text }, hintText), /*#__PURE__*/React.createElement(HtmlLi, { className: classnames(classNames.item, (_a = {}, _a[classNames.hasKeyboardFocus] = hasKeyboardFocus, _a)), tabIndex: -1, onMouseDown: function onMouseDown(event) { event.preventDefault(); }, onClick: function onClick(event) { if (!!_onClick) { _onClick(event); } }, "aria-label": "".concat(hintText, ". ").concat(children, "."), role: "option", id: id }, children)); }; return BaseSelectItemAddition; }(Component); var StyledSelectItemAddition = styled(BaseSelectItemAddition).withConfig({ componentId: "sc-m1d1s3-0" })(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (_a) { var theme = _a.theme; return selectItemAdditionStyles(theme); }); var SelectItemAddition = function (_super) { __extends(SelectItemAddition, _super); function SelectItemAddition() { return _super !== null && _super.apply(this, arguments) || this; } SelectItemAddition.prototype.render = function () { var _this = this; return /*#__PURE__*/React.createElement(SuomifiThemeConsumer, null, function (_a) { var suomifiTheme = _a.suomifiTheme; return /*#__PURE__*/React.createElement(StyledSelectItemAddition, __assign({ theme: suomifiTheme }, _this.props)); }); }; return SelectItemAddition; }(Component); var templateObject_1; export { SelectItemAddition }; //# sourceMappingURL=SelectItemAddition.js.map