suomifi-ui-components
Version:
Suomi.fi UI component library
93 lines (90 loc) • 4.03 kB
JavaScript
import { __extends, __rest, __assign, __makeTemplateObject } from 'tslib';
import React, { Component, forwardRef } from 'react';
import classnames from 'classnames';
import { styled } from 'styled-components';
import '../../../reset/HtmlA/HtmlA.js';
import '../../../reset/HtmlButton/HtmlButton.js';
import '../../../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 { HtmlSpan } from '../../../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 { baseClassName, chipClassNames } from '../BaseChip/BaseChip.js';
import { staticChipBaseStyles } from './StaticChip.baseStyles.js';
import { SuomifiThemeConsumer } from '../../theme/SuomifiThemeProvider/SuomifiThemeProvider.js';
import '../../theme/SuomifiTheme/SuomifiTheme.js';
import { SpacingConsumer } from '../../theme/SpacingProvider/SpacingProvider.js';
import { separateMarginProps } from '../../theme/utils/spacing.js';
import { filterDuplicateKeys } from '../../../utils/common/common.js';
var BaseChip = function (_super) {
__extends(BaseChip, _super);
function BaseChip() {
return _super !== null && _super.apply(this, arguments) || this;
}
BaseChip.prototype.render = function () {
var _a;
var _b = this.props,
className = _b.className,
children = _b.children,
_c = _b.disabled,
disabled = _c === void 0 ? false : _c,
rest = __rest(_b, ["className", "children", "disabled"]);
var _d = separateMarginProps(rest),
passProps = _d[1];
return /*#__PURE__*/React.createElement(HtmlSpan, __assign({
className: classnames(baseClassName, className, (_a = {}, _a[chipClassNames.disabled] = !!disabled, _a))
}, passProps, {
style: __assign({}, passProps === null || passProps === void 0 ? void 0 : passProps.style)
}), /*#__PURE__*/React.createElement(HtmlSpan, {
className: chipClassNames.content
}, children));
};
return BaseChip;
}(Component);
var StyledChip = styled(function (_a) {
_a.theme;
_a.globalMargins;
var passProps = __rest(_a, ["theme", "globalMargins"]);
return /*#__PURE__*/React.createElement(BaseChip, __assign({}, passProps));
}).withConfig({
componentId: "sc-cb2y9x-0"
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (_a) {
var theme = _a.theme,
globalMargins = _a.globalMargins,
rest = __rest(_a, ["theme", "globalMargins"]);
var _b = separateMarginProps(rest),
marginProps = _b[0];
var cleanedGlobalMargins = filterDuplicateKeys(globalMargins.staticChip, marginProps);
return staticChipBaseStyles(theme, cleanedGlobalMargins, marginProps);
});
var StaticChip = /*#__PURE__*/forwardRef(function (props, ref) {
return /*#__PURE__*/React.createElement(SpacingConsumer, null, function (_a) {
var margins = _a.margins;
return /*#__PURE__*/React.createElement(SuomifiThemeConsumer, null, function (_a) {
var suomifiTheme = _a.suomifiTheme;
return /*#__PURE__*/React.createElement(StyledChip, __assign({
theme: suomifiTheme,
globalMargins: margins,
forwardedRef: ref
}, props));
});
});
});
StaticChip.displayName = 'StaticChip';
var templateObject_1;
export { StaticChip };
//# sourceMappingURL=StaticChip.js.map