suomifi-ui-components
Version:
Suomi.fi UI component library
87 lines (84 loc) • 3.86 kB
JavaScript
import { __extends, __rest, __assign, __makeTemplateObject } from 'tslib';
import React, { Component } from 'react';
import { styled } from 'styled-components';
import classnames from 'classnames';
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 '../../../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 { getConditionalAriaProp } from '../../../utils/aria/aria.js';
import { SuomifiThemeConsumer } from '../../theme/SuomifiThemeProvider/SuomifiThemeProvider.js';
import '../../theme/SuomifiTheme/SuomifiTheme.js';
import '../../theme/SpacingProvider/SpacingProvider.js';
import { ExpanderConsumer } from '../Expander/Expander.js';
import { baseStyles } from './ExpanderContent.baseStyles.js';
var baseClassName = 'fi-expander';
var contentBaseClassName = "".concat(baseClassName, "_content");
var contentOpenClassName = "".concat(contentBaseClassName, "--open");
var noPaddingClassName = "".concat(contentBaseClassName, "--no-padding");
var BaseExpanderContent = function (_super) {
__extends(BaseExpanderContent, _super);
function BaseExpanderContent() {
return _super !== null && _super.apply(this, arguments) || this;
}
BaseExpanderContent.prototype.render = function () {
var _a;
var _b = this.props,
children = _b.children;
_b.title;
var className = _b.className;
_b.theme;
var noPadding = _b.noPadding,
consumer = _b.consumer,
ariaLabelledBy = _b["aria-labelledby"],
passProps = __rest(_b, ["children", "title", "className", "theme", "noPadding", "consumer", 'aria-labelledby']);
return /*#__PURE__*/React.createElement(HtmlDiv, __assign({
role: "region"
}, passProps, {
id: consumer.contentId
}, getConditionalAriaProp('aria-labelledby', [consumer.titleId, ariaLabelledBy]), {
className: classnames(className, contentBaseClassName, (_a = {}, _a[contentOpenClassName] = !!consumer.open, _a[noPaddingClassName] = !!noPadding, _a)),
"aria-hidden": !consumer.open,
key: String(consumer.open)
}), children);
};
return BaseExpanderContent;
}(Component);
var StyledExpanderContent = styled(BaseExpanderContent).withConfig({
componentId: "sc-1ln4vdb-0"
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (_a) {
var theme = _a.theme;
return baseStyles(theme);
});
var ExpanderContent = function ExpanderContent(props) {
return /*#__PURE__*/React.createElement(SuomifiThemeConsumer, null, function (_a) {
var suomifiTheme = _a.suomifiTheme;
return /*#__PURE__*/React.createElement(ExpanderConsumer, null, function (consumer) {
return /*#__PURE__*/React.createElement(StyledExpanderContent, __assign({
theme: suomifiTheme,
consumer: consumer
}, props));
});
});
};
ExpanderContent.displayName = 'ExpanderContent';
var templateObject_1;
export { ExpanderContent };
//# sourceMappingURL=ExpanderContent.js.map