1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.createReactRef = exports.isElementOfType = exports.getDisplayName = exports.ensureElement = exports.isReactChildrenElementOrElements = exports.isReactNodeEmpty = void 0;
|
19 | var tslib_1 = require("tslib");
|
20 | var React = tslib_1.__importStar(require("react"));
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | function isReactNodeEmpty(node, skipArray) {
|
27 | if (skipArray === void 0) { skipArray = false; }
|
28 | return (node == null ||
|
29 | node === "" ||
|
30 | node === false ||
|
31 | (!skipArray &&
|
32 | Array.isArray(node) &&
|
33 |
|
34 | (node.length === 0 || node.every(function (n) { return isReactNodeEmpty(n, true); }))));
|
35 | }
|
36 | exports.isReactNodeEmpty = isReactNodeEmpty;
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | function isReactChildrenElementOrElements(children) {
|
43 | return !isReactNodeEmpty(children, true) && children !== true;
|
44 | }
|
45 | exports.isReactChildrenElementOrElements = isReactChildrenElementOrElements;
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | function ensureElement(child, tagName) {
|
52 | if (tagName === void 0) { tagName = "span"; }
|
53 | if (child == null || typeof child === "boolean") {
|
54 | return undefined;
|
55 | }
|
56 | else if (typeof child === "string") {
|
57 |
|
58 | return child.trim().length > 0 ? React.createElement(tagName, {}, child) : undefined;
|
59 | }
|
60 | else if (typeof child === "number" || typeof child.type === "symbol" || Array.isArray(child)) {
|
61 |
|
62 | return React.createElement(tagName, {}, child);
|
63 | }
|
64 | else if (isReactElement(child)) {
|
65 | return child;
|
66 | }
|
67 | else {
|
68 |
|
69 | return undefined;
|
70 | }
|
71 | }
|
72 | exports.ensureElement = ensureElement;
|
73 | function isReactElement(child) {
|
74 | return (typeof child === "object" &&
|
75 | typeof child.type !== "undefined" &&
|
76 | typeof child.props !== "undefined");
|
77 | }
|
78 |
|
79 |
|
80 |
|
81 | function getDisplayName(ComponentClass) {
|
82 | return ComponentClass.displayName || ComponentClass.name || "Unknown";
|
83 | }
|
84 | exports.getDisplayName = getDisplayName;
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | function isElementOfType(element, ComponentType) {
|
97 | return (element != null &&
|
98 | element.type != null &&
|
99 | element.type.displayName != null &&
|
100 | element.type.displayName === ComponentType.displayName);
|
101 | }
|
102 | exports.isElementOfType = isElementOfType;
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | function createReactRef() {
|
109 | return typeof React.createRef !== "undefined" ? React.createRef() : { current: null };
|
110 | }
|
111 | exports.createReactRef = createReactRef;
|
112 |
|
\ | No newline at end of file |