@bianic-ui/system
Version:
Bianic UI system primitives
34 lines (27 loc) • 1.11 kB
JavaScript
;
exports.__esModule = true;
exports.shouldForwardProp = void 0;
var _styledSystem = require("@bianic-ui/styled-system");
var _utils = require("@bianic-ui/utils");
/**
* List of props for emotion to omit from DOM.
* It mostly consists of Bianic props
*/
var allPropNames = [].concat(_styledSystem.propNames, ["textStyle", "layerStyle", "apply", "isTruncated", "noOfLines", "focusBorderColor", "errorBorderColor", "as", "__css", "css", "sx"]);
/**
* htmlWidth and htmlHeight is used in the <Image />
* component to support the native `width` and `height` attributes
*
* https://gitlab.com/bia-design/bianic-ui/issues/149
*/
var validHTMLProps = ["htmlWidth", "htmlHeight", "htmlSize"];
function createShouldForwardProp(props) {
var regex = new RegExp("^(" + props.join("|") + ")$");
return (0, _utils.memoize)(function (prop) {
if (validHTMLProps.includes(prop)) return true;
return !regex.test(prop);
});
}
var shouldForwardProp = createShouldForwardProp(allPropNames);
exports.shouldForwardProp = shouldForwardProp;
//# sourceMappingURL=should-forward-prop.js.map