@snack-uikit/icons 0.26.4 → 0.26.5-preview-76bcef09.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.
@@ -1,5 +1,6 @@
1
- declare function SpriteInner({ content }: {
1
+ type SpriteProps = {
2
2
  content: string;
3
- }): null;
4
- export declare const Sprite: import("react").MemoExoticComponent<typeof SpriteInner>;
3
+ 'data-test-id'?: string;
4
+ };
5
+ export declare const Sprite: import("react").NamedExoticComponent<SpriteProps>;
5
6
  export {};
@@ -4,34 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Sprite = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
8
  const react_1 = require("react");
8
9
  const utils_1 = require("@snack-uikit/utils");
9
- function SpriteInner(_ref) {
10
- let {
11
- content
12
- } = _ref;
13
- const [div] = (0, react_1.useState)((0, utils_1.isBrowser)() ? document.createElement('div') : undefined);
14
- if ((0, utils_1.isBrowser)() && div && div.parentNode !== document.body) {
15
- div.style.display = 'none';
16
- div.innerHTML = content;
17
- document.body.prepend(div);
10
+ exports.Sprite = (0, react_1.memo)(function Sprite(props) {
11
+ if (!(0, utils_1.isBrowser)()) {
12
+ return null;
18
13
  }
19
- (0, utils_1.useLayoutEffect)(() => {
20
- if (div) {
21
- return () => {
22
- document.body.removeChild(div);
23
- };
14
+ return (0, jsx_runtime_1.jsx)("div", {
15
+ "data-test-id": props['data-test-id'],
16
+ style: {
17
+ display: 'none'
18
+ },
19
+ dangerouslySetInnerHTML: {
20
+ __html: props.content
24
21
  }
25
- }, [div]);
26
- (0, utils_1.useLayoutEffect)(() => {
27
- if (div) {
28
- if (div.parentNode !== document.body) {
29
- div.style.display = 'none';
30
- document.body.prepend(div);
31
- }
32
- div.innerHTML = content;
33
- }
34
- }, [content, div]);
35
- return null;
36
- }
37
- exports.Sprite = (0, react_1.memo)(SpriteInner);
22
+ });
23
+ });
@@ -1,5 +1,6 @@
1
- declare function SpriteInner({ content }: {
1
+ type SpriteProps = {
2
2
  content: string;
3
- }): null;
4
- export declare const Sprite: import("react").MemoExoticComponent<typeof SpriteInner>;
3
+ 'data-test-id'?: string;
4
+ };
5
+ export declare const Sprite: import("react").NamedExoticComponent<SpriteProps>;
5
6
  export {};
@@ -1,28 +1,9 @@
1
- import { memo, useState } from 'react';
2
- import { isBrowser, useLayoutEffect } from '@snack-uikit/utils';
3
- function SpriteInner({ content }) {
4
- const [div] = useState(isBrowser() ? document.createElement('div') : undefined);
5
- if (isBrowser() && div && div.parentNode !== document.body) {
6
- div.style.display = 'none';
7
- div.innerHTML = content;
8
- document.body.prepend(div);
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { isBrowser } from '@snack-uikit/utils';
4
+ export const Sprite = memo(function Sprite(props) {
5
+ if (!isBrowser()) {
6
+ return null;
9
7
  }
10
- useLayoutEffect(() => {
11
- if (div) {
12
- return () => {
13
- document.body.removeChild(div);
14
- };
15
- }
16
- }, [div]);
17
- useLayoutEffect(() => {
18
- if (div) {
19
- if (div.parentNode !== document.body) {
20
- div.style.display = 'none';
21
- document.body.prepend(div);
22
- }
23
- div.innerHTML = content;
24
- }
25
- }, [content, div]);
26
- return null;
27
- }
28
- export const Sprite = memo(SpriteInner);
8
+ return (_jsx("div", { "data-test-id": props['data-test-id'], style: { display: 'none' }, dangerouslySetInnerHTML: { __html: props.content } }));
9
+ });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Icons",
7
- "version": "0.26.4",
7
+ "version": "0.26.5-preview-76bcef09.0",
8
8
  "sideEffects": [
9
9
  "*.svg",
10
10
  "*.css",
@@ -56,5 +56,5 @@
56
56
  "svg-sprite": "2.0.2",
57
57
  "svgo": "3.1.0"
58
58
  },
59
- "gitHead": "32ca67614118aeb02c9e69b8d4491f76cf5fe282"
59
+ "gitHead": "f319535e21d641f07f7f7f20ae249d94b7586544"
60
60
  }
package/src/Sprite.tsx CHANGED
@@ -1,36 +1,22 @@
1
- import { memo, useState } from 'react';
1
+ import { memo } from 'react';
2
2
 
3
- import { isBrowser, useLayoutEffect } from '@snack-uikit/utils';
3
+ import { isBrowser } from '@snack-uikit/utils';
4
4
 
5
- function SpriteInner({ content }: { content: string }) {
6
- const [div] = useState(isBrowser() ? document.createElement('div') : undefined);
5
+ type SpriteProps = {
6
+ content: string;
7
+ 'data-test-id'?: string;
8
+ };
7
9
 
8
- if (isBrowser() && div && div.parentNode !== document.body) {
9
- div.style.display = 'none';
10
- div.innerHTML = content;
11
- document.body.prepend(div);
10
+ export const Sprite = memo(function Sprite(props: SpriteProps) {
11
+ if (!isBrowser()) {
12
+ return null;
12
13
  }
13
14
 
14
- useLayoutEffect(() => {
15
- if (div) {
16
- return () => {
17
- document.body.removeChild(div);
18
- };
19
- }
20
- }, [div]);
21
-
22
- useLayoutEffect(() => {
23
- if (div) {
24
- if (div.parentNode !== document.body) {
25
- div.style.display = 'none';
26
- document.body.prepend(div);
27
- }
28
-
29
- div.innerHTML = content;
30
- }
31
- }, [content, div]);
32
-
33
- return null;
34
- }
35
-
36
- export const Sprite = memo(SpriteInner);
15
+ return (
16
+ <div
17
+ data-test-id={props['data-test-id']}
18
+ style={{ display: 'none' }}
19
+ dangerouslySetInnerHTML={{ __html: props.content }}
20
+ />
21
+ );
22
+ });