1 | var __assign = this && this.__assign || function () {
|
2 | __assign = Object.assign || function (t) {
|
3 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4 | s = arguments[i];
|
5 |
|
6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
7 | }
|
8 |
|
9 | return t;
|
10 | };
|
11 |
|
12 | return __assign.apply(this, arguments);
|
13 | };
|
14 |
|
15 | var __rest = this && this.__rest || function (s, e) {
|
16 | var t = {};
|
17 |
|
18 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
19 |
|
20 | if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
21 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
22 | }
|
23 | return t;
|
24 | };
|
25 |
|
26 | import React from 'react';
|
27 | import { IconContext, DefaultContext } from './iconContext';
|
28 |
|
29 | function Tree2Element(tree) {
|
30 | return tree && tree.map(function (node, i) {
|
31 | return React.createElement(node.tag, __assign({
|
32 | key: i
|
33 | }, node.attr), Tree2Element(node.child));
|
34 | });
|
35 | }
|
36 |
|
37 | export function GenIcon(data) {
|
38 | return function (props) {
|
39 | return React.createElement(IconBase, __assign({
|
40 | attr: __assign({}, data.attr)
|
41 | }, props), Tree2Element(data.child));
|
42 | };
|
43 | }
|
44 | export function IconBase(props) {
|
45 | var elem = function (conf) {
|
46 | var attr = props.attr,
|
47 | size = props.size,
|
48 | title = props.title,
|
49 | svgProps = __rest(props, ["attr", "size", "title"]);
|
50 |
|
51 | var computedSize = size || conf.size || "1em";
|
52 | var className;
|
53 | if (conf.className) className = conf.className;
|
54 | if (props.className) className = (className ? className + ' ' : '') + props.className;
|
55 | return React.createElement("svg", __assign({
|
56 | stroke: "currentColor",
|
57 | fill: "currentColor",
|
58 | strokeWidth: "0"
|
59 | }, conf.attr, attr, svgProps, {
|
60 | className: className,
|
61 | style: __assign(__assign({
|
62 | color: props.color || conf.color
|
63 | }, conf.style), props.style),
|
64 | height: computedSize,
|
65 | width: computedSize,
|
66 | xmlns: "http://www.w3.org/2000/svg"
|
67 | }), title && React.createElement("title", null, title), props.children);
|
68 | };
|
69 |
|
70 | return IconContext !== undefined ? React.createElement(IconContext.Consumer, null, function (conf) {
|
71 | return elem(conf);
|
72 | }) : elem(DefaultContext);
|
73 | } |
\ | No newline at end of file |