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 | */
|
16 | import { __assign } from "tslib";
|
17 | export var DISPLAYNAME_PREFIX = "Blueprint5";
|
18 | /** A collection of curated prop keys used across our Components which are not valid HTMLElement props. */
|
19 | var INVALID_PROPS = [
|
20 | "active",
|
21 | "alignText",
|
22 | "asyncControl",
|
23 | "containerRef",
|
24 | "current",
|
25 | "elementRef",
|
26 | "fill",
|
27 | "icon",
|
28 | "iconSize",
|
29 | "inputClassName",
|
30 | "inputRef",
|
31 | "intent",
|
32 | "inline",
|
33 | "large",
|
34 | "loading",
|
35 | "leftElement",
|
36 | "leftIcon",
|
37 | "minimal",
|
38 | "onRemove",
|
39 | "outlined",
|
40 | "panel",
|
41 | "panelClassName",
|
42 | "popoverProps",
|
43 | "rightElement",
|
44 | "rightIcon",
|
45 | "round",
|
46 | "size",
|
47 | "small",
|
48 | "tagName",
|
49 | "text",
|
50 | ];
|
51 | /**
|
52 | * Typically applied to HTMLElements to filter out disallowed props. When applied to a Component,
|
53 | * can filter props from being passed down to the children. Can also filter by a combined list of
|
54 | * supplied prop keys and the denylist (only appropriate for HTMLElements).
|
55 | *
|
56 | * @param props The original props object to filter down.
|
57 | * @param {string[]} invalidProps If supplied, overwrites the default denylist.
|
58 | * @param {boolean} shouldMerge If true, will merge supplied invalidProps and denylist together.
|
59 | */
|
60 | export function removeNonHTMLProps(props, invalidProps, shouldMerge) {
|
61 | if (invalidProps === void 0) { invalidProps = INVALID_PROPS; }
|
62 | if (shouldMerge === void 0) { shouldMerge = false; }
|
63 | if (shouldMerge) {
|
64 | invalidProps = invalidProps.concat(INVALID_PROPS);
|
65 | }
|
66 | return invalidProps.reduce(function (prev, curr) {
|
67 | // Props with hyphens (e.g. data-*) are always considered html props
|
68 | if (curr.indexOf("-") !== -1) {
|
69 | return prev;
|
70 | }
|
71 | if (prev.hasOwnProperty(curr)) {
|
72 | delete prev[curr];
|
73 | }
|
74 | return prev;
|
75 | }, __assign({}, props));
|
76 | }
|
77 | //# sourceMappingURL=props.js.map |
\ | No newline at end of file |