react-svg 17.0.1 → 17.0.3

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,14 +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
+ - `desc` - _Optional_ String used for SVG `<desc>` element content. If a `<desc>` exists it will be replaced, otherwise a new `<desc>` is created. When set, a unique `id` is added to the `<desc>` element and `aria-describedby` is set on the SVG for assistive technology. Defaults to `''`, which is a noop.
56
56
  - `evalScripts` - _Optional_ Run any script blocks found in the SVG. One of `'always'`, `'once'`, or `'never'`. Defaults to `'never'`.
57
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`.
58
58
  - `httpRequestWithCredentials` - _Optional_ Boolean indicating if cross-site Access-Control requests for the SVG should be made using credentials. Defaults to `false`.
59
59
  - `loading` - _Optional_ Component to use during loading. Can be a string, class component, or function component. Defaults to `null`.
60
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 `() => {}`.
61
- - `renumerateIRIElements` - _Optional_ Boolean indicating if SVG IRI addressable elements should be renumerated. Defaults to `true`. When enabled, IDs on IRI-addressable elements (`clipPath`, `linearGradient`, `mask`, `path`, etc.) are made unique, and all references to them presentation attributes, `href`/`xlink:href`, inline `style` attributes, and `<style>` element text are updated. Note: all matching element types are renumerated, not only those inside `<defs>`. Set to `false` if you need to query injected elements by their original IDs.
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
+ - `renumerateIRIElements` - _Optional_ Boolean indicating if SVG IRI addressable elements should be renumerated. Defaults to `true`. When enabled, IDs on IRI-addressable elements (`clipPath`, `linearGradient`, `mask`, `path`, etc.) are made unique, and all references to them (presentation attributes, `href`/`xlink:href`, inline `style` attributes, and `<style>` element text) are updated. Note: all matching element types are renumerated, not only those inside `<defs>`. Set to `false` if you need to query injected elements by their original IDs.
62
+ - `title` - _Optional_ String used for SVG `<title>` element content. If a `<title>` exists it will be replaced, otherwise a new `<title>` is created. When set, a unique `id` is added to the `<title>` element and `aria-labelledby` is set on the SVG for assistive technology. Defaults to `''`, which is a noop.
63
63
  - `useRequestCache` - _Optional_ Use SVG request cache. Defaults to `true`.
64
64
  - `wrapper` - _Optional_ Wrapper element types. One of `'div'`, `'span'` or `'svg'`. Defaults to `'div'`.
65
65
 
@@ -140,7 +140,7 @@ Example output, assuming a `div` wrapper:
140
140
 
141
141
  See:
142
142
 
143
- - [Integrating with Other Libraries](https://reactjs.org/docs/integrating-with-other-libraries.html).
143
+ - [Integrating with Other Libraries](https://legacy.reactjs.org/docs/integrating-with-other-libraries.html).
144
144
 
145
145
  Related issues and PRs:
146
146
 
@@ -51,6 +51,11 @@ var shallowDiffers = function shallowDiffers(a, b) {
51
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
+ // Random prefix avoids ID collisions when multiple copies of react-svg are
55
+ // bundled (e.g. microfrontends). The counter ensures each component instance
56
+ // within the same bundle gets a unique ID.
57
+ var idPrefix = "react-svg-" + Math.random().toString(36).slice(2, 6);
58
+ var idCounter = 0;
54
59
  var ReactSVG = /*#__PURE__*/function (_React$Component) {
55
60
  function ReactSVG() {
56
61
  var _this;
@@ -139,25 +144,52 @@ var ReactSVG = /*#__PURE__*/function (_React$Component) {
139
144
  });
140
145
  }
141
146
  };
147
+ // WAI best practice: SVGs need role="img" plus aria-labelledby/
148
+ // aria-describedby pointing to <title>/<desc> element IDs for screen
149
+ // readers to announce them. svg-injector copies the HTML title
150
+ // *attribute* (tooltip) but doesn't create SVG-namespace child
151
+ // elements or ARIA linkage, so we handle that here.
142
152
  var beforeEach = function beforeEach(svg) {
143
153
  svg.setAttribute('role', 'img');
144
- if (desc) {
145
- var originalDesc = svg.querySelector(':scope > desc');
146
- if (originalDesc) {
147
- svg.removeChild(originalDesc);
148
- }
149
- var newDesc = document.createElement('desc');
150
- newDesc.innerHTML = desc;
151
- svg.prepend(newDesc);
152
- }
154
+ var ariaLabelledBy = [];
155
+ var ariaDescribedBy = [];
153
156
  if (title) {
154
157
  var originalTitle = svg.querySelector(':scope > title');
155
158
  if (originalTitle) {
156
159
  svg.removeChild(originalTitle);
157
160
  }
158
- var newTitle = document.createElement('title');
159
- newTitle.innerHTML = title;
161
+ var titleId = idPrefix + "-title-" + ++idCounter;
162
+ // createElementNS is required: createElement would produce an
163
+ // HTML-namespace node that screen readers ignore inside SVG.
164
+ var newTitle = document.createElementNS(svgNamespace, 'title');
165
+ newTitle.id = titleId;
166
+ newTitle.textContent = title;
160
167
  svg.prepend(newTitle);
168
+ ariaLabelledBy.push(titleId);
169
+ }
170
+ if (desc) {
171
+ var originalDesc = svg.querySelector(':scope > desc');
172
+ if (originalDesc) {
173
+ svg.removeChild(originalDesc);
174
+ }
175
+ var descId = idPrefix + "-desc-" + ++idCounter;
176
+ var newDesc = document.createElementNS(svgNamespace, 'desc');
177
+ newDesc.id = descId;
178
+ newDesc.textContent = desc;
179
+ // Insert after <title> if present, otherwise prepend.
180
+ var existingTitle = svg.querySelector(':scope > title');
181
+ if (existingTitle) {
182
+ existingTitle.after(newDesc);
183
+ } else {
184
+ svg.prepend(newDesc);
185
+ }
186
+ ariaDescribedBy.push(descId);
187
+ }
188
+ if (ariaLabelledBy.length > 0) {
189
+ svg.setAttribute('aria-labelledby', ariaLabelledBy.join(' '));
190
+ }
191
+ if (ariaDescribedBy.length > 0) {
192
+ svg.setAttribute('aria-describedby', ariaDescribedBy.join(' '));
161
193
  }
162
194
  try {
163
195
  beforeInjection(svg);
@@ -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 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 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 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","_React$Component","_this","_len","arguments","length","args","Array","_key","call","apply","concat","initialState","hasError","isLoading","state","_isMounted","reactWrapper","nonReactWrapper","refCallback","_inheritsLoose","_proto","prototype","renderSVG","_this2","Node","_this$props","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","_this$nonReactWrapper","parentNode","componentDidMount","componentDidUpdate","prevProps","_this3","_extends","componentWillUnmount","render","_this$props2","Fallback","fallback","Loading","loading","rest","_objectWithoutPropertiesLoose","_excluded","Wrapper","React","ref","xmlns","xmlnsXlink","Component","defaultProps","undefined","propTypes","PropTypes","func","string","oneOf","oneOfType","object","bool","isRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA,IAAMA,WAAW,GAAG,SAAdA,WAAWA,CAAIC,IAAI,EAAK;EAC1B,IAAMC,GAAG,GAAG,CAAAD,IAAI,oBAAJA,IAAI,CAAEE,aAAa,KAAIC,QAAQ;AAC3C,EAAA,OAAOF,GAAG,CAACG,WAAW,IAAIC,MAAM;AACpC,CAAC;;ACJD;AACA,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,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;AACf,IAAA;AACJ,EAAA;AACA,EAAA,KAAK,IAAMC,EAAC,IAAID,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K,EAAEwD,oBAAS,CAACE,MAAM;EACvBzD,eAAe,EAAEuD,oBAAS,CAACM,IAAI;EAC/BzD,OAAO,EAAEmD,oBAAS,CAACG,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC;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';\n// Random prefix avoids ID collisions when multiple copies of react-svg are\n// bundled (e.g. microfrontends). The counter ensures each component instance\n// within the same bundle gets a unique ID.\nconst idPrefix = `react-svg-${Math.random().toString(36).slice(2, 6)}`;\nlet idCounter = 0;\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 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 // WAI best practice: SVGs need role=\"img\" plus aria-labelledby/\n // aria-describedby pointing to <title>/<desc> element IDs for screen\n // readers to announce them. svg-injector copies the HTML title\n // *attribute* (tooltip) but doesn't create SVG-namespace child\n // elements or ARIA linkage, so we handle that here.\n const beforeEach = (svg) => {\n svg.setAttribute('role', 'img');\n const ariaLabelledBy = [];\n const ariaDescribedBy = [];\n if (title) {\n const originalTitle = svg.querySelector(':scope > title');\n if (originalTitle) {\n svg.removeChild(originalTitle);\n }\n const titleId = `${idPrefix}-title-${++idCounter}`;\n // createElementNS is required: createElement would produce an\n // HTML-namespace node that screen readers ignore inside SVG.\n const newTitle = document.createElementNS(svgNamespace, 'title');\n newTitle.id = titleId;\n newTitle.textContent = title;\n svg.prepend(newTitle);\n ariaLabelledBy.push(titleId);\n }\n if (desc) {\n const originalDesc = svg.querySelector(':scope > desc');\n if (originalDesc) {\n svg.removeChild(originalDesc);\n }\n const descId = `${idPrefix}-desc-${++idCounter}`;\n const newDesc = document.createElementNS(svgNamespace, 'desc');\n newDesc.id = descId;\n newDesc.textContent = desc;\n // Insert after <title> if present, otherwise prepend.\n const existingTitle = svg.querySelector(':scope > title');\n if (existingTitle) {\n existingTitle.after(newDesc);\n }\n else {\n svg.prepend(newDesc);\n }\n ariaDescribedBy.push(descId);\n }\n if (ariaLabelledBy.length > 0) {\n svg.setAttribute('aria-labelledby', ariaLabelledBy.join(' '));\n }\n if (ariaDescribedBy.length > 0) {\n svg.setAttribute('aria-describedby', ariaDescribedBy.join(' '));\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 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","idPrefix","Math","random","toString","slice","idCounter","ReactSVG","_React$Component","_this","_len","arguments","length","args","Array","_key","call","apply","concat","initialState","hasError","isLoading","state","_isMounted","reactWrapper","nonReactWrapper","refCallback","_inheritsLoose","_proto","prototype","renderSVG","_this2","Node","_this$props","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","ariaLabelledBy","ariaDescribedBy","originalTitle","querySelector","removeChild","titleId","newTitle","id","textContent","prepend","push","originalDesc","descId","newDesc","existingTitle","after","join","SVGInjector","cacheRequests","_this$nonReactWrapper","parentNode","componentDidMount","componentDidUpdate","prevProps","_this3","_extends","componentWillUnmount","render","_this$props2","Fallback","fallback","Loading","loading","rest","_objectWithoutPropertiesLoose","_excluded","Wrapper","React","ref","xmlns","xmlnsXlink","Component","defaultProps","undefined","propTypes","PropTypes","func","string","oneOf","oneOfType","object","bool","isRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA,IAAMA,WAAW,GAAG,SAAdA,WAAWA,CAAIC,IAAI,EAAK;EAC1B,IAAMC,GAAG,GAAG,CAAAD,IAAI,oBAAJA,IAAI,CAAEE,aAAa,KAAIC,QAAQ;AAC3C,EAAA,OAAOF,GAAG,CAACG,WAAW,IAAIC,MAAM;AACpC,CAAC;;ACJD;AACA,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,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;AACf,IAAA;AACJ,EAAA;AACA,EAAA,KAAK,IAAMC,EAAC,IAAID,CAAC,EAAE;IACf,IAAID,CAAC,CAACE,EAAC,CAAC,KAAKD,CAAC,CAACC,EAAC,CAAC,EAAE;AACf,MAAA,OAAO,IAAI;AACf,IAAA;AACJ,EAAA;AACA,EAAA,OAAO,KAAK;AAChB,CAAC;;;ACRD,IAAMC,YAAY,GAAG,4BAA4B;AACjD,IAAMC,cAAc,GAAG,8BAA8B;AACrD;AACA;AACA;AACA,IAAMC,QAAQ,GAAA,YAAA,GAAgBC,IAAI,CAACC,MAAM,EAAE,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAG;AACtE,IAAIC,SAAS,GAAG,CAAC;AACjB,IAAaC,QAAQ,0BAAAC,gBAAA,EAAA;AAAA,EAAA,SAAAD,QAAAA,GAAA;AAAA,IAAA,IAAAE,KAAA;AAAA,IAAA,KAAA,IAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAC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CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACzDlB,EAAAA,QAAQ,EAAEe,oBAAS,CAACI,SAAS,CAAC,CAC1BJ,oBAAS,CAACC,IAAI,EACdD,oBAAS,CAACK,MAAM,EAChBL,oBAAS,CAACE,MAAM,CACnB,CAAC;EACFtE,0BAA0B,EAAEoE,oBAAS,CAACM,IAAI;AAC1CnB,EAAAA,OAAO,EAAEa,oBAAS,CAACI,SAAS,CAAC,CACzBJ,oBAAS,CAACC,IAAI,EACdD,oBAAS,CAACK,MAAM,EAChBL,oBAAS,CAACE,MAAM,CACnB,CAAC;EACFjE,OAAO,EAAE+D,oBAAS,CAACC,IAAI;EACvBpE,qBAAqB,EAAEmE,oBAAS,CAACM,IAAI;AACrCxE,EAAAA,GAAG,EAAEkE,oBAAS,CAACE,MAAM,CAACK,UAAU;EAChCxE,KAAK,EAAEiE,oBAAS,CAACE,MAAM;EACvBlE,eAAe,EAAEgE,oBAAS,CAACM,IAAI;EAC/BlE,OAAO,EAAE4D,oBAAS,CAACG,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC;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","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;
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",idPrefix="react-svg-"+Math.random().toString(36).slice(2,6),idCounter=0,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,l=n.title,u=n.useRequestCache,p=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(){p(t)}):p(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){e.setAttribute("role","img");var t=[],r=[];if(l){var n=e.querySelector(":scope > title");n&&e.removeChild(n);var i=idPrefix+"-title-"+ ++idCounter,o=document.createElementNS(svgNamespace,"title");o.id=i,o.textContent=l,e.prepend(o),t.push(i)}if(a){var s=e.querySelector(":scope > desc");s&&e.removeChild(s);var c=idPrefix+"-desc-"+ ++idCounter,u=document.createElementNS(svgNamespace,"desc");u.id=c,u.textContent=a;var p=e.querySelector(":scope > title");p?p.after(u):e.prepend(u),r.push(c)}t.length>0&&e.setAttribute("aria-labelledby",t.join(" ")),r.length>0&&e.setAttribute("aria-describedby",r.join(" "));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 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 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 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","_extends","componentWillUnmount","render","_this$props2","Fallback","fallback","Loading","loading","rest","_objectWithoutPropertiesLoose","_excluded","React","ref","xmlns","xmlnsXlink","Component","defaultProps"],"mappings":"+mBACMA,YAAc,SAACC,GAEjB,cADYA,SAAAA,EAAMC,gBAAiBC,UACxBC,aAAeC,MAC9B,ECHMC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6C,EAAsBC,aACtBtD,KAAKQ,gBAAgB8C,WAAWR,YAAY9C,KAAKQ,iBACjDR,KAAKQ,gBAAkB,KAE/B,EAACG,EACD4C,kBAAA,WACIvD,KAAKM,YAAa,EAClBN,KAAKa,WACT,EAACF,EACD6C,mBAAA,SAAmBC,GAAW,IAAAC,EAAA1D,KACtBjB,eAAc4E,SAAA,CAAA,EAAMF,GAAazD,KAAKkB,QACtClB,KAAKsC,SAAS,WAAA,OAAMoB,EAAKxD,YAAY,EAAE,WACnCwD,EAAKrB,YACLqB,EAAK7C,WACT,EAER,EAACF,EACDiD,qBAAA,WACI5D,KAAKM,YAAa,EAClBN,KAAKqC,WACT,EAAC1B,EACDkD,OAAA,WAEI,IAAAC,EAAuM9D,KAAKkB,MAAtI6C,EAAQD,EAAlBE,SAAyDC,EAAOH,EAAhBI,QAAsErC,EAAOiC,EAAPjC,QAAYsC,EAAIC,8BAAAN,EAAAO,WAGlM,OAAQC,iBAAMtC,cADEH,EACmB8B,YAAOQ,EAAI,CAAEI,IAAKvE,KAAKS,aAA6B,QAAZoB,EACjE,CACE2C,MAAOrF,aACPsF,WAAYrF,gBAEd,CAAA,GACNY,KAAKK,MAAMD,WAAa6D,GAAWK,iBAAMtC,cAAciC,EAAS,MAChEjE,KAAKK,MAAMF,UAAY4D,GAAYO,iBAAMtC,cAAc+B,EAAU,MACzE,EAAC1E,CAAA,EAjLyBiF,iBAAMI,WAAvBrF,SACFsF,aAAe,CAClB/C,eAAgB,WAAe,EAC/BD,gBAAiB,WAAe,EAChCR,KAAM,GACNC,YAAa,QACb4C,SAAU,KACV3C,4BAA4B,EAC5B6C,QAAS,KACTxC,QAAS,WAAe,EACxBJ,uBAAuB,EACvBE,MAAO,GACPC,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';\n// Random prefix avoids ID collisions when multiple copies of react-svg are\n// bundled (e.g. microfrontends). The counter ensures each component instance\n// within the same bundle gets a unique ID.\nconst idPrefix = `react-svg-${Math.random().toString(36).slice(2, 6)}`;\nlet idCounter = 0;\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 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 // WAI best practice: SVGs need role=\"img\" plus aria-labelledby/\n // aria-describedby pointing to <title>/<desc> element IDs for screen\n // readers to announce them. svg-injector copies the HTML title\n // *attribute* (tooltip) but doesn't create SVG-namespace child\n // elements or ARIA linkage, so we handle that here.\n const beforeEach = (svg) => {\n svg.setAttribute('role', 'img');\n const ariaLabelledBy = [];\n const ariaDescribedBy = [];\n if (title) {\n const originalTitle = svg.querySelector(':scope > title');\n if (originalTitle) {\n svg.removeChild(originalTitle);\n }\n const titleId = `${idPrefix}-title-${++idCounter}`;\n // createElementNS is required: createElement would produce an\n // HTML-namespace node that screen readers ignore inside SVG.\n const newTitle = document.createElementNS(svgNamespace, 'title');\n newTitle.id = titleId;\n newTitle.textContent = title;\n svg.prepend(newTitle);\n ariaLabelledBy.push(titleId);\n }\n if (desc) {\n const originalDesc = svg.querySelector(':scope > desc');\n if (originalDesc) {\n svg.removeChild(originalDesc);\n }\n const descId = `${idPrefix}-desc-${++idCounter}`;\n const newDesc = document.createElementNS(svgNamespace, 'desc');\n newDesc.id = descId;\n newDesc.textContent = desc;\n // Insert after <title> if present, otherwise prepend.\n const existingTitle = svg.querySelector(':scope > title');\n if (existingTitle) {\n existingTitle.after(newDesc);\n }\n else {\n svg.prepend(newDesc);\n }\n ariaDescribedBy.push(descId);\n }\n if (ariaLabelledBy.length > 0) {\n svg.setAttribute('aria-labelledby', ariaLabelledBy.join(' '));\n }\n if (ariaDescribedBy.length > 0) {\n svg.setAttribute('aria-describedby', ariaDescribedBy.join(' '));\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 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","idPrefix","Math","random","toString","slice","idCounter","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","ariaLabelledBy","ariaDescribedBy","originalTitle","querySelector","removeChild","titleId","newTitle","id","textContent","prepend","push","originalDesc","descId","newDesc","existingTitle","after","join","cacheRequests","_this$nonReactWrapper","parentNode","componentDidMount","componentDidUpdate","prevProps","_this3","_extends","componentWillUnmount","render","_this$props2","Fallback","fallback","Loading","loading","rest","_objectWithoutPropertiesLoose","_excluded","React","ref","xmlns","xmlnsXlink","Component","defaultProps"],"mappings":"+mBACMA,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,GACX,OAAO,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+F,aAAe,CAClBxD,eAAgB,WAAe,EAC/BD,gBAAiB,WAAe,EAChCR,KAAM,GACNC,YAAa,QACbqD,SAAU,KACVpD,4BAA4B,EAC5BsD,QAAS,KACTjD,QAAS,WAAe,EACxBJ,uBAAuB,EACvBE,MAAO,GACPC,iBAAiB,EACjBI,QAAS"}
@@ -29,6 +29,11 @@ var shallowDiffers = function shallowDiffers(a, b) {
29
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
+ // Random prefix avoids ID collisions when multiple copies of react-svg are
33
+ // bundled (e.g. microfrontends). The counter ensures each component instance
34
+ // within the same bundle gets a unique ID.
35
+ var idPrefix = "react-svg-" + Math.random().toString(36).slice(2, 6);
36
+ var idCounter = 0;
32
37
  var ReactSVG = /*#__PURE__*/function (_React$Component) {
33
38
  function ReactSVG() {
34
39
  var _this;
@@ -117,25 +122,52 @@ var ReactSVG = /*#__PURE__*/function (_React$Component) {
117
122
  });
118
123
  }
119
124
  };
125
+ // WAI best practice: SVGs need role="img" plus aria-labelledby/
126
+ // aria-describedby pointing to <title>/<desc> element IDs for screen
127
+ // readers to announce them. svg-injector copies the HTML title
128
+ // *attribute* (tooltip) but doesn't create SVG-namespace child
129
+ // elements or ARIA linkage, so we handle that here.
120
130
  var beforeEach = function beforeEach(svg) {
121
131
  svg.setAttribute('role', 'img');
122
- if (desc) {
123
- var originalDesc = svg.querySelector(':scope > desc');
124
- if (originalDesc) {
125
- svg.removeChild(originalDesc);
126
- }
127
- var newDesc = document.createElement('desc');
128
- newDesc.innerHTML = desc;
129
- svg.prepend(newDesc);
130
- }
132
+ var ariaLabelledBy = [];
133
+ var ariaDescribedBy = [];
131
134
  if (title) {
132
135
  var originalTitle = svg.querySelector(':scope > title');
133
136
  if (originalTitle) {
134
137
  svg.removeChild(originalTitle);
135
138
  }
136
- var newTitle = document.createElement('title');
137
- newTitle.innerHTML = title;
139
+ var titleId = idPrefix + "-title-" + ++idCounter;
140
+ // createElementNS is required: createElement would produce an
141
+ // HTML-namespace node that screen readers ignore inside SVG.
142
+ var newTitle = document.createElementNS(svgNamespace, 'title');
143
+ newTitle.id = titleId;
144
+ newTitle.textContent = title;
138
145
  svg.prepend(newTitle);
146
+ ariaLabelledBy.push(titleId);
147
+ }
148
+ if (desc) {
149
+ var originalDesc = svg.querySelector(':scope > desc');
150
+ if (originalDesc) {
151
+ svg.removeChild(originalDesc);
152
+ }
153
+ var descId = idPrefix + "-desc-" + ++idCounter;
154
+ var newDesc = document.createElementNS(svgNamespace, 'desc');
155
+ newDesc.id = descId;
156
+ newDesc.textContent = desc;
157
+ // Insert after <title> if present, otherwise prepend.
158
+ var existingTitle = svg.querySelector(':scope > title');
159
+ if (existingTitle) {
160
+ existingTitle.after(newDesc);
161
+ } else {
162
+ svg.prepend(newDesc);
163
+ }
164
+ ariaDescribedBy.push(descId);
165
+ }
166
+ if (ariaLabelledBy.length > 0) {
167
+ svg.setAttribute('aria-labelledby', ariaLabelledBy.join(' '));
168
+ }
169
+ if (ariaDescribedBy.length > 0) {
170
+ svg.setAttribute('aria-describedby', ariaDescribedBy.join(' '));
139
171
  }
140
172
  try {
141
173
  beforeInjection(svg);
@@ -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 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 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 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","_React$Component","_this","_len","arguments","length","args","Array","_key","call","apply","concat","initialState","hasError","isLoading","state","_isMounted","reactWrapper","nonReactWrapper","refCallback","_inheritsLoose","_proto","prototype","renderSVG","_this2","Node","_this$props","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","_this$nonReactWrapper","parentNode","componentDidMount","componentDidUpdate","prevProps","_this3","_extends","componentWillUnmount","render","_this$props2","Fallback","fallback","Loading","loading","rest","_objectWithoutPropertiesLoose","_excluded","Wrapper","React","ref","xmlns","xmlnsXlink","Component","defaultProps","undefined","propTypes","PropTypes","func","string","oneOf","oneOfType","object","bool","isRequired"],"mappings":";;;;;;;AAAA;AACA,IAAMA,WA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C,CAC1BJ,SAAS,CAACC,IAAI,EACdD,SAAS,CAACK,MAAM,EAChBL,SAAS,CAACE,MAAM,CACnB,CAAC;EACF7D,0BAA0B,EAAE2D,SAAS,CAACM,IAAI;AAC1CnB,EAAAA,OAAO,EAAEa,SAAS,CAACI,SAAS,CAAC,CACzBJ,SAAS,CAACC,IAAI,EACdD,SAAS,CAACK,MAAM,EAChBL,SAAS,CAACE,MAAM,CACnB,CAAC;EACFxD,OAAO,EAAEsD,SAAS,CAACC,IAAI;EACvB3D,qBAAqB,EAAE0D,SAAS,CAACM,IAAI;AACrC/D,EAAAA,GAAG,EAAEyD,SAAS,CAACE,MAAM,CAACK,UAAU;EAChC/D,KAAK,EAAEwD,SAAS,CAACE,MAAM;EACvBzD,eAAe,EAAEuD,SAAS,CAACM,IAAI;EAC/BzD,OAAO,EAAEmD,SAAS,CAACG,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC;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';\n// Random prefix avoids ID collisions when multiple copies of react-svg are\n// bundled (e.g. microfrontends). The counter ensures each component instance\n// within the same bundle gets a unique ID.\nconst idPrefix = `react-svg-${Math.random().toString(36).slice(2, 6)}`;\nlet idCounter = 0;\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 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 // WAI best practice: SVGs need role=\"img\" plus aria-labelledby/\n // aria-describedby pointing to <title>/<desc> element IDs for screen\n // readers to announce them. svg-injector copies the HTML title\n // *attribute* (tooltip) but doesn't create SVG-namespace child\n // elements or ARIA linkage, so we handle that here.\n const beforeEach = (svg) => {\n svg.setAttribute('role', 'img');\n const ariaLabelledBy = [];\n const ariaDescribedBy = [];\n if (title) {\n const originalTitle = svg.querySelector(':scope > title');\n if (originalTitle) {\n svg.removeChild(originalTitle);\n }\n const titleId = `${idPrefix}-title-${++idCounter}`;\n // createElementNS is required: createElement would produce an\n // HTML-namespace node that screen readers ignore inside SVG.\n const newTitle = document.createElementNS(svgNamespace, 'title');\n newTitle.id = titleId;\n newTitle.textContent = title;\n svg.prepend(newTitle);\n ariaLabelledBy.push(titleId);\n }\n if (desc) {\n const originalDesc = svg.querySelector(':scope > desc');\n if (originalDesc) {\n svg.removeChild(originalDesc);\n }\n const descId = `${idPrefix}-desc-${++idCounter}`;\n const newDesc = document.createElementNS(svgNamespace, 'desc');\n newDesc.id = descId;\n newDesc.textContent = desc;\n // Insert after <title> if present, otherwise prepend.\n const existingTitle = svg.querySelector(':scope > title');\n if (existingTitle) {\n existingTitle.after(newDesc);\n }\n else {\n svg.prepend(newDesc);\n }\n ariaDescribedBy.push(descId);\n }\n if (ariaLabelledBy.length > 0) {\n svg.setAttribute('aria-labelledby', ariaLabelledBy.join(' '));\n }\n if (ariaDescribedBy.length > 0) {\n svg.setAttribute('aria-describedby', ariaDescribedBy.join(' '));\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 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","idPrefix","Math","random","toString","slice","idCounter","ReactSVG","_React$Component","_this","_len","arguments","length","args","Array","_key","call","apply","concat","initialState","hasError","isLoading","state","_isMounted","reactWrapper","nonReactWrapper","refCallback","_inheritsLoose","_proto","prototype","renderSVG","_this2","Node","_this$props","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","ariaLabelledBy","ariaDescribedBy","originalTitle","querySelector","removeChild","titleId","newTitle","id","textContent","prepend","push","originalDesc","descId","newDesc","existingTitle","after","join","SVGInjector","cacheRequests","_this$nonReactWrapper","parentNode","componentDidMount","componentDidUpdate","prevProps","_this3","_extends","componentWillUnmount","render","_this$props2","Fallback","fallback","Loading","loading","rest","_objectWithoutPropertiesLoose","_excluded","Wrapper","React","ref","xmlns","xmlnsXlink","Component","defaultProps","undefined","propTypes","PropTypes","func","string","oneOf","oneOfType","object","bool","isRequired"],"mappings":";;;;;;;AAAA;AACA,IAAMA,WAAW,GAAG,SAAdA,WAAWA,CAAIC,IAAI,EAAK;EAC1B,IAAMC,GAAG,GAAG,CAAAD,IAAI,oBAAJA,IAAI,CAAEE,aAAa,KAAIC,QAAQ;AAC3C,EAAA,OAAOF,GAAG,CAACG,WAAW,IAAIC,MAAM;AACpC,CAAC;;ACJD;AACA,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,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;AACf,IAAA;AACJ,EAAA;AACA,EAAA,KAAK,IAAMC,EAAC,IAAID,CAAC,EAAE;IACf,IAAID,CAAC,CAACE,EAAC,CAAC,KAAKD,CAAC,CAACC,EAAC,CAAC,EAAE;AACf,MAAA,OAAO,IAAI;AACf,IAAA;AACJ,EAAA;AACA,EAAA,OAAO,KAAK;AAChB,CAAC;;;ACRD,IAAMC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;AAAA,IAAA,OAAQ6D,SAAS;AAAA,EAAA,CAAA;AACxBjE,EAAAA,qBAAqB,EAAE,IAAI;AAC3BE,EAAAA,KAAK,EAAE,EAAE;AACTC,EAAAA,eAAe,EAAE,IAAI;AACrBI,EAAAA,OAAO,EAAE;AACb,CAAC;AAdQtC,QAAQ,CAeViG,SAAS,GAAG;EACf5D,cAAc,EAAE6D,SAAS,CAACC,IAAI;EAC9B/D,eAAe,EAAE8D,SAAS,CAACC,IAAI;EAC/BvE,IAAI,EAAEsE,SAAS,CAACE,MAAM;AACtBvE,EAAAA,WAAW,EAAEqE,SAAS,CAACG,KAAK,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACzDlB,EAAAA,QAAQ,EAAEe,SAAS,CAACI,SAAS,CAAC,CAC1BJ,SAAS,CAACC,IAAI,EACdD,SAAS,CAACK,MAAM,EAChBL,SAAS,CAACE,MAAM,CACnB,CAAC;EACFtE,0BAA0B,EAAEoE,SAAS,CAACM,IAAI;AAC1CnB,EAAAA,OAAO,EAAEa,SAAS,CAACI,SAAS,CAAC,CACzBJ,SAAS,CAACC,IAAI,EACdD,SAAS,CAACK,MAAM,EAChBL,SAAS,CAACE,MAAM,CACnB,CAAC;EACFjE,OAAO,EAAE+D,SAAS,CAACC,IAAI;EACvBpE,qBAAqB,EAAEmE,SAAS,CAACM,IAAI;AACrCxE,EAAAA,GAAG,EAAEkE,SAAS,CAACE,MAAM,CAACK,UAAU;EAChCxE,KAAK,EAAEiE,SAAS,CAACE,MAAM;EACvBlE,eAAe,EAAEgE,SAAS,CAACM,IAAI;EAC/BlE,OAAO,EAAE4D,SAAS,CAACG,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC;AACnD,CAAC,CAAA;;;;"}
@@ -445,9 +445,9 @@
445
445
  });
446
446
  };
447
447
 
448
- var idCounter = 0;
448
+ var idCounter$1 = 0;
449
449
  var uniqueId = function () {
450
- return ++idCounter;
450
+ return ++idCounter$1;
451
451
  };
452
452
 
453
453
  var injectedElements = [];
@@ -731,6 +731,11 @@
731
731
  var _excluded = ["afterInjection", "beforeInjection", "desc", "evalScripts", "fallback", "httpRequestWithCredentials", "loading", "renumerateIRIElements", "src", "title", "useRequestCache", "wrapper"];
732
732
  var svgNamespace = 'http://www.w3.org/2000/svg';
733
733
  var xlinkNamespace = 'http://www.w3.org/1999/xlink';
734
+ // Random prefix avoids ID collisions when multiple copies of react-svg are
735
+ // bundled (e.g. microfrontends). The counter ensures each component instance
736
+ // within the same bundle gets a unique ID.
737
+ var idPrefix = "react-svg-" + Math.random().toString(36).slice(2, 6);
738
+ var idCounter = 0;
734
739
  var ReactSVG = /*#__PURE__*/function (_React$Component) {
735
740
  function ReactSVG() {
736
741
  var _this;
@@ -819,25 +824,52 @@
819
824
  });
820
825
  }
821
826
  };
827
+ // WAI best practice: SVGs need role="img" plus aria-labelledby/
828
+ // aria-describedby pointing to <title>/<desc> element IDs for screen
829
+ // readers to announce them. svg-injector copies the HTML title
830
+ // *attribute* (tooltip) but doesn't create SVG-namespace child
831
+ // elements or ARIA linkage, so we handle that here.
822
832
  var beforeEach = function beforeEach(svg) {
823
833
  svg.setAttribute('role', 'img');
824
- if (desc) {
825
- var originalDesc = svg.querySelector(':scope > desc');
826
- if (originalDesc) {
827
- svg.removeChild(originalDesc);
828
- }
829
- var newDesc = document.createElement('desc');
830
- newDesc.innerHTML = desc;
831
- svg.prepend(newDesc);
832
- }
834
+ var ariaLabelledBy = [];
835
+ var ariaDescribedBy = [];
833
836
  if (title) {
834
837
  var originalTitle = svg.querySelector(':scope > title');
835
838
  if (originalTitle) {
836
839
  svg.removeChild(originalTitle);
837
840
  }
838
- var newTitle = document.createElement('title');
839
- newTitle.innerHTML = title;
841
+ var titleId = idPrefix + "-title-" + ++idCounter;
842
+ // createElementNS is required: createElement would produce an
843
+ // HTML-namespace node that screen readers ignore inside SVG.
844
+ var newTitle = document.createElementNS(svgNamespace, 'title');
845
+ newTitle.id = titleId;
846
+ newTitle.textContent = title;
840
847
  svg.prepend(newTitle);
848
+ ariaLabelledBy.push(titleId);
849
+ }
850
+ if (desc) {
851
+ var originalDesc = svg.querySelector(':scope > desc');
852
+ if (originalDesc) {
853
+ svg.removeChild(originalDesc);
854
+ }
855
+ var descId = idPrefix + "-desc-" + ++idCounter;
856
+ var newDesc = document.createElementNS(svgNamespace, 'desc');
857
+ newDesc.id = descId;
858
+ newDesc.textContent = desc;
859
+ // Insert after <title> if present, otherwise prepend.
860
+ var existingTitle = svg.querySelector(':scope > title');
861
+ if (existingTitle) {
862
+ existingTitle.after(newDesc);
863
+ } else {
864
+ svg.prepend(newDesc);
865
+ }
866
+ ariaDescribedBy.push(descId);
867
+ }
868
+ if (ariaLabelledBy.length > 0) {
869
+ svg.setAttribute('aria-labelledby', ariaLabelledBy.join(' '));
870
+ }
871
+ if (ariaDescribedBy.length > 0) {
872
+ svg.setAttribute('aria-describedby', ariaDescribedBy.join(' '));
841
873
  }
842
874
  try {
843
875
  beforeInjection(svg);