1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
3 | import React from 'react';
|
4 | import cx from 'classnames';
|
5 | import ConfigProvider from '../config-provider';
|
6 | import Icon from './index';
|
7 |
|
8 | var customCache = new Set();
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export default function createFromIconfontCN() {
|
15 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
16 | var scriptUrl = options.scriptUrl,
|
17 | _options$extraCommonP = options.extraCommonProps,
|
18 | extraCommonProps = _options$extraCommonP === undefined ? {} : _options$extraCommonP;
|
19 |
|
20 | var hasExist = customCache.has(scriptUrl);
|
21 |
|
22 | if (document.querySelector('script[data-namespace="' + scriptUrl + '"]')) {
|
23 | hasExist = true;
|
24 | }
|
25 |
|
26 | |
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | if (typeof document !== 'undefined' && typeof window !== 'undefined' && typeof document.createElement === 'function' && typeof scriptUrl === 'string' && scriptUrl.length && !hasExist) {
|
33 | var script = document.createElement('script');
|
34 | script.setAttribute('src', scriptUrl);
|
35 | script.setAttribute('data-namespace', scriptUrl);
|
36 | customCache.add(scriptUrl);
|
37 | document.body.appendChild(script);
|
38 | }
|
39 |
|
40 | var Iconfont = function Iconfont(props) {
|
41 | var _cx;
|
42 |
|
43 | var type = props.type,
|
44 | size = props.size,
|
45 | children = props.children,
|
46 | className = props.className,
|
47 | _props$prefix = props.prefix,
|
48 | prefix = _props$prefix === undefined ? 'next-' : _props$prefix,
|
49 | others = _objectWithoutProperties(props, ['type', 'size', 'children', 'className', 'prefix']);
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | var content = null;
|
55 | if (props.type) {
|
56 | content = React.createElement('use', { xlinkHref: '#' + type });
|
57 | }
|
58 | if (children) {
|
59 | content = children;
|
60 | }
|
61 |
|
62 | var classes = cx((_cx = {}, _cx[prefix + 'icon-remote'] = true, _cx), className);
|
63 |
|
64 | return React.createElement(
|
65 | Icon,
|
66 | { size: size },
|
67 | React.createElement(
|
68 | 'svg',
|
69 | _extends({
|
70 | className: classes,
|
71 | focusable: false
|
72 | }, others, extraCommonProps),
|
73 | content
|
74 | )
|
75 | );
|
76 | };
|
77 |
|
78 | Iconfont.displayName = 'Iconfont';
|
79 |
|
80 | return ConfigProvider.config(Iconfont);
|
81 | } |
\ | No newline at end of file |