1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.MiniMap = undefined;
|
7 |
|
8 | var _extends2 = require('babel-runtime/helpers/extends');
|
9 |
|
10 | var _extends3 = _interopRequireDefault(_extends2);
|
11 |
|
12 | var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
13 |
|
14 | var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
15 |
|
16 | var _createClass2 = require('babel-runtime/helpers/createClass');
|
17 |
|
18 | var _createClass3 = _interopRequireDefault(_createClass2);
|
19 |
|
20 | exports.log = log;
|
21 | exports.isIconDefinition = isIconDefinition;
|
22 | exports.normalizeAttrs = normalizeAttrs;
|
23 | exports.generate = generate;
|
24 | exports.getSecondaryColor = getSecondaryColor;
|
25 | exports.withSuffix = withSuffix;
|
26 |
|
27 | var _colors = require('@ant-design/colors');
|
28 |
|
29 | var _react = require('react');
|
30 |
|
31 | var React = _interopRequireWildcard(_react);
|
32 |
|
33 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
34 |
|
35 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
36 |
|
37 | function log(message) {
|
38 | if (!(process && process.env && process.env.NODE_ENV === 'production')) {
|
39 | console.error('[@ant-design/icons-react]: ' + message + '.');
|
40 | }
|
41 | }
|
42 | function isIconDefinition(target) {
|
43 | return typeof target === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (typeof target.icon === 'object' || typeof target.icon === 'function');
|
44 | }
|
45 | function normalizeAttrs() {
|
46 | var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
47 |
|
48 | return Object.keys(attrs).reduce(function (acc, key) {
|
49 | var val = attrs[key];
|
50 | switch (key) {
|
51 | case 'class':
|
52 | acc.className = val;
|
53 | delete acc['class'];
|
54 | break;
|
55 | default:
|
56 | acc[key] = val;
|
57 | }
|
58 | return acc;
|
59 | }, {});
|
60 | }
|
61 |
|
62 | var MiniMap = exports.MiniMap = function () {
|
63 | function MiniMap() {
|
64 | (0, _classCallCheck3['default'])(this, MiniMap);
|
65 |
|
66 | this.collection = {};
|
67 | }
|
68 |
|
69 | (0, _createClass3['default'])(MiniMap, [{
|
70 | key: 'clear',
|
71 | value: function clear() {
|
72 | this.collection = {};
|
73 | }
|
74 | }, {
|
75 | key: 'delete',
|
76 | value: function _delete(key) {
|
77 | return delete this.collection[key];
|
78 | }
|
79 | }, {
|
80 | key: 'get',
|
81 | value: function get(key) {
|
82 | return this.collection[key];
|
83 | }
|
84 | }, {
|
85 | key: 'has',
|
86 | value: function has(key) {
|
87 | return Boolean(this.collection[key]);
|
88 | }
|
89 | }, {
|
90 | key: 'set',
|
91 | value: function set(key, value) {
|
92 | this.collection[key] = value;
|
93 | return this;
|
94 | }
|
95 | }, {
|
96 | key: 'size',
|
97 | get: function get() {
|
98 | return Object.keys(this.collection).length;
|
99 | }
|
100 | }]);
|
101 | return MiniMap;
|
102 | }();
|
103 |
|
104 | function generate(node, key, rootProps) {
|
105 | if (!rootProps) {
|
106 | return React.createElement(node.tag, (0, _extends3['default'])({ key: key }, normalizeAttrs(node.attrs)), (node.children || []).map(function (child, index) {
|
107 | return generate(child, key + '-' + node.tag + '-' + index);
|
108 | }));
|
109 | }
|
110 | return React.createElement(node.tag, (0, _extends3['default'])({
|
111 | key: key
|
112 | }, normalizeAttrs(node.attrs), rootProps), (node.children || []).map(function (child, index) {
|
113 | return generate(child, key + '-' + node.tag + '-' + index);
|
114 | }));
|
115 | }
|
116 | function getSecondaryColor(primaryColor) {
|
117 |
|
118 | return (0, _colors.generate)(primaryColor)[0];
|
119 | }
|
120 | function withSuffix(name, theme) {
|
121 | switch (theme) {
|
122 | case 'fill':
|
123 | return name + '-fill';
|
124 | case 'outline':
|
125 | return name + '-o';
|
126 | case 'twotone':
|
127 | return name + '-twotone';
|
128 | default:
|
129 | throw new TypeError('Unknown theme type: ' + theme + ', name: ' + name);
|
130 | }
|
131 | } |
\ | No newline at end of file |