1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
3 | import _createClass from 'babel-runtime/helpers/createClass';
|
4 | import { generate as generateColor } from '@ant-design/colors';
|
5 | import * as React from 'react';
|
6 | export function log(message) {
|
7 | if (!(process && process.env && process.env.NODE_ENV === 'production')) {
|
8 | console.error('[@ant-design/icons-react]: ' + message + '.');
|
9 | }
|
10 | }
|
11 | export function isIconDefinition(target) {
|
12 | return typeof target === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (typeof target.icon === 'object' || typeof target.icon === 'function');
|
13 | }
|
14 | export function normalizeAttrs() {
|
15 | var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
16 |
|
17 | return Object.keys(attrs).reduce(function (acc, key) {
|
18 | var val = attrs[key];
|
19 | switch (key) {
|
20 | case 'class':
|
21 | acc.className = val;
|
22 | delete acc['class'];
|
23 | break;
|
24 | default:
|
25 | acc[key] = val;
|
26 | }
|
27 | return acc;
|
28 | }, {});
|
29 | }
|
30 | export var MiniMap = function () {
|
31 | function MiniMap() {
|
32 | _classCallCheck(this, MiniMap);
|
33 |
|
34 | this.collection = {};
|
35 | }
|
36 |
|
37 | _createClass(MiniMap, [{
|
38 | key: 'clear',
|
39 | value: function clear() {
|
40 | this.collection = {};
|
41 | }
|
42 | }, {
|
43 | key: 'delete',
|
44 | value: function _delete(key) {
|
45 | return delete this.collection[key];
|
46 | }
|
47 | }, {
|
48 | key: 'get',
|
49 | value: function get(key) {
|
50 | return this.collection[key];
|
51 | }
|
52 | }, {
|
53 | key: 'has',
|
54 | value: function has(key) {
|
55 | return Boolean(this.collection[key]);
|
56 | }
|
57 | }, {
|
58 | key: 'set',
|
59 | value: function set(key, value) {
|
60 | this.collection[key] = value;
|
61 | return this;
|
62 | }
|
63 | }, {
|
64 | key: 'size',
|
65 | get: function get() {
|
66 | return Object.keys(this.collection).length;
|
67 | }
|
68 | }]);
|
69 |
|
70 | return MiniMap;
|
71 | }();
|
72 | export function generate(node, key, rootProps) {
|
73 | if (!rootProps) {
|
74 | return React.createElement(node.tag, _extends({ key: key }, normalizeAttrs(node.attrs)), (node.children || []).map(function (child, index) {
|
75 | return generate(child, key + '-' + node.tag + '-' + index);
|
76 | }));
|
77 | }
|
78 | return React.createElement(node.tag, _extends({
|
79 | key: key
|
80 | }, normalizeAttrs(node.attrs), rootProps), (node.children || []).map(function (child, index) {
|
81 | return generate(child, key + '-' + node.tag + '-' + index);
|
82 | }));
|
83 | }
|
84 | export function getSecondaryColor(primaryColor) {
|
85 |
|
86 | return generateColor(primaryColor)[0];
|
87 | }
|
88 | export function withSuffix(name, theme) {
|
89 | switch (theme) {
|
90 | case 'fill':
|
91 | return name + '-fill';
|
92 | case 'outline':
|
93 | return name + '-o';
|
94 | case 'twotone':
|
95 | return name + '-twotone';
|
96 | default:
|
97 | throw new TypeError('Unknown theme type: ' + theme + ', name: ' + name);
|
98 | }
|
99 | } |
\ | No newline at end of file |