@blueprintjs/core
Version:
Core styles & components
50 lines (48 loc) • 1.85 kB
JavaScript
/*
* Copyright 2015 Palantir Technologies, Inc. All rights reserved.
* Licensed under the BSD-3 License as modified (the “License”); you may obtain a copy
* of the license at https://github.com/palantir/blueprint/blob/master/LICENSE
* and https://github.com/palantir/blueprint/blob/master/PATENTS
*/
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
/** A collection of curated prop keys used across our Components which are not valid HTMLElement props. */
var INVALID_PROPS = [
"active",
"containerRef",
"elementRef",
"iconName",
"inputRef",
"intent",
"loading",
"leftIconName",
"onChildrenMount",
"onRemove",
"rightElement",
"rightIconName",
"text",
];
/**
* Typically applied to HTMLElements to filter out blacklisted props. When applied to a Component,
* can filter props from being passed down to the children. Can also filter by a combined list of
* supplied prop keys and the blacklist (only appropriate for HTMLElements).
* @param props The original props object to filter down.
* @param {string[]} invalidProps If supplied, overwrites the default blacklist.
* @param {boolean} shouldMerge If true, will merge supplied invalidProps and blacklist together.
*/
function removeNonHTMLProps(props, invalidProps, shouldMerge) {
if (invalidProps === void 0) { invalidProps = INVALID_PROPS; }
if (shouldMerge === void 0) { shouldMerge = false; }
if (shouldMerge) {
invalidProps = invalidProps.concat(INVALID_PROPS);
}
return invalidProps.reduce(function (prev, curr) {
if (prev.hasOwnProperty(curr)) {
delete prev[curr];
}
return prev;
}, tslib_1.__assign({}, props));
}
exports.removeNonHTMLProps = removeNonHTMLProps;
//# sourceMappingURL=props.js.map