react-inlinesvg 3.0.3 → 3.1.0-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/helpers.js DELETED
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.omit = exports.randomString = exports.supportsInlineSVG = exports.isSupportedEnvironment = exports.canUseDOM = exports.STATUS = void 0;
4
- var exenv_1 = require("exenv");
5
- exports.STATUS = {
6
- IDLE: 'idle',
7
- LOADING: 'loading',
8
- LOADED: 'loaded',
9
- FAILED: 'failed',
10
- READY: 'ready',
11
- UNSUPPORTED: 'unsupported',
12
- };
13
- function canUseDOM() {
14
- return exenv_1.canUseDOM;
15
- }
16
- exports.canUseDOM = canUseDOM;
17
- function isSupportedEnvironment() {
18
- return supportsInlineSVG() && typeof window !== 'undefined' && window !== null;
19
- }
20
- exports.isSupportedEnvironment = isSupportedEnvironment;
21
- function supportsInlineSVG() {
22
- /* istanbul ignore next */
23
- if (!document) {
24
- return false;
25
- }
26
- var div = document.createElement('div');
27
- div.innerHTML = '<svg />';
28
- var svg = div.firstChild;
29
- return !!svg && svg.namespaceURI === 'http://www.w3.org/2000/svg';
30
- }
31
- exports.supportsInlineSVG = supportsInlineSVG;
32
- function randomCharacter(character) {
33
- return character[Math.floor(Math.random() * character.length)];
34
- }
35
- function randomString(length) {
36
- var letters = 'abcdefghijklmnopqrstuvwxyz';
37
- var numbers = '1234567890';
38
- var charset = "".concat(letters).concat(letters.toUpperCase()).concat(numbers);
39
- var R = '';
40
- for (var index = 0; index < length; index++) {
41
- R += randomCharacter(charset);
42
- }
43
- return R;
44
- }
45
- exports.randomString = randomString;
46
- /**
47
- * Remove properties from an object
48
- */
49
- function omit(input) {
50
- var filter = [];
51
- for (var _i = 1; _i < arguments.length; _i++) {
52
- filter[_i - 1] = arguments[_i];
53
- }
54
- var output = {};
55
- for (var key in input) {
56
- /* istanbul ignore else */
57
- if ({}.hasOwnProperty.call(input, key)) {
58
- if (!filter.includes(key)) {
59
- output[key] = input[key];
60
- }
61
- }
62
- }
63
- return output;
64
- }
65
- exports.omit = omit;
66
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAAA,+BAAmD;AAItC,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,aAAa;CAClB,CAAC;AAEX,SAAgB,SAAS;IACvB,OAAO,iBAAa,CAAC;AACvB,CAAC;AAFD,8BAEC;AAED,SAAgB,sBAAsB;IACpC,OAAO,iBAAiB,EAAE,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,IAAI,CAAC;AACjF,CAAC;AAFD,wDAEC;AAED,SAAgB,iBAAiB;IAC/B,0BAA0B;IAC1B,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,KAAK,CAAC;KACd;IAED,IAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAE1C,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC;IAC1B,IAAM,GAAG,GAAG,GAAG,CAAC,UAA2B,CAAC;IAE5C,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,YAAY,KAAK,4BAA4B,CAAC;AACpE,CAAC;AAZD,8CAYC;AAED,SAAS,eAAe,CAAC,SAAiB;IACxC,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,SAAgB,YAAY,CAAC,MAAc;IACzC,IAAM,OAAO,GAAG,4BAA4B,CAAC;IAC7C,IAAM,OAAO,GAAG,YAAY,CAAC;IAC7B,IAAM,OAAO,GAAG,UAAG,OAAO,SAAG,OAAO,CAAC,WAAW,EAAE,SAAG,OAAO,CAAE,CAAC;IAE/D,IAAI,CAAC,GAAG,EAAE,CAAC;IAEX,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE;QAC3C,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;KAC/B;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AAZD,oCAYC;AAED;;GAEG;AACH,SAAgB,IAAI,CAClB,KAAQ;IACR,gBAAc;SAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;QAAd,+BAAc;;IAEd,IAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,KAAK,IAAM,GAAG,IAAI,KAAK,EAAE;QACvB,0BAA0B;QAC1B,IAAI,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YACtC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAmB,CAAC,EAAE;gBACzC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;aAC1B;SACF;KACF;IAED,OAAO,MAAoB,CAAC;AAC9B,CAAC;AAhBD,oBAgBC"}
package/lib/index.d.ts DELETED
@@ -1,28 +0,0 @@
1
- import * as React from 'react';
2
- import { Props, State, StorageItem } from './types';
3
- export declare const cacheStore: {
4
- [key: string]: StorageItem;
5
- };
6
- export default class InlineSVG extends React.PureComponent<Props, State> {
7
- private readonly hash;
8
- private isActive;
9
- private isInitialized;
10
- static defaultProps: {
11
- cacheRequests: boolean;
12
- uniquifyIDs: boolean;
13
- };
14
- constructor(props: Props);
15
- componentDidMount(): void;
16
- componentDidUpdate(previousProps: Props, previousState: State): void;
17
- componentWillUnmount(): void;
18
- private getElement;
19
- private getNode;
20
- private handleError;
21
- private handleLoad;
22
- private load;
23
- private processSVG;
24
- private request;
25
- private updateSVGAttributes;
26
- render(): React.ReactNode;
27
- }
28
- export * from './types';
package/lib/index.js DELETED
@@ -1,488 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
- if (k2 === undefined) k2 = k;
30
- var desc = Object.getOwnPropertyDescriptor(m, k);
31
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
- desc = { enumerable: true, get: function() { return m[k]; } };
33
- }
34
- Object.defineProperty(o, k2, desc);
35
- }) : (function(o, m, k, k2) {
36
- if (k2 === undefined) k2 = k;
37
- o[k2] = m[k];
38
- }));
39
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
40
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
41
- };
42
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
43
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
44
- return new (P || (P = Promise))(function (resolve, reject) {
45
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
46
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
47
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
48
- step((generator = generator.apply(thisArg, _arguments || [])).next());
49
- });
50
- };
51
- var __generator = (this && this.__generator) || function (thisArg, body) {
52
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
53
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
54
- function verb(n) { return function (v) { return step([n, v]); }; }
55
- function step(op) {
56
- if (f) throw new TypeError("Generator is already executing.");
57
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
58
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
59
- if (y = 0, t) op = [op[0] & 2, t.value];
60
- switch (op[0]) {
61
- case 0: case 1: t = op; break;
62
- case 4: _.label++; return { value: op[1], done: false };
63
- case 5: _.label++; y = op[1]; op = [0]; continue;
64
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
65
- default:
66
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
67
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
68
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
69
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
70
- if (t[2]) _.ops.pop();
71
- _.trys.pop(); continue;
72
- }
73
- op = body.call(thisArg, _);
74
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
75
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
76
- }
77
- };
78
- var __read = (this && this.__read) || function (o, n) {
79
- var m = typeof Symbol === "function" && o[Symbol.iterator];
80
- if (!m) return o;
81
- var i = m.call(o), r, ar = [], e;
82
- try {
83
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
84
- }
85
- catch (error) { e = { error: error }; }
86
- finally {
87
- try {
88
- if (r && !r.done && (m = i["return"])) m.call(i);
89
- }
90
- finally { if (e) throw e.error; }
91
- }
92
- return ar;
93
- };
94
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
95
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
96
- if (ar || !(i in from)) {
97
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
98
- ar[i] = from[i];
99
- }
100
- }
101
- return to.concat(ar || Array.prototype.slice.call(from));
102
- };
103
- Object.defineProperty(exports, "__esModule", { value: true });
104
- exports.cacheStore = void 0;
105
- var React = require("react");
106
- var react_from_dom_1 = require("react-from-dom");
107
- var helpers_1 = require("./helpers");
108
- exports.cacheStore = Object.create(null);
109
- var InlineSVG = /** @class */ (function (_super) {
110
- __extends(InlineSVG, _super);
111
- function InlineSVG(props) {
112
- var _this = _super.call(this, props) || this;
113
- Object.defineProperty(_this, "hash", {
114
- enumerable: true,
115
- configurable: true,
116
- writable: true,
117
- value: void 0
118
- });
119
- Object.defineProperty(_this, "isActive", {
120
- enumerable: true,
121
- configurable: true,
122
- writable: true,
123
- value: false
124
- });
125
- Object.defineProperty(_this, "isInitialized", {
126
- enumerable: true,
127
- configurable: true,
128
- writable: true,
129
- value: false
130
- });
131
- Object.defineProperty(_this, "handleError", {
132
- enumerable: true,
133
- configurable: true,
134
- writable: true,
135
- value: function (error) {
136
- var onError = _this.props.onError;
137
- var status = error.message === 'Browser does not support SVG' ? helpers_1.STATUS.UNSUPPORTED : helpers_1.STATUS.FAILED;
138
- /* istanbul ignore else */
139
- if (_this.isActive) {
140
- _this.setState({ status: status }, function () {
141
- /* istanbul ignore else */
142
- if (typeof onError === 'function') {
143
- onError(error);
144
- }
145
- });
146
- }
147
- }
148
- });
149
- Object.defineProperty(_this, "handleLoad", {
150
- enumerable: true,
151
- configurable: true,
152
- writable: true,
153
- value: function (content, hasCache) {
154
- if (hasCache === void 0) { hasCache = false; }
155
- /* istanbul ignore else */
156
- if (_this.isActive) {
157
- _this.setState({
158
- content: content,
159
- hasCache: hasCache,
160
- status: helpers_1.STATUS.LOADED,
161
- }, _this.getElement);
162
- }
163
- }
164
- });
165
- Object.defineProperty(_this, "request", {
166
- enumerable: true,
167
- configurable: true,
168
- writable: true,
169
- value: function () { return __awaiter(_this, void 0, void 0, function () {
170
- var _a, cacheRequests, fetchOptions, src, response, contentType, _b, fileType_1, content, currentSrc, cache, error_1, cache;
171
- return __generator(this, function (_c) {
172
- switch (_c.label) {
173
- case 0:
174
- _a = this.props, cacheRequests = _a.cacheRequests, fetchOptions = _a.fetchOptions, src = _a.src;
175
- if (cacheRequests) {
176
- exports.cacheStore[src] = { content: '', status: helpers_1.STATUS.LOADING };
177
- }
178
- _c.label = 1;
179
- case 1:
180
- _c.trys.push([1, 4, , 5]);
181
- return [4 /*yield*/, fetch(src, fetchOptions)];
182
- case 2:
183
- response = _c.sent();
184
- contentType = response.headers.get('content-type');
185
- _b = __read((contentType || '').split(/ ?; ?/), 1), fileType_1 = _b[0];
186
- if (response.status > 299) {
187
- throw new Error('Not found');
188
- }
189
- if (!['image/svg+xml', 'text/plain'].some(function (d) { return fileType_1.includes(d); })) {
190
- throw new Error("Content type isn't valid: ".concat(fileType_1));
191
- }
192
- return [4 /*yield*/, response.text()];
193
- case 3:
194
- content = _c.sent();
195
- currentSrc = this.props.src;
196
- // the current src don't match the previous one, skipping...
197
- if (src !== currentSrc) {
198
- if (exports.cacheStore[src].status === helpers_1.STATUS.LOADING) {
199
- delete exports.cacheStore[src];
200
- }
201
- return [2 /*return*/];
202
- }
203
- this.handleLoad(content);
204
- /* istanbul ignore else */
205
- if (cacheRequests) {
206
- cache = exports.cacheStore[src];
207
- /* istanbul ignore else */
208
- if (cache) {
209
- cache.content = content;
210
- cache.status = helpers_1.STATUS.LOADED;
211
- }
212
- }
213
- return [3 /*break*/, 5];
214
- case 4:
215
- error_1 = _c.sent();
216
- this.handleError(error_1);
217
- /* istanbul ignore else */
218
- if (cacheRequests) {
219
- cache = exports.cacheStore[src];
220
- /* istanbul ignore else */
221
- if (cache) {
222
- delete exports.cacheStore[src];
223
- }
224
- }
225
- return [3 /*break*/, 5];
226
- case 5: return [2 /*return*/];
227
- }
228
- });
229
- }); }
230
- });
231
- _this.state = {
232
- content: '',
233
- element: null,
234
- hasCache: !!props.cacheRequests && !!exports.cacheStore[props.src],
235
- status: helpers_1.STATUS.IDLE,
236
- };
237
- _this.hash = props.uniqueHash || (0, helpers_1.randomString)(8);
238
- return _this;
239
- }
240
- Object.defineProperty(InlineSVG.prototype, "componentDidMount", {
241
- enumerable: false,
242
- configurable: true,
243
- writable: true,
244
- value: function () {
245
- this.isActive = true;
246
- if (!(0, helpers_1.canUseDOM)() || this.isInitialized) {
247
- return;
248
- }
249
- var status = this.state.status;
250
- var src = this.props.src;
251
- try {
252
- /* istanbul ignore else */
253
- if (status === helpers_1.STATUS.IDLE) {
254
- /* istanbul ignore else */
255
- if (!(0, helpers_1.isSupportedEnvironment)()) {
256
- throw new Error('Browser does not support SVG');
257
- }
258
- /* istanbul ignore else */
259
- if (!src) {
260
- throw new Error('Missing src');
261
- }
262
- this.load();
263
- }
264
- }
265
- catch (error) {
266
- this.handleError(error);
267
- }
268
- this.isInitialized = true;
269
- }
270
- });
271
- Object.defineProperty(InlineSVG.prototype, "componentDidUpdate", {
272
- enumerable: false,
273
- configurable: true,
274
- writable: true,
275
- value: function (previousProps, previousState) {
276
- if (!(0, helpers_1.canUseDOM)()) {
277
- return;
278
- }
279
- var _a = this.state, hasCache = _a.hasCache, status = _a.status;
280
- var _b = this.props, onLoad = _b.onLoad, src = _b.src;
281
- if (previousState.status !== helpers_1.STATUS.READY && status === helpers_1.STATUS.READY) {
282
- /* istanbul ignore else */
283
- if (onLoad) {
284
- onLoad(src, hasCache);
285
- }
286
- }
287
- if (previousProps.src !== src) {
288
- if (!src) {
289
- this.handleError(new Error('Missing src'));
290
- return;
291
- }
292
- this.load();
293
- }
294
- }
295
- });
296
- Object.defineProperty(InlineSVG.prototype, "componentWillUnmount", {
297
- enumerable: false,
298
- configurable: true,
299
- writable: true,
300
- value: function () {
301
- this.isActive = false;
302
- }
303
- });
304
- Object.defineProperty(InlineSVG.prototype, "getElement", {
305
- enumerable: false,
306
- configurable: true,
307
- writable: true,
308
- value: function () {
309
- try {
310
- var node = this.getNode();
311
- var element = (0, react_from_dom_1.default)(node);
312
- if (!element || !React.isValidElement(element)) {
313
- throw new Error('Could not convert the src to a React element');
314
- }
315
- this.setState({
316
- element: element,
317
- status: helpers_1.STATUS.READY,
318
- });
319
- }
320
- catch (error) {
321
- this.handleError(new Error(error.message));
322
- }
323
- }
324
- });
325
- Object.defineProperty(InlineSVG.prototype, "getNode", {
326
- enumerable: false,
327
- configurable: true,
328
- writable: true,
329
- value: function () {
330
- var _a = this.props, description = _a.description, title = _a.title;
331
- try {
332
- var svgText = this.processSVG();
333
- var node = (0, react_from_dom_1.default)(svgText, { nodeOnly: true });
334
- if (!node || !(node instanceof SVGSVGElement)) {
335
- throw new Error('Could not convert the src to a DOM Node');
336
- }
337
- var svg = this.updateSVGAttributes(node);
338
- if (description) {
339
- var originalDesc = svg.querySelector('desc');
340
- if (originalDesc && originalDesc.parentNode) {
341
- originalDesc.parentNode.removeChild(originalDesc);
342
- }
343
- var descElement = document.createElementNS('http://www.w3.org/2000/svg', 'desc');
344
- descElement.innerHTML = description;
345
- svg.prepend(descElement);
346
- }
347
- if (typeof title !== 'undefined') {
348
- var originalTitle = svg.querySelector('title');
349
- if (originalTitle && originalTitle.parentNode) {
350
- originalTitle.parentNode.removeChild(originalTitle);
351
- }
352
- if (title) {
353
- var titleElement = document.createElementNS('http://www.w3.org/2000/svg', 'title');
354
- titleElement.innerHTML = title;
355
- svg.prepend(titleElement);
356
- }
357
- }
358
- return svg;
359
- }
360
- catch (error) {
361
- return this.handleError(error);
362
- }
363
- }
364
- });
365
- Object.defineProperty(InlineSVG.prototype, "load", {
366
- enumerable: false,
367
- configurable: true,
368
- writable: true,
369
- value: function () {
370
- var _this = this;
371
- /* istanbul ignore else */
372
- if (this.isActive) {
373
- this.setState({
374
- content: '',
375
- element: null,
376
- hasCache: false,
377
- status: helpers_1.STATUS.LOADING,
378
- }, function () {
379
- var _a = _this.props, cacheRequests = _a.cacheRequests, src = _a.src;
380
- var cache = cacheRequests && exports.cacheStore[src];
381
- if (cache && cache.status === helpers_1.STATUS.LOADED) {
382
- _this.handleLoad(cache.content, true);
383
- return;
384
- }
385
- var dataURI = src.match(/^data:image\/svg[^,]*?(;base64)?,(.*)/u);
386
- var inlineSrc;
387
- if (dataURI) {
388
- inlineSrc = dataURI[1] ? window.atob(dataURI[2]) : decodeURIComponent(dataURI[2]);
389
- }
390
- else if (src.includes('<svg')) {
391
- inlineSrc = src;
392
- }
393
- if (inlineSrc) {
394
- _this.handleLoad(inlineSrc);
395
- return;
396
- }
397
- _this.request();
398
- });
399
- }
400
- }
401
- });
402
- Object.defineProperty(InlineSVG.prototype, "processSVG", {
403
- enumerable: false,
404
- configurable: true,
405
- writable: true,
406
- value: function () {
407
- var content = this.state.content;
408
- var preProcessor = this.props.preProcessor;
409
- if (preProcessor) {
410
- return preProcessor(content);
411
- }
412
- return content;
413
- }
414
- });
415
- Object.defineProperty(InlineSVG.prototype, "updateSVGAttributes", {
416
- enumerable: false,
417
- configurable: true,
418
- writable: true,
419
- value: function (node) {
420
- var _this = this;
421
- var _a = this.props, _b = _a.baseURL, baseURL = _b === void 0 ? '' : _b, uniquifyIDs = _a.uniquifyIDs;
422
- var replaceableAttributes = ['id', 'href', 'xlink:href', 'xlink:role', 'xlink:arcrole'];
423
- var linkAttributes = ['href', 'xlink:href'];
424
- var isDataValue = function (name, value) {
425
- return linkAttributes.includes(name) && (value ? !value.includes('#') : false);
426
- };
427
- if (!uniquifyIDs) {
428
- return node;
429
- }
430
- __spreadArray([], __read(node.children), false).forEach(function (d) {
431
- if (d.attributes && d.attributes.length) {
432
- var attributes_1 = Object.values(d.attributes).map(function (a) {
433
- var attribute = a;
434
- var match = a.value.match(/url\((.*?)\)/);
435
- if (match && match[1]) {
436
- attribute.value = a.value.replace(match[0], "url(".concat(baseURL).concat(match[1], "__").concat(_this.hash, ")"));
437
- }
438
- return attribute;
439
- });
440
- replaceableAttributes.forEach(function (r) {
441
- var attribute = attributes_1.find(function (a) { return a.name === r; });
442
- if (attribute && !isDataValue(r, attribute.value)) {
443
- attribute.value = "".concat(attribute.value, "__").concat(_this.hash);
444
- }
445
- });
446
- }
447
- if (d.children.length) {
448
- return _this.updateSVGAttributes(d);
449
- }
450
- return d;
451
- });
452
- return node;
453
- }
454
- });
455
- Object.defineProperty(InlineSVG.prototype, "render", {
456
- enumerable: false,
457
- configurable: true,
458
- writable: true,
459
- value: function () {
460
- var _a = this.state, element = _a.element, status = _a.status;
461
- var _b = this.props, _c = _b.children, children = _c === void 0 ? null : _c, innerRef = _b.innerRef, _d = _b.loader, loader = _d === void 0 ? null : _d;
462
- var elementProps = (0, helpers_1.omit)(this.props, 'baseURL', 'cacheRequests', 'children', 'description', 'fetchOptions', 'innerRef', 'loader', 'onError', 'onLoad', 'preProcessor', 'src', 'title', 'uniqueHash', 'uniquifyIDs');
463
- if (!(0, helpers_1.canUseDOM)()) {
464
- return loader;
465
- }
466
- if (element) {
467
- return React.cloneElement(element, __assign({ ref: innerRef }, elementProps));
468
- }
469
- if ([helpers_1.STATUS.UNSUPPORTED, helpers_1.STATUS.FAILED].includes(status)) {
470
- return children;
471
- }
472
- return loader;
473
- }
474
- });
475
- Object.defineProperty(InlineSVG, "defaultProps", {
476
- enumerable: true,
477
- configurable: true,
478
- writable: true,
479
- value: {
480
- cacheRequests: true,
481
- uniquifyIDs: false,
482
- }
483
- });
484
- return InlineSVG;
485
- }(React.PureComponent));
486
- exports.default = InlineSVG;
487
- __exportStar(require("./types"), exports);
488
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,iDAAqC;AAErC,qCAA0F;AAG7E,QAAA,UAAU,GAAmC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAE9E;IAAuC,6BAAiC;IAUtE,mBAAY,KAAY;QAAxB,YACE,kBAAM,KAAK,CAAC,SAUb;QApBgB;;;;;WAAa;QACtB;;;;mBAAW,KAAK;WAAC;QACjB;;;;mBAAgB,KAAK;WAAC;QAmJtB;;;;mBAAc,UAAC,KAAyB;gBACtC,IAAA,OAAO,GAAK,KAAI,CAAC,KAAK,QAAf,CAAgB;gBAC/B,IAAM,MAAM,GACV,KAAK,CAAC,OAAO,KAAK,8BAA8B,CAAC,CAAC,CAAC,gBAAM,CAAC,WAAW,CAAC,CAAC,CAAC,gBAAM,CAAC,MAAM,CAAC;gBAExF,0BAA0B;gBAC1B,IAAI,KAAI,CAAC,QAAQ,EAAE;oBACjB,KAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,QAAA,EAAE,EAAE;wBACxB,0BAA0B;wBAC1B,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;4BACjC,OAAO,CAAC,KAAK,CAAC,CAAC;yBAChB;oBACH,CAAC,CAAC,CAAC;iBACJ;YACH,CAAC;WAAC;QAEM;;;;mBAAa,UAAC,OAAe,EAAE,QAAgB;gBAAhB,yBAAA,EAAA,gBAAgB;gBACrD,0BAA0B;gBAC1B,IAAI,KAAI,CAAC,QAAQ,EAAE;oBACjB,KAAI,CAAC,QAAQ,CACX;wBACE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CAAC,aAAa,GAiXzD;kBAjXoB,SAAS;AAmX9B,0CAAwB"}
package/lib/types.d.ts DELETED
@@ -1,39 +0,0 @@
1
- import * as React from 'react';
2
- import { STATUS } from './helpers';
3
- export type ErrorCallback = (error: Error | FetchError) => void;
4
- export type LoadCallback = (src: string, isCached: boolean) => void;
5
- export type PlainObject<T = unknown> = Record<string, T>;
6
- export type PreProcessorCallback = (code: string) => string;
7
- export interface Props extends Omit<React.SVGProps<SVGElement>, 'onLoad' | 'onError' | 'ref'> {
8
- baseURL?: string;
9
- cacheRequests?: boolean;
10
- children?: React.ReactNode;
11
- description?: string;
12
- fetchOptions?: RequestInit;
13
- innerRef?: React.Ref<SVGElement>;
14
- loader?: React.ReactNode;
15
- onError?: ErrorCallback;
16
- onLoad?: LoadCallback;
17
- preProcessor?: PreProcessorCallback;
18
- src: string;
19
- title?: string | null;
20
- uniqueHash?: string;
21
- uniquifyIDs?: boolean;
22
- }
23
- export interface State {
24
- content: string;
25
- element: React.ReactNode;
26
- hasCache: boolean;
27
- status: Status;
28
- }
29
- export interface FetchError extends Error {
30
- code: string;
31
- errno: string;
32
- message: string;
33
- type: string;
34
- }
35
- export type Status = (typeof STATUS)[keyof typeof STATUS];
36
- export interface StorageItem {
37
- content: string;
38
- status: Status;
39
- }
package/lib/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
package/lib/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}