UNPKG

2.43 kBJavaScriptView Raw
1/*
2 * Copyright 2015 Palantir Technologies, Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { __assign } from "tslib";
17export var DISPLAYNAME_PREFIX = "Blueprint4";
18/** A collection of curated prop keys used across our Components which are not valid HTMLElement props. */
19var INVALID_PROPS = [
20 "active",
21 "alignText",
22 "asyncControl",
23 "containerRef",
24 "current",
25 "elementRef",
26 "fill",
27 "icon",
28 "inputRef",
29 "intent",
30 "inline",
31 "large",
32 "loading",
33 "leftElement",
34 "leftIcon",
35 "minimal",
36 "onRemove",
37 "outlined",
38 "panel",
39 "panelClassName",
40 "popoverProps",
41 "rightElement",
42 "rightIcon",
43 "round",
44 "small",
45 "text",
46];
47/**
48 * Typically applied to HTMLElements to filter out disallowed props. When applied to a Component,
49 * can filter props from being passed down to the children. Can also filter by a combined list of
50 * supplied prop keys and the denylist (only appropriate for HTMLElements).
51 *
52 * @param props The original props object to filter down.
53 * @param {string[]} invalidProps If supplied, overwrites the default denylist.
54 * @param {boolean} shouldMerge If true, will merge supplied invalidProps and denylist together.
55 */
56export function removeNonHTMLProps(props, invalidProps, shouldMerge) {
57 if (invalidProps === void 0) { invalidProps = INVALID_PROPS; }
58 if (shouldMerge === void 0) { shouldMerge = false; }
59 if (shouldMerge) {
60 invalidProps = invalidProps.concat(INVALID_PROPS);
61 }
62 return invalidProps.reduce(function (prev, curr) {
63 // Props with hyphens (e.g. data-*) are always considered html props
64 if (curr.indexOf("-") !== -1) {
65 return prev;
66 }
67 if (prev.hasOwnProperty(curr)) {
68 delete prev[curr];
69 }
70 return prev;
71 }, __assign({}, props));
72}
73//# sourceMappingURL=props.js.map
\No newline at end of file