@snack-uikit/icons 0.26.4 → 0.26.5-preview-b8beb2db.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,16 @@ 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
- 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);
18
- }
19
- (0, utils_1.useLayoutEffect)(() => {
20
- if (div) {
21
- return () => {
22
- document.body.removeChild(div);
23
- };
9
+ exports.Sprite = (0, react_1.memo)(function Sprite(props) {
10
+ return (0, jsx_runtime_1.jsx)("div", {
11
+ "data-test-id": props['data-test-id'],
12
+ style: {
13
+ display: 'none'
14
+ },
15
+ dangerouslySetInnerHTML: {
16
+ __html: props.content
24
17
  }
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);
18
+ });
19
+ });
@@ -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,5 @@
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);
9
- }
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);
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ export const Sprite = memo(function Sprite(props) {
4
+ return (_jsx("div", { "data-test-id": props['data-test-id'], style: { display: 'none' }, dangerouslySetInnerHTML: { __html: props.content } }));
5
+ });
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-b8beb2db.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": "a9dd04b575451d7955fd4cdcf5bf3a116501f244"
60
60
  }
package/src/Sprite.tsx CHANGED
@@ -1,36 +1,16 @@
1
- import { memo, useState } from 'react';
2
-
3
- import { isBrowser, useLayoutEffect } from '@snack-uikit/utils';
4
-
5
- function SpriteInner({ content }: { content: string }) {
6
- const [div] = useState(isBrowser() ? document.createElement('div') : undefined);
7
-
8
- if (isBrowser() && div && div.parentNode !== document.body) {
9
- div.style.display = 'none';
10
- div.innerHTML = content;
11
- document.body.prepend(div);
12
- }
13
-
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);
1
+ import { memo } from 'react';
2
+
3
+ type SpriteProps = {
4
+ content: string;
5
+ 'data-test-id'?: string;
6
+ };
7
+
8
+ export const Sprite = memo(function Sprite(props: SpriteProps) {
9
+ return (
10
+ <div
11
+ data-test-id={props['data-test-id']}
12
+ style={{ display: 'none' }}
13
+ dangerouslySetInnerHTML={{ __html: props.content }}
14
+ />
15
+ );
16
+ });