UNPKG

@bianic-ui/system

Version:

Bianic UI system primitives

66 lines (47 loc) 2.38 kB
"use strict"; exports.__esModule = true; exports.styled = styled; exports.bianic = void 0; var _styledSystem = require("@bianic-ui/styled-system"); var _styled = _interopRequireDefault(require("@emotion/styled")); var _system = require("./system.utils"); var _shouldForwardProp = require("./should-forward-prop"); 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); } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } var sxProp = (0, _system.cast)(function (props) { return (0, _styledSystem.css)(props.sx)(props.theme); }); var cssProp = function cssProp(props) { return props.css; }; var __css = (0, _system.cast)(function (props) { var result = {}; for (var key in props.__css) { var exists = (key in props); if (!exists || props[key] == null) { result[key] = props.__css[key]; } } return (0, _styledSystem.css)(result)(props.theme); }); var base = (0, _system.cast)(function (baseStyle) { return function (props) { return (0, _styledSystem.css)(baseStyle)(props.theme); }; }); function styled(component, options) { var _ref = options || {}, baseStyle = _ref.baseStyle, styledOptions = _objectWithoutPropertiesLoose(_ref, ["baseStyle"]); return (0, _styled["default"])(component, _extends({}, styledOptions, { shouldForwardProp: _shouldForwardProp.shouldForwardProp }))(__css, base(baseStyle), (0, _system.cast)(_system.extraProps), (0, _system.cast)(_system.truncateProp), (0, _system.cast)(_styledSystem.systemProps), (0, _system.cast)(_system.pseudoProps), sxProp, (0, _system.cast)(cssProp)); } var bianic = styled; exports.bianic = bianic; _system.domElements.forEach(function (tag) { //@ts-ignore bianic[tag] = bianic(tag); }); //# sourceMappingURL=system.js.map