1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", {
|
3 | value: true
|
4 | });
|
5 | Object.defineProperty(exports, "default", {
|
6 | enumerable: true,
|
7 | get: function() {
|
8 | return create;
|
9 | }
|
10 | });
|
11 | var _react = _interop_require_wildcard(require("react"));
|
12 | var _Icon = _interop_require_default(require("./Icon"));
|
13 | function _define_property(obj, key, value) {
|
14 | if (key in obj) {
|
15 | Object.defineProperty(obj, key, {
|
16 | value: value,
|
17 | enumerable: true,
|
18 | configurable: true,
|
19 | writable: true
|
20 | });
|
21 | } else {
|
22 | obj[key] = value;
|
23 | }
|
24 | return obj;
|
25 | }
|
26 | function _interop_require_default(obj) {
|
27 | return obj && obj.__esModule ? obj : {
|
28 | default: obj
|
29 | };
|
30 | }
|
31 | function _getRequireWildcardCache(nodeInterop) {
|
32 | if (typeof WeakMap !== "function") return null;
|
33 | var cacheBabelInterop = new WeakMap();
|
34 | var cacheNodeInterop = new WeakMap();
|
35 | return (_getRequireWildcardCache = function(nodeInterop) {
|
36 | return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
37 | })(nodeInterop);
|
38 | }
|
39 | function _interop_require_wildcard(obj, nodeInterop) {
|
40 | if (!nodeInterop && obj && obj.__esModule) {
|
41 | return obj;
|
42 | }
|
43 | if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
44 | return {
|
45 | default: obj
|
46 | };
|
47 | }
|
48 | var cache = _getRequireWildcardCache(nodeInterop);
|
49 | if (cache && cache.has(obj)) {
|
50 | return cache.get(obj);
|
51 | }
|
52 | var newObj = {};
|
53 | var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
54 | for(var key in obj){
|
55 | if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
56 | var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
57 | if (desc && (desc.get || desc.set)) {
|
58 | Object.defineProperty(newObj, key, desc);
|
59 | } else {
|
60 | newObj[key] = obj[key];
|
61 | }
|
62 | }
|
63 | }
|
64 | newObj.default = obj;
|
65 | if (cache) {
|
66 | cache.set(obj, newObj);
|
67 | }
|
68 | return newObj;
|
69 | }
|
70 | function _object_spread(target) {
|
71 | for(var i = 1; i < arguments.length; i++){
|
72 | var source = arguments[i] != null ? arguments[i] : {};
|
73 | var ownKeys = Object.keys(source);
|
74 | if (typeof Object.getOwnPropertySymbols === "function") {
|
75 | ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
76 | return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
77 | }));
|
78 | }
|
79 | ownKeys.forEach(function(key) {
|
80 | _define_property(target, key, source[key]);
|
81 | });
|
82 | }
|
83 | return target;
|
84 | }
|
85 | function ownKeys(object, enumerableOnly) {
|
86 | var keys = Object.keys(object);
|
87 | if (Object.getOwnPropertySymbols) {
|
88 | var symbols = Object.getOwnPropertySymbols(object);
|
89 | if (enumerableOnly) {
|
90 | symbols = symbols.filter(function(sym) {
|
91 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
92 | });
|
93 | }
|
94 | keys.push.apply(keys, symbols);
|
95 | }
|
96 | return keys;
|
97 | }
|
98 | function _object_spread_props(target, source) {
|
99 | source = source != null ? source : {};
|
100 | if (Object.getOwnPropertyDescriptors) {
|
101 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
102 | } else {
|
103 | ownKeys(Object(source)).forEach(function(key) {
|
104 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
105 | });
|
106 | }
|
107 | return target;
|
108 | }
|
109 | function _object_without_properties(source, excluded) {
|
110 | if (source == null) return {};
|
111 | var target = _object_without_properties_loose(source, excluded);
|
112 | var key, i;
|
113 | if (Object.getOwnPropertySymbols) {
|
114 | var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
115 | for(i = 0; i < sourceSymbolKeys.length; i++){
|
116 | key = sourceSymbolKeys[i];
|
117 | if (excluded.indexOf(key) >= 0) continue;
|
118 | if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
119 | target[key] = source[key];
|
120 | }
|
121 | }
|
122 | return target;
|
123 | }
|
124 | function _object_without_properties_loose(source, excluded) {
|
125 | if (source == null) return {};
|
126 | var target = {};
|
127 | var sourceKeys = Object.keys(source);
|
128 | var key, i;
|
129 | for(i = 0; i < sourceKeys.length; i++){
|
130 | key = sourceKeys[i];
|
131 | if (excluded.indexOf(key) >= 0) continue;
|
132 | target[key] = source[key];
|
133 | }
|
134 | return target;
|
135 | }
|
136 | var customCache = new Set();
|
137 | function isValidCustomScriptUrl(scriptUrl) {
|
138 | return Boolean(typeof scriptUrl === "string" && scriptUrl.length && !customCache.has(scriptUrl));
|
139 | }
|
140 | function createScriptUrlElements(scriptUrls) {
|
141 | var index = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
142 | var currentScriptUrl = scriptUrls[index];
|
143 | if (isValidCustomScriptUrl(currentScriptUrl)) {
|
144 | var script = document.createElement("script");
|
145 | script.setAttribute("src", currentScriptUrl);
|
146 | script.setAttribute("data-namespace", currentScriptUrl);
|
147 | if (scriptUrls.length > index + 1) {
|
148 | script.onload = function() {
|
149 | createScriptUrlElements(scriptUrls, index + 1);
|
150 | };
|
151 | script.onerror = function() {
|
152 | createScriptUrlElements(scriptUrls, index + 1);
|
153 | };
|
154 | }
|
155 | customCache.add(currentScriptUrl);
|
156 | document.body.appendChild(script);
|
157 | }
|
158 | }
|
159 | function create() {
|
160 | var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
161 | var scriptUrl = options.scriptUrl, _options_extraCommonProps = options.extraCommonProps, extraCommonProps = _options_extraCommonProps === void 0 ? {} : _options_extraCommonProps;
|
162 | |
163 |
|
164 |
|
165 |
|
166 |
|
167 | if (scriptUrl && typeof document !== "undefined" && typeof window !== "undefined" && typeof document.createElement === "function") {
|
168 | if (Array.isArray(scriptUrl)) {
|
169 |
|
170 | createScriptUrlElements(scriptUrl.reverse());
|
171 | } else {
|
172 | createScriptUrlElements([
|
173 | scriptUrl
|
174 | ]);
|
175 | }
|
176 | }
|
177 | var Iconfont = _react.forwardRef(function(props, ref) {
|
178 | var type = props.type, children = props.children, restProps = _object_without_properties(props, [
|
179 | "type",
|
180 | "children"
|
181 | ]);
|
182 |
|
183 | var content = null;
|
184 | if (props.type) {
|
185 | content = _react.createElement("use", {
|
186 | xlinkHref: "#".concat(type)
|
187 | });
|
188 | }
|
189 | if (children) {
|
190 | content = children;
|
191 | }
|
192 | return _react.createElement(_Icon.default, _object_spread_props(_object_spread({}, extraCommonProps, restProps), {
|
193 | ref: ref
|
194 | }), content);
|
195 | });
|
196 | Iconfont.displayName = "Iconfont";
|
197 | return Iconfont;
|
198 | }
|