react-svg 16.0.0 → 16.1.0

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/README.md CHANGED
@@ -52,12 +52,14 @@ root.render(<ReactSVG src="svg.svg" />)
52
52
  - `src` - The SVG URL.
53
53
  - `afterInjection(svg)` - _Optional_ Function to call after the SVG is injected. `svg` is the injected SVG DOM element. If an error occurs during execution it will be routed to the `onError` callback, and if a `fallback` is specified it will be rendered. Defaults to `() => {}`.
54
54
  - `beforeInjection(svg)` - _Optional_ Function to call just before the SVG is injected. `svg` is the SVG DOM element which is about to be injected. If an error occurs during execution it will be routed to the `onError` callback, and if a `fallback` is specified it will be rendered. Defaults to `() => {}`.
55
+ - `desc` - _Optional_ String used for SVG `<desc>` element content. If a `<desc>` exists it will be replaced, otherwise a new `<desc>` is created. Defaults to `''`, which is a noop.
55
56
  - `evalScripts` - _Optional_ Run any script blocks found in the SVG. One of `'always'`, `'once'`, or `'never'`. Defaults to `'never'`.
56
57
  - `fallback` - _Optional_ Fallback to use if an error occurs during injection, or if errors are thrown from the `beforeInjection` or `afterInjection` functions. Can be a string, class component, or function component. Defaults to `null`.
57
58
  - `httpRequestWithCredentials` - _Optional_ Boolean indicating if cross-site Access-Control requests for the SVG should be made using credentials. Defaults to `false`.
58
59
  - `loading` - _Optional_ Component to use during loading. Can be a string, class component, or function component. Defaults to `null`.
59
60
  - `onError(error)` - _Optional_ Function to call if an error occurs during injection, or if errors are thrown from the `beforeInjection` or `afterInjection` functions. `error` is an `unknown` object. Defaults to `() => {}`.
60
61
  - `renumerateIRIElements` - _Optional_ Boolean indicating if SVG IRI addressable elements should be renumerated. Defaults to `true`.
62
+ - `title` - _Optional_ String used for SVG `<title>` element content. If a `<title>` exists it will be replaced, otherwise a new `<title>` is created. Defaults to `''`, which is a noop.
61
63
  - `useRequestCache` - _Optional_ Use SVG request cache. Defaults to `true`.
62
64
  - `wrapper` - _Optional_ Wrapper element types. One of `'div'`, `'span'` or `'svg'`. Defaults to `'div'`.
63
65
 
@@ -75,6 +77,7 @@ Other non-documented properties are applied to the outermost wrapper element.
75
77
  svg.setAttribute('style', 'width: 200px')
76
78
  }}
77
79
  className="wrapper-class-name"
80
+ desc="Description"
78
81
  evalScripts="always"
79
82
  fallback={() => <span>Error!</span>}
80
83
  httpRequestWithCredentials={true}
@@ -87,6 +90,7 @@ Other non-documented properties are applied to the outermost wrapper element.
87
90
  }}
88
91
  renumerateIRIElements={false}
89
92
  src="svg.svg"
93
+ title="Title"
90
94
  useRequestCache={false}
91
95
  wrapper="span"
92
96
  />
@@ -149,47 +153,6 @@ Related issues and PRs:
149
153
 
150
154
  </details>
151
155
 
152
- <details>
153
-
154
- <summary>
155
- How can I improve the accessibility of the rendered output?
156
- </summary>
157
-
158
- Let's assume we want to add `role` and `aria-label` attributes to the outermost wrapper element, plus `title` and `desc` elements to the SVG.
159
-
160
- Since non-documented properties are applied to the outermost wrapper element, and the `beforeInjection` function allows us to modify the SVG DOM, we can do something like the following:
161
-
162
- ```jsx
163
- <ReactSVG
164
- aria-label="Description of the overall image"
165
- beforeInjection={(svg) => {
166
- const desc = document.createElementNS(
167
- 'http://www.w3.org/2000/svg',
168
- 'desc'
169
- )
170
- desc.innerHTML = 'A description'
171
- svg.prepend(desc)
172
-
173
- const title = document.createElementNS(
174
- 'http://www.w3.org/2000/svg',
175
- 'title'
176
- )
177
- title.innerHTML = 'A title'
178
- svg.prepend(title)
179
- }}
180
- role="img"
181
- src="svg.svg"
182
- />
183
- ```
184
-
185
- A live example is available [here](https://codesandbox.io/s/github/tanem/react-svg/tree/master/examples/accessibility).
186
-
187
- Related issue:
188
-
189
- - [#639](https://github.com/tanem/react-svg/issues/639).
190
-
191
- </details>
192
-
193
156
  ## License
194
157
 
195
158
  MIT
@@ -5,18 +5,21 @@ export declare class ReactSVG extends React.Component<Props, State> {
5
5
  static defaultProps: {
6
6
  afterInjection: () => undefined;
7
7
  beforeInjection: () => undefined;
8
+ desc: string;
8
9
  evalScripts: string;
9
10
  fallback: null;
10
11
  httpRequestWithCredentials: boolean;
11
12
  loading: null;
12
13
  onError: () => undefined;
13
14
  renumerateIRIElements: boolean;
15
+ title: string;
14
16
  useRequestCache: boolean;
15
17
  wrapper: string;
16
18
  };
17
19
  static propTypes: {
18
20
  afterInjection: PropTypes.Requireable<(...args: any[]) => any>;
19
21
  beforeInjection: PropTypes.Requireable<(...args: any[]) => any>;
22
+ desc: PropTypes.Requireable<string>;
20
23
  evalScripts: PropTypes.Requireable<string>;
21
24
  fallback: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
22
25
  httpRequestWithCredentials: PropTypes.Requireable<boolean>;
@@ -24,6 +27,7 @@ export declare class ReactSVG extends React.Component<Props, State> {
24
27
  onError: PropTypes.Requireable<(...args: any[]) => any>;
25
28
  renumerateIRIElements: PropTypes.Requireable<boolean>;
26
29
  src: PropTypes.Validator<string>;
30
+ title: PropTypes.Requireable<string>;
27
31
  useRequestCache: PropTypes.Requireable<boolean>;
28
32
  wrapper: PropTypes.Requireable<string>;
29
33
  };
@@ -48,7 +48,7 @@ var shallowDiffers = function shallowDiffers(a, b) {
48
48
  return false;
49
49
  };
50
50
 
51
- var _excluded = ["afterInjection", "beforeInjection", "evalScripts", "fallback", "httpRequestWithCredentials", "loading", "renumerateIRIElements", "src", "useRequestCache", "wrapper"];
51
+ var _excluded = ["afterInjection", "beforeInjection", "desc", "evalScripts", "fallback", "httpRequestWithCredentials", "loading", "renumerateIRIElements", "src", "title", "useRequestCache", "wrapper"];
52
52
  var svgNamespace = 'http://www.w3.org/2000/svg';
53
53
  var xlinkNamespace = 'http://www.w3.org/1999/xlink';
54
54
  var ReactSVG = /*#__PURE__*/function (_React$Component) {
@@ -78,10 +78,12 @@ var ReactSVG = /*#__PURE__*/function (_React$Component) {
78
78
  /* istanbul ignore else */
79
79
  if (this.reactWrapper instanceof ownerWindow(this.reactWrapper).Node) {
80
80
  var _this$props = this.props,
81
+ desc = _this$props.desc,
81
82
  evalScripts = _this$props.evalScripts,
82
83
  httpRequestWithCredentials = _this$props.httpRequestWithCredentials,
83
84
  renumerateIRIElements = _this$props.renumerateIRIElements,
84
85
  src = _this$props.src,
86
+ title = _this$props.title,
85
87
  useRequestCache = _this$props.useRequestCache;
86
88
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
87
89
  var onError = this.props.onError;
@@ -139,6 +141,25 @@ var ReactSVG = /*#__PURE__*/function (_React$Component) {
139
141
  }
140
142
  };
141
143
  var beforeEach = function beforeEach(svg) {
144
+ svg.setAttribute('role', 'img');
145
+ if (desc) {
146
+ var originalDesc = svg.querySelector(':scope > desc');
147
+ if (originalDesc) {
148
+ svg.removeChild(originalDesc);
149
+ }
150
+ var newDesc = document.createElement('desc');
151
+ newDesc.innerHTML = desc;
152
+ svg.prepend(newDesc);
153
+ }
154
+ if (title) {
155
+ var originalTitle = svg.querySelector(':scope > title');
156
+ if (originalTitle) {
157
+ svg.removeChild(originalTitle);
158
+ }
159
+ var newTitle = document.createElement('title');
160
+ newTitle.innerHTML = title;
161
+ svg.prepend(newTitle);
162
+ }
142
163
  try {
143
164
  beforeInjection(svg);
144
165
  } catch (error) {
@@ -186,12 +207,14 @@ var ReactSVG = /*#__PURE__*/function (_React$Component) {
186
207
  var _this$props2 = this.props;
187
208
  _this$props2.afterInjection;
188
209
  _this$props2.beforeInjection;
210
+ _this$props2.desc;
189
211
  _this$props2.evalScripts;
190
212
  var Fallback = _this$props2.fallback;
191
213
  _this$props2.httpRequestWithCredentials;
192
214
  var Loading = _this$props2.loading;
193
215
  _this$props2.renumerateIRIElements;
194
216
  _this$props2.src;
217
+ _this$props2.title;
195
218
  _this$props2.useRequestCache;
196
219
  var wrapper = _this$props2.wrapper,
197
220
  rest = _objectWithoutPropertiesLoose(_this$props2, _excluded);
@@ -214,6 +237,7 @@ ReactSVG.defaultProps = {
214
237
  beforeInjection: function beforeInjection() {
215
238
  return undefined;
216
239
  },
240
+ desc: '',
217
241
  evalScripts: 'never',
218
242
  fallback: null,
219
243
  httpRequestWithCredentials: false,
@@ -222,12 +246,14 @@ ReactSVG.defaultProps = {
222
246
  return undefined;
223
247
  },
224
248
  renumerateIRIElements: true,
249
+ title: '',
225
250
  useRequestCache: true,
226
251
  wrapper: 'div'
227
252
  };
228
253
  ReactSVG.propTypes = {
229
254
  afterInjection: PropTypes__namespace.func,
230
255
  beforeInjection: PropTypes__namespace.func,
256
+ desc: PropTypes__namespace.string,
231
257
  evalScripts: PropTypes__namespace.oneOf(['always', 'once', 'never']),
232
258
  fallback: PropTypes__namespace.oneOfType([PropTypes__namespace.func, PropTypes__namespace.object, PropTypes__namespace.string]),
233
259
  httpRequestWithCredentials: PropTypes__namespace.bool,
@@ -235,6 +261,7 @@ ReactSVG.propTypes = {
235
261
  onError: PropTypes__namespace.func,
236
262
  renumerateIRIElements: PropTypes__namespace.bool,
237
263
  src: PropTypes__namespace.string.isRequired,
264
+ title: PropTypes__namespace.string,
238
265
  useRequestCache: PropTypes__namespace.bool,
239
266
  wrapper: PropTypes__namespace.oneOf(['div', 'span', 'svg'])
240
267
  };
@@ -1 +1 @@
1
- {"version":3,"file":"react-svg.cjs.development.js","sources":["../compiled/owner-window.js","../compiled/shallow-differs.js","../compiled/ReactSVG.js"],"sourcesContent":["// Hat-tip: https://github.com/mui/material-ui/tree/master/packages/mui-utils/src.\nconst ownerWindow = (node) => {\n const doc = node?.ownerDocument || document;\n return doc.defaultView || window;\n};\nexport default ownerWindow;\n","// Hat-tip: https://github.com/developit/preact-compat/blob/master/src/index.js#L402.\nconst shallowDiffers = (a, b) => {\n for (const i in a) {\n if (!(i in b)) {\n return true;\n }\n }\n for (const i in b) {\n if (a[i] !== b[i]) {\n return true;\n }\n }\n return false;\n};\nexport default shallowDiffers;\n","import { SVGInjector } from '@tanem/svg-injector';\nimport * as PropTypes from 'prop-types';\nimport * as React from 'react';\nimport ownerWindow from './owner-window';\nimport shallowDiffers from './shallow-differs';\nconst svgNamespace = 'http://www.w3.org/2000/svg';\nconst xlinkNamespace = 'http://www.w3.org/1999/xlink';\nexport class ReactSVG extends React.Component {\n static defaultProps = {\n afterInjection: () => undefined,\n beforeInjection: () => undefined,\n evalScripts: 'never',\n fallback: null,\n httpRequestWithCredentials: false,\n loading: null,\n onError: () => undefined,\n renumerateIRIElements: true,\n useRequestCache: true,\n wrapper: 'div',\n };\n static propTypes = {\n afterInjection: PropTypes.func,\n beforeInjection: PropTypes.func,\n evalScripts: PropTypes.oneOf(['always', 'once', 'never']),\n fallback: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.object,\n PropTypes.string,\n ]),\n httpRequestWithCredentials: PropTypes.bool,\n loading: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.object,\n PropTypes.string,\n ]),\n onError: PropTypes.func,\n renumerateIRIElements: PropTypes.bool,\n src: PropTypes.string.isRequired,\n useRequestCache: PropTypes.bool,\n wrapper: PropTypes.oneOf(['div', 'span', 'svg']),\n };\n initialState = {\n hasError: false,\n isLoading: true,\n };\n state = this.initialState;\n _isMounted = false;\n reactWrapper;\n nonReactWrapper;\n refCallback = (reactWrapper) => {\n this.reactWrapper = reactWrapper;\n };\n renderSVG() {\n /* istanbul ignore else */\n if (this.reactWrapper instanceof ownerWindow(this.reactWrapper).Node) {\n const { evalScripts, httpRequestWithCredentials, renumerateIRIElements, src, useRequestCache, } = this.props;\n /* eslint-disable @typescript-eslint/no-non-null-assertion */\n const onError = this.props.onError;\n const beforeInjection = this.props.beforeInjection;\n const afterInjection = this.props.afterInjection;\n const wrapper = this.props.wrapper;\n let nonReactWrapper;\n let nonReactTarget;\n if (wrapper === 'svg') {\n nonReactWrapper = document.createElementNS(svgNamespace, wrapper);\n nonReactWrapper.setAttribute('xmlns', svgNamespace);\n nonReactWrapper.setAttribute('xmlns:xlink', xlinkNamespace);\n nonReactTarget = document.createElementNS(svgNamespace, wrapper);\n }\n else {\n nonReactWrapper = document.createElement(wrapper);\n nonReactTarget = document.createElement(wrapper);\n }\n nonReactWrapper.appendChild(nonReactTarget);\n nonReactTarget.dataset.src = src;\n this.nonReactWrapper = this.reactWrapper.appendChild(nonReactWrapper);\n const handleError = (error) => {\n this.removeSVG();\n if (!this._isMounted) {\n onError(error);\n return;\n }\n this.setState(() => ({\n hasError: true,\n isLoading: false,\n }), () => {\n onError(error);\n });\n };\n const afterEach = (error, svg) => {\n if (error) {\n handleError(error);\n return;\n }\n // TODO (Tane): It'd be better to cleanly unsubscribe from SVGInjector\n // callbacks instead of tracking a property like this.\n if (this._isMounted) {\n this.setState(() => ({\n isLoading: false,\n }), () => {\n try {\n afterInjection(svg);\n }\n catch (afterInjectionError) {\n handleError(afterInjectionError);\n }\n });\n }\n };\n const beforeEach = (svg) => {\n try {\n beforeInjection(svg);\n }\n catch (error) {\n handleError(error);\n }\n };\n SVGInjector(nonReactTarget, {\n afterEach,\n beforeEach,\n cacheRequests: useRequestCache,\n evalScripts,\n httpRequestWithCredentials,\n renumerateIRIElements,\n });\n }\n }\n removeSVG() {\n if (this.nonReactWrapper?.parentNode) {\n this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper);\n this.nonReactWrapper = null;\n }\n }\n componentDidMount() {\n this._isMounted = true;\n this.renderSVG();\n }\n componentDidUpdate(prevProps) {\n if (shallowDiffers({ ...prevProps }, this.props)) {\n this.setState(() => this.initialState, () => {\n this.removeSVG();\n this.renderSVG();\n });\n }\n }\n componentWillUnmount() {\n this._isMounted = false;\n this.removeSVG();\n }\n render() {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { afterInjection, beforeInjection, evalScripts, fallback: Fallback, httpRequestWithCredentials, loading: Loading, renumerateIRIElements, src, useRequestCache, wrapper, ...rest } = this.props;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const Wrapper = wrapper;\n return (React.createElement(Wrapper, { ...rest, ref: this.refCallback, ...(wrapper === 'svg'\n ? {\n xmlns: svgNamespace,\n xmlnsXlink: xlinkNamespace,\n }\n : {}) },\n this.state.isLoading && Loading && React.createElement(Loading, null),\n this.state.hasError && Fallback && React.createElement(Fallback, null)));\n }\n}\n"],"names":["ownerWindow","node","doc","ownerDocument","document","defaultView","window","shallowDiffers","a","b","i","svgNamespace","xlinkNamespace","ReactSVG","initialState","hasError","isLoading","state","_isMounted","reactWrapper","nonReactWrapper","refCallback","renderSVG","Node","props","evalScripts","httpRequestWithCredentials","renumerateIRIElements","src","useRequestCache","onError","beforeInjection","afterInjection","wrapper","nonReactTarget","createElementNS","setAttribute","createElement","appendChild","dataset","handleError","error","removeSVG","setState","afterEach","svg","afterInjectionError","beforeEach","SVGInjector","cacheRequests","parentNode","removeChild","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","render","Fallback","fallback","Loading","loading","rest","Wrapper","React","ref","xmlns","xmlnsXlink","Component","defaultProps","undefined","propTypes","PropTypes","func","oneOf","oneOfType","object","string","bool","isRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA,IAAMA,WAAW,GAAG,SAAdA,WAAW,CAAIC,IAAI,EAAK;EAC1B,IAAMC,GAAG,GAAG,CAAAD,IAAI,oBAAJA,IAAI,CAAEE,aAAa,KAAIC,QAAQ,CAAA;AAC3C,EAAA,OAAOF,GAAG,CAACG,WAAW,IAAIC,MAAM,CAAA;AACpC,CAAC;;ACJD;AACA,IAAMC,cAAc,GAAG,SAAjBA,cAAc,CAAIC,CAAC,EAAEC,CAAC,EAAK;AAC7B,EAAA,KAAK,IAAMC,CAAC,IAAIF,CAAC,EAAE;AACf,IAAA,IAAI,EAAEE,CAAC,IAAID,CAAC,CAAC,EAAE;AACX,MAAA,OAAO,IAAI,CAAA;AACf,KAAA;AACJ,GAAA;AACA,EAAA,KAAK,IAAMC,EAAC,IAAID,CAAC,EAAE;IACf,IAAID,CAAC,CAACE,EAAC,CAAC,KAAKD,CAAC,CAACC,EAAC,CAAC,EAAE;AACf,MAAA,OAAO,IAAI,CAAA;AACf,KAAA;AACJ,GAA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CACzBH,oBAAS,CAACC,IAAI,EACdD,oBAAS,CAACI,MAAM,EAChBJ,oBAAS,CAACK,MAAM,CACnB,CAAC;EACF9C,OAAO,EAAEyC,oBAAS,CAACC,IAAI;EACvB7C,qBAAqB,EAAE4C,oBAAS,CAACM,IAAI;AACrCjD,EAAAA,GAAG,EAAE2C,oBAAS,CAACK,MAAM,CAACE,UAAU;EAChCjD,eAAe,EAAE0C,oBAAS,CAACM,IAAI;EAC/B5C,OAAO,EAAEsC,oBAAS,CAACE,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AACnD,CAAC;;;;"}
1
+ {"version":3,"file":"react-svg.cjs.development.js","sources":["../compiled/owner-window.js","../compiled/shallow-differs.js","../compiled/ReactSVG.js"],"sourcesContent":["// Hat-tip: https://github.com/mui/material-ui/tree/master/packages/mui-utils/src.\nconst ownerWindow = (node) => {\n const doc = node?.ownerDocument || document;\n return doc.defaultView || window;\n};\nexport default ownerWindow;\n","// Hat-tip: https://github.com/developit/preact-compat/blob/master/src/index.js#L402.\nconst shallowDiffers = (a, b) => {\n for (const i in a) {\n if (!(i in b)) {\n return true;\n }\n }\n for (const i in b) {\n if (a[i] !== b[i]) {\n return true;\n }\n }\n return false;\n};\nexport default shallowDiffers;\n","import { SVGInjector } from '@tanem/svg-injector';\nimport * as PropTypes from 'prop-types';\nimport * as React from 'react';\nimport ownerWindow from './owner-window';\nimport shallowDiffers from './shallow-differs';\nconst svgNamespace = 'http://www.w3.org/2000/svg';\nconst xlinkNamespace = 'http://www.w3.org/1999/xlink';\nexport class ReactSVG extends React.Component {\n static defaultProps = {\n afterInjection: () => undefined,\n beforeInjection: () => undefined,\n desc: '',\n evalScripts: 'never',\n fallback: null,\n httpRequestWithCredentials: false,\n loading: null,\n onError: () => undefined,\n renumerateIRIElements: true,\n title: '',\n useRequestCache: true,\n wrapper: 'div',\n };\n static propTypes = {\n afterInjection: PropTypes.func,\n beforeInjection: PropTypes.func,\n desc: PropTypes.string,\n evalScripts: PropTypes.oneOf(['always', 'once', 'never']),\n fallback: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.object,\n PropTypes.string,\n ]),\n httpRequestWithCredentials: PropTypes.bool,\n loading: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.object,\n PropTypes.string,\n ]),\n onError: PropTypes.func,\n renumerateIRIElements: PropTypes.bool,\n src: PropTypes.string.isRequired,\n title: PropTypes.string,\n useRequestCache: PropTypes.bool,\n wrapper: PropTypes.oneOf(['div', 'span', 'svg']),\n };\n initialState = {\n hasError: false,\n isLoading: true,\n };\n state = this.initialState;\n _isMounted = false;\n reactWrapper;\n nonReactWrapper;\n refCallback = (reactWrapper) => {\n this.reactWrapper = reactWrapper;\n };\n renderSVG() {\n /* istanbul ignore else */\n if (this.reactWrapper instanceof ownerWindow(this.reactWrapper).Node) {\n const { desc, evalScripts, httpRequestWithCredentials, renumerateIRIElements, src, title, useRequestCache, } = this.props;\n /* eslint-disable @typescript-eslint/no-non-null-assertion */\n const onError = this.props.onError;\n const beforeInjection = this.props.beforeInjection;\n const afterInjection = this.props.afterInjection;\n const wrapper = this.props.wrapper;\n let nonReactWrapper;\n let nonReactTarget;\n if (wrapper === 'svg') {\n nonReactWrapper = document.createElementNS(svgNamespace, wrapper);\n nonReactWrapper.setAttribute('xmlns', svgNamespace);\n nonReactWrapper.setAttribute('xmlns:xlink', xlinkNamespace);\n nonReactTarget = document.createElementNS(svgNamespace, wrapper);\n }\n else {\n nonReactWrapper = document.createElement(wrapper);\n nonReactTarget = document.createElement(wrapper);\n }\n nonReactWrapper.appendChild(nonReactTarget);\n nonReactTarget.dataset.src = src;\n this.nonReactWrapper = this.reactWrapper.appendChild(nonReactWrapper);\n const handleError = (error) => {\n this.removeSVG();\n if (!this._isMounted) {\n onError(error);\n return;\n }\n this.setState(() => ({\n hasError: true,\n isLoading: false,\n }), () => {\n onError(error);\n });\n };\n const afterEach = (error, svg) => {\n if (error) {\n handleError(error);\n return;\n }\n // TODO (Tane): It'd be better to cleanly unsubscribe from SVGInjector\n // callbacks instead of tracking a property like this.\n if (this._isMounted) {\n this.setState(() => ({\n isLoading: false,\n }), () => {\n try {\n afterInjection(svg);\n }\n catch (afterInjectionError) {\n handleError(afterInjectionError);\n }\n });\n }\n };\n const beforeEach = (svg) => {\n svg.setAttribute('role', 'img');\n if (desc) {\n const originalDesc = svg.querySelector(':scope > desc');\n if (originalDesc) {\n svg.removeChild(originalDesc);\n }\n const newDesc = document.createElement('desc');\n newDesc.innerHTML = desc;\n svg.prepend(newDesc);\n }\n if (title) {\n const originalTitle = svg.querySelector(':scope > title');\n if (originalTitle) {\n svg.removeChild(originalTitle);\n }\n const newTitle = document.createElement('title');\n newTitle.innerHTML = title;\n svg.prepend(newTitle);\n }\n try {\n beforeInjection(svg);\n }\n catch (error) {\n handleError(error);\n }\n };\n SVGInjector(nonReactTarget, {\n afterEach,\n beforeEach,\n cacheRequests: useRequestCache,\n evalScripts,\n httpRequestWithCredentials,\n renumerateIRIElements,\n });\n }\n }\n removeSVG() {\n if (this.nonReactWrapper?.parentNode) {\n this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper);\n this.nonReactWrapper = null;\n }\n }\n componentDidMount() {\n this._isMounted = true;\n this.renderSVG();\n }\n componentDidUpdate(prevProps) {\n if (shallowDiffers({ ...prevProps }, this.props)) {\n this.setState(() => this.initialState, () => {\n this.removeSVG();\n this.renderSVG();\n });\n }\n }\n componentWillUnmount() {\n this._isMounted = false;\n this.removeSVG();\n }\n render() {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { afterInjection, beforeInjection, desc, evalScripts, fallback: Fallback, httpRequestWithCredentials, loading: Loading, renumerateIRIElements, src, title, useRequestCache, wrapper, ...rest } = this.props;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const Wrapper = wrapper;\n return (React.createElement(Wrapper, { ...rest, ref: this.refCallback, ...(wrapper === 'svg'\n ? {\n xmlns: svgNamespace,\n xmlnsXlink: xlinkNamespace,\n }\n : {}) },\n this.state.isLoading && Loading && React.createElement(Loading, null),\n this.state.hasError && Fallback && React.createElement(Fallback, null)));\n }\n}\n"],"names":["ownerWindow","node","doc","ownerDocument","document","defaultView","window","shallowDiffers","a","b","i","svgNamespace","xlinkNamespace","ReactSVG","initialState","hasError","isLoading","state","_isMounted","reactWrapper","nonReactWrapper","refCallback","renderSVG","Node","props","desc","evalScripts","httpRequestWithCredentials","renumerateIRIElements","src","title","useRequestCache","onError","beforeInjection","afterInjection","wrapper","nonReactTarget","createElementNS","setAttribute","createElement","appendChild","dataset","handleError","error","removeSVG","setState","afterEach","svg","afterInjectionError","beforeEach","originalDesc","querySelector","removeChild","newDesc","innerHTML","prepend","originalTitle","newTitle","SVGInjector","cacheRequests","parentNode","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","render","Fallback","fallback","Loading","loading","rest","Wrapper","React","ref","xmlns","xmlnsXlink","Component","defaultProps","undefined","propTypes","PropTypes","func","string","oneOf","oneOfType","object","bool","isRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA,IAAMA,WAAW,GAAG,SAAdA,WAAW,CAAIC,IAAI,EAAK;EAC1B,IAAMC,GAAG,GAAG,CAAAD,IAAI,oBAAJA,IAAI,CAAEE,aAAa,KAAIC,QAAQ,CAAA;AAC3C,EAAA,OAAOF,GAAG,CAACG,WAAW,IAAIC,MAAM,CAAA;AACpC,CAAC;;ACJD;AACA,IAAMC,cAAc,GAAG,SAAjBA,cAAc,CAAIC,CAAC,EAAEC,CAAC,EAAK;AAC7B,EAAA,KAAK,IAAMC,CAAC,IAAIF,CAAC,EAAE;AACf,IAAA,IAAI,EAAEE,CAAC,IAAID,CAAC,CAAC,EAAE;AACX,MAAA,OAAO,IAAI,CAAA;AACf,KAAA;AACJ,GAAA;AACA,EAAA,KAAK,IAAMC,EAAC,IAAID,CAAC,EAAE;IACf,IAAID,CAAC,CAACE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dD,oBAAS,CAACK,MAAM,EAChBL,oBAAS,CAACE,MAAM,CACnB,CAAC;EACFlD,OAAO,EAAEgD,oBAAS,CAACC,IAAI;EACvBrD,qBAAqB,EAAEoD,oBAAS,CAACM,IAAI;AACrCzD,EAAAA,GAAG,EAAEmD,oBAAS,CAACE,MAAM,CAACK,UAAU;EAChCzD,KAAK,EAAEkD,oBAAS,CAACE,MAAM;EACvBnD,eAAe,EAAEiD,oBAAS,CAACM,IAAI;EAC/BnD,OAAO,EAAE6C,oBAAS,CAACG,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AACnD,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";var _objectWithoutPropertiesLoose=require("@babel/runtime/helpers/objectWithoutPropertiesLoose"),_extends=require("@babel/runtime/helpers/extends"),_inheritsLoose=require("@babel/runtime/helpers/inheritsLoose"),svgInjector=require("@tanem/svg-injector"),React=require("react");function _interopNamespaceDefault(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var React__namespace=_interopNamespaceDefault(React),ownerWindow=function(e){return((null==e?void 0:e.ownerDocument)||document).defaultView||window},shallowDiffers=function(e,t){for(var r in e)if(!(r in t))return!0;for(var n in t)if(e[n]!==t[n])return!0;return!1},_excluded=["afterInjection","beforeInjection","evalScripts","fallback","httpRequestWithCredentials","loading","renumerateIRIElements","src","useRequestCache","wrapper"],svgNamespace="http://www.w3.org/2000/svg",xlinkNamespace="http://www.w3.org/1999/xlink",ReactSVG=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return(t=e.call.apply(e,[this].concat(n))||this).initialState={hasError:!1,isLoading:!0},t.state=t.initialState,t._isMounted=!1,t.reactWrapper=void 0,t.nonReactWrapper=void 0,t.refCallback=function(e){t.reactWrapper=e},t}_inheritsLoose(t,e);var r=t.prototype;return r.renderSVG=function(){var e=this;if(this.reactWrapper instanceof ownerWindow(this.reactWrapper).Node){var t,r,n=this.props,a=n.evalScripts,i=n.httpRequestWithCredentials,o=n.renumerateIRIElements,s=n.src,c=n.useRequestCache,p=this.props.onError,u=this.props.beforeInjection,l=this.props.afterInjection,h=this.props.wrapper;"svg"===h?((t=document.createElementNS(svgNamespace,h)).setAttribute("xmlns",svgNamespace),t.setAttribute("xmlns:xlink",xlinkNamespace),r=document.createElementNS(svgNamespace,h)):(t=document.createElement(h),r=document.createElement(h)),t.appendChild(r),r.dataset.src=s,this.nonReactWrapper=this.reactWrapper.appendChild(t);var f=function(t){e.removeSVG(),e._isMounted?e.setState((function(){return{hasError:!0,isLoading:!1}}),(function(){p(t)})):p(t)};svgInjector.SVGInjector(r,{afterEach:function(t,r){t?f(t):e._isMounted&&e.setState((function(){return{isLoading:!1}}),(function(){try{l(r)}catch(e){f(e)}}))},beforeEach:function(e){try{u(e)}catch(e){f(e)}},cacheRequests:c,evalScripts:a,httpRequestWithCredentials:i,renumerateIRIElements:o})}},r.removeSVG=function(){var e;null!=(e=this.nonReactWrapper)&&e.parentNode&&(this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper),this.nonReactWrapper=null)},r.componentDidMount=function(){this._isMounted=!0,this.renderSVG()},r.componentDidUpdate=function(e){var t=this;shallowDiffers(_extends({},e),this.props)&&this.setState((function(){return t.initialState}),(function(){t.removeSVG(),t.renderSVG()}))},r.componentWillUnmount=function(){this._isMounted=!1,this.removeSVG()},r.render=function(){var e=this.props,t=e.fallback,r=e.loading,n=e.wrapper,a=_objectWithoutPropertiesLoose(e,_excluded);return React__namespace.createElement(n,_extends({},a,{ref:this.refCallback},"svg"===n?{xmlns:svgNamespace,xmlnsXlink:xlinkNamespace}:{}),this.state.isLoading&&r&&React__namespace.createElement(r,null),this.state.hasError&&t&&React__namespace.createElement(t,null))},t}(React__namespace.Component);ReactSVG.defaultProps={afterInjection:function(){},beforeInjection:function(){},evalScripts:"never",fallback:null,httpRequestWithCredentials:!1,loading:null,onError:function(){},renumerateIRIElements:!0,useRequestCache:!0,wrapper:"div"},exports.ReactSVG=ReactSVG;
1
+ "use strict";var _objectWithoutPropertiesLoose=require("@babel/runtime/helpers/objectWithoutPropertiesLoose"),_extends=require("@babel/runtime/helpers/extends"),_inheritsLoose=require("@babel/runtime/helpers/inheritsLoose"),svgInjector=require("@tanem/svg-injector"),React=require("react");function _interopNamespaceDefault(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var React__namespace=_interopNamespaceDefault(React),ownerWindow=function(e){return((null==e?void 0:e.ownerDocument)||document).defaultView||window},shallowDiffers=function(e,t){for(var r in e)if(!(r in t))return!0;for(var n in t)if(e[n]!==t[n])return!0;return!1},_excluded=["afterInjection","beforeInjection","desc","evalScripts","fallback","httpRequestWithCredentials","loading","renumerateIRIElements","src","title","useRequestCache","wrapper"],svgNamespace="http://www.w3.org/2000/svg",xlinkNamespace="http://www.w3.org/1999/xlink",ReactSVG=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return(t=e.call.apply(e,[this].concat(n))||this).initialState={hasError:!1,isLoading:!0},t.state=t.initialState,t._isMounted=!1,t.reactWrapper=void 0,t.nonReactWrapper=void 0,t.refCallback=function(e){t.reactWrapper=e},t}_inheritsLoose(t,e);var r=t.prototype;return r.renderSVG=function(){var e=this;if(this.reactWrapper instanceof ownerWindow(this.reactWrapper).Node){var t,r,n=this.props,a=n.desc,i=n.evalScripts,o=n.httpRequestWithCredentials,s=n.renumerateIRIElements,c=n.src,p=n.title,u=n.useRequestCache,l=this.props.onError,d=this.props.beforeInjection,h=this.props.afterInjection,f=this.props.wrapper;"svg"===f?((t=document.createElementNS(svgNamespace,f)).setAttribute("xmlns",svgNamespace),t.setAttribute("xmlns:xlink",xlinkNamespace),r=document.createElementNS(svgNamespace,f)):(t=document.createElement(f),r=document.createElement(f)),t.appendChild(r),r.dataset.src=c,this.nonReactWrapper=this.reactWrapper.appendChild(t);var m=function(t){e.removeSVG(),e._isMounted?e.setState((function(){return{hasError:!0,isLoading:!1}}),(function(){l(t)})):l(t)};svgInjector.SVGInjector(r,{afterEach:function(t,r){t?m(t):e._isMounted&&e.setState((function(){return{isLoading:!1}}),(function(){try{h(r)}catch(e){m(e)}}))},beforeEach:function(e){if(e.setAttribute("role","img"),a){var t=e.querySelector(":scope > desc");t&&e.removeChild(t);var r=document.createElement("desc");r.innerHTML=a,e.prepend(r)}if(p){var n=e.querySelector(":scope > title");n&&e.removeChild(n);var i=document.createElement("title");i.innerHTML=p,e.prepend(i)}try{d(e)}catch(e){m(e)}},cacheRequests:u,evalScripts:i,httpRequestWithCredentials:o,renumerateIRIElements:s})}},r.removeSVG=function(){var e;null!=(e=this.nonReactWrapper)&&e.parentNode&&(this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper),this.nonReactWrapper=null)},r.componentDidMount=function(){this._isMounted=!0,this.renderSVG()},r.componentDidUpdate=function(e){var t=this;shallowDiffers(_extends({},e),this.props)&&this.setState((function(){return t.initialState}),(function(){t.removeSVG(),t.renderSVG()}))},r.componentWillUnmount=function(){this._isMounted=!1,this.removeSVG()},r.render=function(){var e=this.props,t=e.fallback,r=e.loading,n=e.wrapper,a=_objectWithoutPropertiesLoose(e,_excluded);return React__namespace.createElement(n,_extends({},a,{ref:this.refCallback},"svg"===n?{xmlns:svgNamespace,xmlnsXlink:xlinkNamespace}:{}),this.state.isLoading&&r&&React__namespace.createElement(r,null),this.state.hasError&&t&&React__namespace.createElement(t,null))},t}(React__namespace.Component);ReactSVG.defaultProps={afterInjection:function(){},beforeInjection:function(){},desc:"",evalScripts:"never",fallback:null,httpRequestWithCredentials:!1,loading:null,onError:function(){},renumerateIRIElements:!0,title:"",useRequestCache:!0,wrapper:"div"},exports.ReactSVG=ReactSVG;
2
2
  //# sourceMappingURL=react-svg.cjs.production.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-svg.cjs.production.js","sources":["../compiled/owner-window.js","../compiled/shallow-differs.js","../compiled/ReactSVG.js"],"sourcesContent":["// Hat-tip: https://github.com/mui/material-ui/tree/master/packages/mui-utils/src.\nconst ownerWindow = (node) => {\n const doc = node?.ownerDocument || document;\n return doc.defaultView || window;\n};\nexport default ownerWindow;\n","// Hat-tip: https://github.com/developit/preact-compat/blob/master/src/index.js#L402.\nconst shallowDiffers = (a, b) => {\n for (const i in a) {\n if (!(i in b)) {\n return true;\n }\n }\n for (const i in b) {\n if (a[i] !== b[i]) {\n return true;\n }\n }\n return false;\n};\nexport default shallowDiffers;\n","import { SVGInjector } from '@tanem/svg-injector';\nimport * as PropTypes from 'prop-types';\nimport * as React from 'react';\nimport ownerWindow from './owner-window';\nimport shallowDiffers from './shallow-differs';\nconst svgNamespace = 'http://www.w3.org/2000/svg';\nconst xlinkNamespace = 'http://www.w3.org/1999/xlink';\nexport class ReactSVG extends React.Component {\n static defaultProps = {\n afterInjection: () => undefined,\n beforeInjection: () => undefined,\n evalScripts: 'never',\n fallback: null,\n httpRequestWithCredentials: false,\n loading: null,\n onError: () => undefined,\n renumerateIRIElements: true,\n useRequestCache: true,\n wrapper: 'div',\n };\n static propTypes = {\n afterInjection: PropTypes.func,\n beforeInjection: PropTypes.func,\n evalScripts: PropTypes.oneOf(['always', 'once', 'never']),\n fallback: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.object,\n PropTypes.string,\n ]),\n httpRequestWithCredentials: PropTypes.bool,\n loading: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.object,\n PropTypes.string,\n ]),\n onError: PropTypes.func,\n renumerateIRIElements: PropTypes.bool,\n src: PropTypes.string.isRequired,\n useRequestCache: PropTypes.bool,\n wrapper: PropTypes.oneOf(['div', 'span', 'svg']),\n };\n initialState = {\n hasError: false,\n isLoading: true,\n };\n state = this.initialState;\n _isMounted = false;\n reactWrapper;\n nonReactWrapper;\n refCallback = (reactWrapper) => {\n this.reactWrapper = reactWrapper;\n };\n renderSVG() {\n /* istanbul ignore else */\n if (this.reactWrapper instanceof ownerWindow(this.reactWrapper).Node) {\n const { evalScripts, httpRequestWithCredentials, renumerateIRIElements, src, useRequestCache, } = this.props;\n /* eslint-disable @typescript-eslint/no-non-null-assertion */\n const onError = this.props.onError;\n const beforeInjection = this.props.beforeInjection;\n const afterInjection = this.props.afterInjection;\n const wrapper = this.props.wrapper;\n let nonReactWrapper;\n let nonReactTarget;\n if (wrapper === 'svg') {\n nonReactWrapper = document.createElementNS(svgNamespace, wrapper);\n nonReactWrapper.setAttribute('xmlns', svgNamespace);\n nonReactWrapper.setAttribute('xmlns:xlink', xlinkNamespace);\n nonReactTarget = document.createElementNS(svgNamespace, wrapper);\n }\n else {\n nonReactWrapper = document.createElement(wrapper);\n nonReactTarget = document.createElement(wrapper);\n }\n nonReactWrapper.appendChild(nonReactTarget);\n nonReactTarget.dataset.src = src;\n this.nonReactWrapper = this.reactWrapper.appendChild(nonReactWrapper);\n const handleError = (error) => {\n this.removeSVG();\n if (!this._isMounted) {\n onError(error);\n return;\n }\n this.setState(() => ({\n hasError: true,\n isLoading: false,\n }), () => {\n onError(error);\n });\n };\n const afterEach = (error, svg) => {\n if (error) {\n handleError(error);\n return;\n }\n // TODO (Tane): It'd be better to cleanly unsubscribe from SVGInjector\n // callbacks instead of tracking a property like this.\n if (this._isMounted) {\n this.setState(() => ({\n isLoading: false,\n }), () => {\n try {\n afterInjection(svg);\n }\n catch (afterInjectionError) {\n handleError(afterInjectionError);\n }\n });\n }\n };\n const beforeEach = (svg) => {\n try {\n beforeInjection(svg);\n }\n catch (error) {\n handleError(error);\n }\n };\n SVGInjector(nonReactTarget, {\n afterEach,\n beforeEach,\n cacheRequests: useRequestCache,\n evalScripts,\n httpRequestWithCredentials,\n renumerateIRIElements,\n });\n }\n }\n removeSVG() {\n if (this.nonReactWrapper?.parentNode) {\n this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper);\n this.nonReactWrapper = null;\n }\n }\n componentDidMount() {\n this._isMounted = true;\n this.renderSVG();\n }\n componentDidUpdate(prevProps) {\n if (shallowDiffers({ ...prevProps }, this.props)) {\n this.setState(() => this.initialState, () => {\n this.removeSVG();\n this.renderSVG();\n });\n }\n }\n componentWillUnmount() {\n this._isMounted = false;\n this.removeSVG();\n }\n render() {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { afterInjection, beforeInjection, evalScripts, fallback: Fallback, httpRequestWithCredentials, loading: Loading, renumerateIRIElements, src, useRequestCache, wrapper, ...rest } = this.props;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const Wrapper = wrapper;\n return (React.createElement(Wrapper, { ...rest, ref: this.refCallback, ...(wrapper === 'svg'\n ? {\n xmlns: svgNamespace,\n xmlnsXlink: xlinkNamespace,\n }\n : {}) },\n this.state.isLoading && Loading && React.createElement(Loading, null),\n this.state.hasError && Fallback && React.createElement(Fallback, null)));\n }\n}\n"],"names":["ownerWindow","node","ownerDocument","document","defaultView","window","shallowDiffers","a","b","i","svgNamespace","xlinkNamespace","ReactSVG","_React$Component","_this","_len","arguments","length","args","Array","_key","call","apply","this","concat","initialState","hasError","isLoading","state","_isMounted","reactWrapper","nonReactWrapper","refCallback","_inheritsLoose","_proto","prototype","renderSVG","_this2","Node","nonReactTarget","_this$props","props","evalScripts","httpRequestWithCredentials","renumerateIRIElements","src","useRequestCache","onError","beforeInjection","afterInjection","wrapper","createElementNS","setAttribute","createElement","appendChild","dataset","handleError","error","removeSVG","setState","SVGInjector","afterEach","svg","afterInjectionError","beforeEach","cacheRequests","_this$nonReactWrapper","parentNode","removeChild","componentDidMount","componentDidUpdate","prevProps","_this3","componentWillUnmount","render","_this$props2","Fallback","fallback","Loading","loading","rest","_objectWithoutProp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ACDuC,qBAAA,WACIlD,KAAKM,YAAa,EAClBN,KAAKmC,aACRxB,EACDwC,OAAA,WAE8L,IAAAC,EAAApD,KAAKkB,MAA/HmC,IAAVC,SAAyDC,IAATC,QAA+D7B,IAAAA,QAAY8B,EAAIC,8BAAAN,EAAAO,WAIrL,OAAQC,iBAAM9B,cADEH,cAC0B8B,EAAI,CAAEI,IAAK7D,KAAKS,aAA6B,QAAZkB,EACjE,CACEmC,MAAO3E,aACP4E,WAAY3E,gBAEd,CAAE,GACRY,KAAKK,MAAMD,WAAamD,GAAWK,iBAAM9B,cAAcyB,EAAS,MAChEvD,KAAKK,MAAMF,UAAYkD,GAAYO,iBAAM9B,cAAcuB,EAAU,QACxEhE,CAAA,CA5JgB,CAASuE,iBAAMI,WAAvB3E,SACF4E,aAAe,CAClBvC,eAAgB,WAAe,EAC/BD,gBAAiB,WAAe,EAChCN,YAAa,QACbmC,SAAU,KACVlC,4BAA4B,EAC5BoC,QAAS,KACThC,QAAS,WAAe,EACxBH,uBAAuB,EACvBE,iBAAiB,EACjBI,QAAS"}
1
+ {"version":3,"file":"react-svg.cjs.production.js","sources":["../compiled/owner-window.js","../compiled/shallow-differs.js","../compiled/ReactSVG.js"],"sourcesContent":["// Hat-tip: https://github.com/mui/material-ui/tree/master/packages/mui-utils/src.\nconst ownerWindow = (node) => {\n const doc = node?.ownerDocument || document;\n return doc.defaultView || window;\n};\nexport default ownerWindow;\n","// Hat-tip: https://github.com/developit/preact-compat/blob/master/src/index.js#L402.\nconst shallowDiffers = (a, b) => {\n for (const i in a) {\n if (!(i in b)) {\n return true;\n }\n }\n for (const i in b) {\n if (a[i] !== b[i]) {\n return true;\n }\n }\n return false;\n};\nexport default shallowDiffers;\n","import { SVGInjector } from '@tanem/svg-injector';\nimport * as PropTypes from 'prop-types';\nimport * as React from 'react';\nimport ownerWindow from './owner-window';\nimport shallowDiffers from './shallow-differs';\nconst svgNamespace = 'http://www.w3.org/2000/svg';\nconst xlinkNamespace = 'http://www.w3.org/1999/xlink';\nexport class ReactSVG extends React.Component {\n static defaultProps = {\n afterInjection: () => undefined,\n beforeInjection: () => undefined,\n desc: '',\n evalScripts: 'never',\n fallback: null,\n httpRequestWithCredentials: false,\n loading: null,\n onError: () => undefined,\n renumerateIRIElements: true,\n title: '',\n useRequestCache: true,\n wrapper: 'div',\n };\n static propTypes = {\n afterInjection: PropTypes.func,\n beforeInjection: PropTypes.func,\n desc: PropTypes.string,\n evalScripts: PropTypes.oneOf(['always', 'once', 'never']),\n fallback: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.object,\n PropTypes.string,\n ]),\n httpRequestWithCredentials: PropTypes.bool,\n loading: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.object,\n PropTypes.string,\n ]),\n onError: PropTypes.func,\n renumerateIRIElements: PropTypes.bool,\n src: PropTypes.string.isRequired,\n title: PropTypes.string,\n useRequestCache: PropTypes.bool,\n wrapper: PropTypes.oneOf(['div', 'span', 'svg']),\n };\n initialState = {\n hasError: false,\n isLoading: true,\n };\n state = this.initialState;\n _isMounted = false;\n reactWrapper;\n nonReactWrapper;\n refCallback = (reactWrapper) => {\n this.reactWrapper = reactWrapper;\n };\n renderSVG() {\n /* istanbul ignore else */\n if (this.reactWrapper instanceof ownerWindow(this.reactWrapper).Node) {\n const { desc, evalScripts, httpRequestWithCredentials, renumerateIRIElements, src, title, useRequestCache, } = this.props;\n /* eslint-disable @typescript-eslint/no-non-null-assertion */\n const onError = this.props.onError;\n const beforeInjection = this.props.beforeInjection;\n const afterInjection = this.props.afterInjection;\n const wrapper = this.props.wrapper;\n let nonReactWrapper;\n let nonReactTarget;\n if (wrapper === 'svg') {\n nonReactWrapper = document.createElementNS(svgNamespace, wrapper);\n nonReactWrapper.setAttribute('xmlns', svgNamespace);\n nonReactWrapper.setAttribute('xmlns:xlink', xlinkNamespace);\n nonReactTarget = document.createElementNS(svgNamespace, wrapper);\n }\n else {\n nonReactWrapper = document.createElement(wrapper);\n nonReactTarget = document.createElement(wrapper);\n }\n nonReactWrapper.appendChild(nonReactTarget);\n nonReactTarget.dataset.src = src;\n this.nonReactWrapper = this.reactWrapper.appendChild(nonReactWrapper);\n const handleError = (error) => {\n this.removeSVG();\n if (!this._isMounted) {\n onError(error);\n return;\n }\n this.setState(() => ({\n hasError: true,\n isLoading: false,\n }), () => {\n onError(error);\n });\n };\n const afterEach = (error, svg) => {\n if (error) {\n handleError(error);\n return;\n }\n // TODO (Tane): It'd be better to cleanly unsubscribe from SVGInjector\n // callbacks instead of tracking a property like this.\n if (this._isMounted) {\n this.setState(() => ({\n isLoading: false,\n }), () => {\n try {\n afterInjection(svg);\n }\n catch (afterInjectionError) {\n handleError(afterInjectionError);\n }\n });\n }\n };\n const beforeEach = (svg) => {\n svg.setAttribute('role', 'img');\n if (desc) {\n const originalDesc = svg.querySelector(':scope > desc');\n if (originalDesc) {\n svg.removeChild(originalDesc);\n }\n const newDesc = document.createElement('desc');\n newDesc.innerHTML = desc;\n svg.prepend(newDesc);\n }\n if (title) {\n const originalTitle = svg.querySelector(':scope > title');\n if (originalTitle) {\n svg.removeChild(originalTitle);\n }\n const newTitle = document.createElement('title');\n newTitle.innerHTML = title;\n svg.prepend(newTitle);\n }\n try {\n beforeInjection(svg);\n }\n catch (error) {\n handleError(error);\n }\n };\n SVGInjector(nonReactTarget, {\n afterEach,\n beforeEach,\n cacheRequests: useRequestCache,\n evalScripts,\n httpRequestWithCredentials,\n renumerateIRIElements,\n });\n }\n }\n removeSVG() {\n if (this.nonReactWrapper?.parentNode) {\n this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper);\n this.nonReactWrapper = null;\n }\n }\n componentDidMount() {\n this._isMounted = true;\n this.renderSVG();\n }\n componentDidUpdate(prevProps) {\n if (shallowDiffers({ ...prevProps }, this.props)) {\n this.setState(() => this.initialState, () => {\n this.removeSVG();\n this.renderSVG();\n });\n }\n }\n componentWillUnmount() {\n this._isMounted = false;\n this.removeSVG();\n }\n render() {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { afterInjection, beforeInjection, desc, evalScripts, fallback: Fallback, httpRequestWithCredentials, loading: Loading, renumerateIRIElements, src, title, useRequestCache, wrapper, ...rest } = this.props;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const Wrapper = wrapper;\n return (React.createElement(Wrapper, { ...rest, ref: this.refCallback, ...(wrapper === 'svg'\n ? {\n xmlns: svgNamespace,\n xmlnsXlink: xlinkNamespace,\n }\n : {}) },\n this.state.isLoading && Loading && React.createElement(Loading, null),\n this.state.hasError && Fallback && React.createElement(Fallback, null)));\n }\n}\n"],"names":["ownerWindow","node","ownerDocument","document","defaultView","window","shallowDiffers","a","b","i","svgNamespace","xlinkNamespace","ReactSVG","_React$Component","_this","_len","arguments","length","args","Array","_key","call","apply","this","concat","initialState","hasError","isLoading","state","_isMounted","reactWrapper","nonReactWrapper","refCallback","_inheritsLoose","_proto","prototype","renderSVG","_this2","Node","nonReactTarget","_this$props","props","desc","evalScripts","httpRequestWithCredentials","renumerateIRIElements","src","title","useRequestCache","onError","beforeInjection","afterInjection","wrapper","createElementNS","setAttribute","createElement","appendChild","dataset","handleError","error","removeSVG","setState","SVGInjector","afterEach","svg","afterInjectionError","beforeEach","originalDesc","querySelector","removeChild","newDesc","innerHTML","prepend","originalTitle","newTitle","cacheRequests","_this$nonReactWrapper","parentNode","componentDidMount","componentDidUpdate","prevProps","_this3","componentWillUnmount","render","_this$props2","Fallback","fallback","Loading","loading","rest","_objectWithoutPropertiesLoose","_excluded","React","ref","xmlns","xmlnsXlink","Component","defaultProps"],"mappings":"inBACMA,YAAc,SAACC,GAEjB,cADYA,SAAAA,EAAMC,gBAAiBC,UACxBC,aAAeC,MAC9B,ECHMC,eAAiB,SAACC,EAAGC,GACvB,IAAK,IAAMC,KAAKF,EACZ,KAAME,KAAKD,GACP,OAAO,EAGf,IAAK,IAAMC,KAAKD,EACZ,GAAID,EAAEE,KAAOD,EAAEC,GAC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BAAoB0E,GAAazD,KAAKkB,QACtClB,KAAKsC,UAAS,WAAA,OAAMoB,EAAKxD,YAAY,IAAE,WACnCwD,EAAKrB,YACLqB,EAAK7C,WACT,KAEPF,EACDgD,qBAAA,WACI3D,KAAKM,YAAa,EAClBN,KAAKqC,aACR1B,EACDiD,OAAA,WAE2M,IAAAC,EAAA7D,KAAKkB,MAAtI4C,IAAVC,SAAyDC,IAATC,QAAsEpC,IAAAA,QAAYqC,EAAIC,8BAAAN,EAAAO,WAIlM,OAAQC,iBAAMrC,cADEH,cAC0BqC,EAAI,CAAEI,IAAKtE,KAAKS,aAA6B,QAAZoB,EACjE,CACE0C,MAAOpF,aACPqF,WAAYpF,gBAEd,CAAE,GACRY,KAAKK,MAAMD,WAAa4D,GAAWK,iBAAMrC,cAAcgC,EAAS,MAChEhE,KAAKK,MAAMF,UAAY2D,GAAYO,iBAAMrC,cAAc8B,EAAU,QACxEzE,CAAA,CAnLgB,CAASgF,iBAAMI,WAAvBpF,SACFqF,aAAe,CAClB9C,eAAgB,WAAe,EAC/BD,gBAAiB,WAAe,EAChCR,KAAM,GACNC,YAAa,QACb2C,SAAU,KACV1C,4BAA4B,EAC5B4C,QAAS,KACTvC,QAAS,WAAe,EACxBJ,uBAAuB,EACvBE,MAAO,GACPC,iBAAiB,EACjBI,QAAS"}
@@ -26,7 +26,7 @@ var shallowDiffers = function shallowDiffers(a, b) {
26
26
  return false;
27
27
  };
28
28
 
29
- var _excluded = ["afterInjection", "beforeInjection", "evalScripts", "fallback", "httpRequestWithCredentials", "loading", "renumerateIRIElements", "src", "useRequestCache", "wrapper"];
29
+ var _excluded = ["afterInjection", "beforeInjection", "desc", "evalScripts", "fallback", "httpRequestWithCredentials", "loading", "renumerateIRIElements", "src", "title", "useRequestCache", "wrapper"];
30
30
  var svgNamespace = 'http://www.w3.org/2000/svg';
31
31
  var xlinkNamespace = 'http://www.w3.org/1999/xlink';
32
32
  var ReactSVG = /*#__PURE__*/function (_React$Component) {
@@ -56,10 +56,12 @@ var ReactSVG = /*#__PURE__*/function (_React$Component) {
56
56
  /* istanbul ignore else */
57
57
  if (this.reactWrapper instanceof ownerWindow(this.reactWrapper).Node) {
58
58
  var _this$props = this.props,
59
+ desc = _this$props.desc,
59
60
  evalScripts = _this$props.evalScripts,
60
61
  httpRequestWithCredentials = _this$props.httpRequestWithCredentials,
61
62
  renumerateIRIElements = _this$props.renumerateIRIElements,
62
63
  src = _this$props.src,
64
+ title = _this$props.title,
63
65
  useRequestCache = _this$props.useRequestCache;
64
66
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
65
67
  var onError = this.props.onError;
@@ -117,6 +119,25 @@ var ReactSVG = /*#__PURE__*/function (_React$Component) {
117
119
  }
118
120
  };
119
121
  var beforeEach = function beforeEach(svg) {
122
+ svg.setAttribute('role', 'img');
123
+ if (desc) {
124
+ var originalDesc = svg.querySelector(':scope > desc');
125
+ if (originalDesc) {
126
+ svg.removeChild(originalDesc);
127
+ }
128
+ var newDesc = document.createElement('desc');
129
+ newDesc.innerHTML = desc;
130
+ svg.prepend(newDesc);
131
+ }
132
+ if (title) {
133
+ var originalTitle = svg.querySelector(':scope > title');
134
+ if (originalTitle) {
135
+ svg.removeChild(originalTitle);
136
+ }
137
+ var newTitle = document.createElement('title');
138
+ newTitle.innerHTML = title;
139
+ svg.prepend(newTitle);
140
+ }
120
141
  try {
121
142
  beforeInjection(svg);
122
143
  } catch (error) {
@@ -164,12 +185,14 @@ var ReactSVG = /*#__PURE__*/function (_React$Component) {
164
185
  var _this$props2 = this.props;
165
186
  _this$props2.afterInjection;
166
187
  _this$props2.beforeInjection;
188
+ _this$props2.desc;
167
189
  _this$props2.evalScripts;
168
190
  var Fallback = _this$props2.fallback;
169
191
  _this$props2.httpRequestWithCredentials;
170
192
  var Loading = _this$props2.loading;
171
193
  _this$props2.renumerateIRIElements;
172
194
  _this$props2.src;
195
+ _this$props2.title;
173
196
  _this$props2.useRequestCache;
174
197
  var wrapper = _this$props2.wrapper,
175
198
  rest = _objectWithoutPropertiesLoose(_this$props2, _excluded);
@@ -192,6 +215,7 @@ ReactSVG.defaultProps = {
192
215
  beforeInjection: function beforeInjection() {
193
216
  return undefined;
194
217
  },
218
+ desc: '',
195
219
  evalScripts: 'never',
196
220
  fallback: null,
197
221
  httpRequestWithCredentials: false,
@@ -200,12 +224,14 @@ ReactSVG.defaultProps = {
200
224
  return undefined;
201
225
  },
202
226
  renumerateIRIElements: true,
227
+ title: '',
203
228
  useRequestCache: true,
204
229
  wrapper: 'div'
205
230
  };
206
231
  ReactSVG.propTypes = {
207
232
  afterInjection: PropTypes.func,
208
233
  beforeInjection: PropTypes.func,
234
+ desc: PropTypes.string,
209
235
  evalScripts: PropTypes.oneOf(['always', 'once', 'never']),
210
236
  fallback: PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.string]),
211
237
  httpRequestWithCredentials: PropTypes.bool,
@@ -213,6 +239,7 @@ ReactSVG.propTypes = {
213
239
  onError: PropTypes.func,
214
240
  renumerateIRIElements: PropTypes.bool,
215
241
  src: PropTypes.string.isRequired,
242
+ title: PropTypes.string,
216
243
  useRequestCache: PropTypes.bool,
217
244
  wrapper: PropTypes.oneOf(['div', 'span', 'svg'])
218
245
  } ;
@@ -1 +1 @@
1
- {"version":3,"file":"react-svg.esm.js","sources":["../compiled/owner-window.js","../compiled/shallow-differs.js","../compiled/ReactSVG.js"],"sourcesContent":["// Hat-tip: https://github.com/mui/material-ui/tree/master/packages/mui-utils/src.\nconst ownerWindow = (node) => {\n const doc = node?.ownerDocument || document;\n return doc.defaultView || window;\n};\nexport default ownerWindow;\n","// Hat-tip: https://github.com/developit/preact-compat/blob/master/src/index.js#L402.\nconst shallowDiffers = (a, b) => {\n for (const i in a) {\n if (!(i in b)) {\n return true;\n }\n }\n for (const i in b) {\n if (a[i] !== b[i]) {\n return true;\n }\n }\n return false;\n};\nexport default shallowDiffers;\n","import { SVGInjector } from '@tanem/svg-injector';\nimport * as PropTypes from 'prop-types';\nimport * as React from 'react';\nimport ownerWindow from './owner-window';\nimport shallowDiffers from './shallow-differs';\nconst svgNamespace = 'http://www.w3.org/2000/svg';\nconst xlinkNamespace = 'http://www.w3.org/1999/xlink';\nexport class ReactSVG extends React.Component {\n static defaultProps = {\n afterInjection: () => undefined,\n beforeInjection: () => undefined,\n evalScripts: 'never',\n fallback: null,\n httpRequestWithCredentials: false,\n loading: null,\n onError: () => undefined,\n renumerateIRIElements: true,\n useRequestCache: true,\n wrapper: 'div',\n };\n static propTypes = {\n afterInjection: PropTypes.func,\n beforeInjection: PropTypes.func,\n evalScripts: PropTypes.oneOf(['always', 'once', 'never']),\n fallback: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.object,\n PropTypes.string,\n ]),\n httpRequestWithCredentials: PropTypes.bool,\n loading: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.object,\n PropTypes.string,\n ]),\n onError: PropTypes.func,\n renumerateIRIElements: PropTypes.bool,\n src: PropTypes.string.isRequired,\n useRequestCache: PropTypes.bool,\n wrapper: PropTypes.oneOf(['div', 'span', 'svg']),\n };\n initialState = {\n hasError: false,\n isLoading: true,\n };\n state = this.initialState;\n _isMounted = false;\n reactWrapper;\n nonReactWrapper;\n refCallback = (reactWrapper) => {\n this.reactWrapper = reactWrapper;\n };\n renderSVG() {\n /* istanbul ignore else */\n if (this.reactWrapper instanceof ownerWindow(this.reactWrapper).Node) {\n const { evalScripts, httpRequestWithCredentials, renumerateIRIElements, src, useRequestCache, } = this.props;\n /* eslint-disable @typescript-eslint/no-non-null-assertion */\n const onError = this.props.onError;\n const beforeInjection = this.props.beforeInjection;\n const afterInjection = this.props.afterInjection;\n const wrapper = this.props.wrapper;\n let nonReactWrapper;\n let nonReactTarget;\n if (wrapper === 'svg') {\n nonReactWrapper = document.createElementNS(svgNamespace, wrapper);\n nonReactWrapper.setAttribute('xmlns', svgNamespace);\n nonReactWrapper.setAttribute('xmlns:xlink', xlinkNamespace);\n nonReactTarget = document.createElementNS(svgNamespace, wrapper);\n }\n else {\n nonReactWrapper = document.createElement(wrapper);\n nonReactTarget = document.createElement(wrapper);\n }\n nonReactWrapper.appendChild(nonReactTarget);\n nonReactTarget.dataset.src = src;\n this.nonReactWrapper = this.reactWrapper.appendChild(nonReactWrapper);\n const handleError = (error) => {\n this.removeSVG();\n if (!this._isMounted) {\n onError(error);\n return;\n }\n this.setState(() => ({\n hasError: true,\n isLoading: false,\n }), () => {\n onError(error);\n });\n };\n const afterEach = (error, svg) => {\n if (error) {\n handleError(error);\n return;\n }\n // TODO (Tane): It'd be better to cleanly unsubscribe from SVGInjector\n // callbacks instead of tracking a property like this.\n if (this._isMounted) {\n this.setState(() => ({\n isLoading: false,\n }), () => {\n try {\n afterInjection(svg);\n }\n catch (afterInjectionError) {\n handleError(afterInjectionError);\n }\n });\n }\n };\n const beforeEach = (svg) => {\n try {\n beforeInjection(svg);\n }\n catch (error) {\n handleError(error);\n }\n };\n SVGInjector(nonReactTarget, {\n afterEach,\n beforeEach,\n cacheRequests: useRequestCache,\n evalScripts,\n httpRequestWithCredentials,\n renumerateIRIElements,\n });\n }\n }\n removeSVG() {\n if (this.nonReactWrapper?.parentNode) {\n this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper);\n this.nonReactWrapper = null;\n }\n }\n componentDidMount() {\n this._isMounted = true;\n this.renderSVG();\n }\n componentDidUpdate(prevProps) {\n if (shallowDiffers({ ...prevProps }, this.props)) {\n this.setState(() => this.initialState, () => {\n this.removeSVG();\n this.renderSVG();\n });\n }\n }\n componentWillUnmount() {\n this._isMounted = false;\n this.removeSVG();\n }\n render() {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { afterInjection, beforeInjection, evalScripts, fallback: Fallback, httpRequestWithCredentials, loading: Loading, renumerateIRIElements, src, useRequestCache, wrapper, ...rest } = this.props;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const Wrapper = wrapper;\n return (React.createElement(Wrapper, { ...rest, ref: this.refCallback, ...(wrapper === 'svg'\n ? {\n xmlns: svgNamespace,\n xmlnsXlink: xlinkNamespace,\n }\n : {}) },\n this.state.isLoading && Loading && React.createElement(Loading, null),\n this.state.hasError && Fallback && React.createElement(Fallback, null)));\n }\n}\n"],"names":["ownerWindow","node","doc","ownerDocument","document","defaultView","window","shallowDiffers","a","b","i","svgNamespace","xlinkNamespace","ReactSVG","initialState","hasError","isLoading","state","_isMounted","reactWrapper","nonReactWrapper","refCallback","renderSVG","Node","props","evalScripts","httpRequestWithCredentials","renumerateIRIElements","src","useRequestCache","onError","beforeInjection","afterInjection","wrapper","nonReactTarget","createElementNS","setAttribute","createElement","appendChild","dataset","handleError","error","removeSVG","setState","afterEach","svg","afterInjectionError","beforeEach","SVGInjector","cacheRequests","parentNode","removeChild","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","render","Fallback","fallback","Loading","loading","rest","Wrapper","React","ref","xmlns","xmlnsXlink","Component","defaultProps","undefined","propTypes","PropTypes","func","oneOf","oneOfType","object","string","bool","isRequired"],"mappings":";;;;;;;AAAA;AACA,IAAMA,WAAW,GAAG,SAAdA,WAAW,CAAIC,IAAI,EAAK;EAC1B,IAAMC,GAAG,GAAG,CAAAD,IAAI,oBAAJA,IAAI,CAAEE,aAAa,KAAIC,QAAQ,CAAA;AAC3C,EAAA,OAAOF,GAAG,CAACG,WAAW,IAAIC,MAAM,CAAA;AACpC,CAAC;;ACJD;AACA,IAAMC,cAAc,GAAG,SAAjBA,cAAc,CAAIC,CAAC,EAAEC,CAAC,EAAK;AAC7B,EAAA,KAAK,IAAMC,CAAC,IAAIF,CAAC,EAAE;AACf,IAAA,IAAI,EAAEE,CAAC,IAAID,CAAC,CAAC,EAAE;AACX,MAAA,OAAO,IAAI,CAAA;AACf,KAAA;AACJ,GAAA;AACA,EAAA,KAAK,IAAMC,EAAC,IAAID,CAAC,EAAE;IACf,IAAID,CAAC,CAACE,EAAC,CAAC,KAAKD,CAAC,CAACC,EAAC,CAAC,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,OAAO,EAAEW,SAAS,CAACG,SAAS,CAAC,CACzBH,SAAS,CAACC,IAAI,EACdD,SAAS,CAACI,MAAM,EAChBJ,SAAS,CAACK,MAAM,CACnB,CAAC;EACF9C,OAAO,EAAEyC,SAAS,CAACC,IAAI;EACvB7C,qBAAqB,EAAE4C,SAAS,CAACM,IAAI;AACrCjD,EAAAA,GAAG,EAAE2C,SAAS,CAACK,MAAM,CAACE,UAAU;EAChCjD,eAAe,EAAE0C,SAAS,CAACM,IAAI;EAC/B5C,OAAO,EAAEsC,SAAS,CAACE,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AACnD,CAAC,CAAA;;;;"}
1
+ {"version":3,"file":"react-svg.esm.js","sources":["../compiled/owner-window.js","../compiled/shallow-differs.js","../compiled/ReactSVG.js"],"sourcesContent":["// Hat-tip: https://github.com/mui/material-ui/tree/master/packages/mui-utils/src.\nconst ownerWindow = (node) => {\n const doc = node?.ownerDocument || document;\n return doc.defaultView || window;\n};\nexport default ownerWindow;\n","// Hat-tip: https://github.com/developit/preact-compat/blob/master/src/index.js#L402.\nconst shallowDiffers = (a, b) => {\n for (const i in a) {\n if (!(i in b)) {\n return true;\n }\n }\n for (const i in b) {\n if (a[i] !== b[i]) {\n return true;\n }\n }\n return false;\n};\nexport default shallowDiffers;\n","import { SVGInjector } from '@tanem/svg-injector';\nimport * as PropTypes from 'prop-types';\nimport * as React from 'react';\nimport ownerWindow from './owner-window';\nimport shallowDiffers from './shallow-differs';\nconst svgNamespace = 'http://www.w3.org/2000/svg';\nconst xlinkNamespace = 'http://www.w3.org/1999/xlink';\nexport class ReactSVG extends React.Component {\n static defaultProps = {\n afterInjection: () => undefined,\n beforeInjection: () => undefined,\n desc: '',\n evalScripts: 'never',\n fallback: null,\n httpRequestWithCredentials: false,\n loading: null,\n onError: () => undefined,\n renumerateIRIElements: true,\n title: '',\n useRequestCache: true,\n wrapper: 'div',\n };\n static propTypes = {\n afterInjection: PropTypes.func,\n beforeInjection: PropTypes.func,\n desc: PropTypes.string,\n evalScripts: PropTypes.oneOf(['always', 'once', 'never']),\n fallback: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.object,\n PropTypes.string,\n ]),\n httpRequestWithCredentials: PropTypes.bool,\n loading: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.object,\n PropTypes.string,\n ]),\n onError: PropTypes.func,\n renumerateIRIElements: PropTypes.bool,\n src: PropTypes.string.isRequired,\n title: PropTypes.string,\n useRequestCache: PropTypes.bool,\n wrapper: PropTypes.oneOf(['div', 'span', 'svg']),\n };\n initialState = {\n hasError: false,\n isLoading: true,\n };\n state = this.initialState;\n _isMounted = false;\n reactWrapper;\n nonReactWrapper;\n refCallback = (reactWrapper) => {\n this.reactWrapper = reactWrapper;\n };\n renderSVG() {\n /* istanbul ignore else */\n if (this.reactWrapper instanceof ownerWindow(this.reactWrapper).Node) {\n const { desc, evalScripts, httpRequestWithCredentials, renumerateIRIElements, src, title, useRequestCache, } = this.props;\n /* eslint-disable @typescript-eslint/no-non-null-assertion */\n const onError = this.props.onError;\n const beforeInjection = this.props.beforeInjection;\n const afterInjection = this.props.afterInjection;\n const wrapper = this.props.wrapper;\n let nonReactWrapper;\n let nonReactTarget;\n if (wrapper === 'svg') {\n nonReactWrapper = document.createElementNS(svgNamespace, wrapper);\n nonReactWrapper.setAttribute('xmlns', svgNamespace);\n nonReactWrapper.setAttribute('xmlns:xlink', xlinkNamespace);\n nonReactTarget = document.createElementNS(svgNamespace, wrapper);\n }\n else {\n nonReactWrapper = document.createElement(wrapper);\n nonReactTarget = document.createElement(wrapper);\n }\n nonReactWrapper.appendChild(nonReactTarget);\n nonReactTarget.dataset.src = src;\n this.nonReactWrapper = this.reactWrapper.appendChild(nonReactWrapper);\n const handleError = (error) => {\n this.removeSVG();\n if (!this._isMounted) {\n onError(error);\n return;\n }\n this.setState(() => ({\n hasError: true,\n isLoading: false,\n }), () => {\n onError(error);\n });\n };\n const afterEach = (error, svg) => {\n if (error) {\n handleError(error);\n return;\n }\n // TODO (Tane): It'd be better to cleanly unsubscribe from SVGInjector\n // callbacks instead of tracking a property like this.\n if (this._isMounted) {\n this.setState(() => ({\n isLoading: false,\n }), () => {\n try {\n afterInjection(svg);\n }\n catch (afterInjectionError) {\n handleError(afterInjectionError);\n }\n });\n }\n };\n const beforeEach = (svg) => {\n svg.setAttribute('role', 'img');\n if (desc) {\n const originalDesc = svg.querySelector(':scope > desc');\n if (originalDesc) {\n svg.removeChild(originalDesc);\n }\n const newDesc = document.createElement('desc');\n newDesc.innerHTML = desc;\n svg.prepend(newDesc);\n }\n if (title) {\n const originalTitle = svg.querySelector(':scope > title');\n if (originalTitle) {\n svg.removeChild(originalTitle);\n }\n const newTitle = document.createElement('title');\n newTitle.innerHTML = title;\n svg.prepend(newTitle);\n }\n try {\n beforeInjection(svg);\n }\n catch (error) {\n handleError(error);\n }\n };\n SVGInjector(nonReactTarget, {\n afterEach,\n beforeEach,\n cacheRequests: useRequestCache,\n evalScripts,\n httpRequestWithCredentials,\n renumerateIRIElements,\n });\n }\n }\n removeSVG() {\n if (this.nonReactWrapper?.parentNode) {\n this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper);\n this.nonReactWrapper = null;\n }\n }\n componentDidMount() {\n this._isMounted = true;\n this.renderSVG();\n }\n componentDidUpdate(prevProps) {\n if (shallowDiffers({ ...prevProps }, this.props)) {\n this.setState(() => this.initialState, () => {\n this.removeSVG();\n this.renderSVG();\n });\n }\n }\n componentWillUnmount() {\n this._isMounted = false;\n this.removeSVG();\n }\n render() {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { afterInjection, beforeInjection, desc, evalScripts, fallback: Fallback, httpRequestWithCredentials, loading: Loading, renumerateIRIElements, src, title, useRequestCache, wrapper, ...rest } = this.props;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const Wrapper = wrapper;\n return (React.createElement(Wrapper, { ...rest, ref: this.refCallback, ...(wrapper === 'svg'\n ? {\n xmlns: svgNamespace,\n xmlnsXlink: xlinkNamespace,\n }\n : {}) },\n this.state.isLoading && Loading && React.createElement(Loading, null),\n this.state.hasError && Fallback && React.createElement(Fallback, null)));\n }\n}\n"],"names":["ownerWindow","node","doc","ownerDocument","document","defaultView","window","shallowDiffers","a","b","i","svgNamespace","xlinkNamespace","ReactSVG","initialState","hasError","isLoading","state","_isMounted","reactWrapper","nonReactWrapper","refCallback","renderSVG","Node","props","desc","evalScripts","httpRequestWithCredentials","renumerateIRIElements","src","title","useRequestCache","onError","beforeInjection","afterInjection","wrapper","nonReactTarget","createElementNS","setAttribute","createElement","appendChild","dataset","handleError","error","removeSVG","setState","afterEach","svg","afterInjectionError","beforeEach","originalDesc","querySelector","removeChild","newDesc","innerHTML","prepend","originalTitle","newTitle","SVGInjector","cacheRequests","parentNode","componentDidMount","componentDidUpdate","prevProps","componentWillUnmount","render","Fallback","fallback","Loading","loading","rest","Wrapper","React","ref","xmlns","xmlnsXlink","Component","defaultProps","undefined","propTypes","PropTypes","func","string","oneOf","oneOfType","object","bool","isRequired"],"mappings":";;;;;;;AAAA;AACA,IAAMA,WAAW,GAAG,SAAdA,WAAW,CAAIC,IAAI,EAAK;EAC1B,IAAMC,GAAG,GAAG,CAAAD,IAAI,oBAAJA,IAAI,CAAEE,aAAa,KAAIC,QAAQ,CAAA;AAC3C,EAAA,OAAOF,GAAG,CAACG,WAAW,IAAIC,MAAM,CAAA;AACpC,CAAC;;ACJD;AACA,IAAMC,cAAc,GAAG,SAAjBA,cAAc,CAAIC,CAAC,EAAEC,CAAC,EAAK;AAC7B,EAAA,KAAK,IAAMC,CAAC,IAAIF,CAAC,EAAE;AACf,IAAA,IAAI,EAAEE,CAAC,IAAID,CAAC,CAAC,EAAE;AACX,MAAA,OAAO,IAAI,CAAA;AACf,KAAA;AACJ,GAAA;AACA,EAAA,KAAK,IAAMC,EAAC,IAAID,CAAC,EAAE;IACf,IAAID,CAAC,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