@stokr/components-library 3.0.37 → 3.0.38

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,9 +1,12 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import "react";
2
+ import DOMPurify from "dompurify";
3
3
  import PropTypes from "prop-types";
4
+ import { useId } from "react";
5
+ import parse from "html-react-parser";
4
6
  import { Tooltip } from "react-tippy";
5
- import { Container, Icon } from "./InfoIcon.styles.js";
7
+ import { colors } from "../../styles/colors.js";
6
8
  import { IoniconsStyles } from "../../styles/ioniconsStyles.js";
9
+ import { Container, ArrowColorGlobalStyle, Icon } from "./InfoIcon.styles.js";
7
10
  const InfoIcon = ({
8
11
  title = null,
9
12
  html = null,
@@ -14,13 +17,20 @@ const InfoIcon = ({
14
17
  noIcon,
15
18
  disabled,
16
19
  fullWidth,
20
+ arrow = true,
21
+ arrowColor = colors.blue,
22
+ theme = "light",
23
+ trigger,
17
24
  outline = false,
18
25
  containerStyle,
19
26
  ...props
20
27
  }) => {
28
+ const htmlContent = typeof html === "string" ? parse(DOMPurify.sanitize(html)) : html;
29
+ const instanceToken = `info-${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
30
+ const tippyTheme = arrowColor ? `${theme} ${instanceToken}` : theme;
21
31
  return /* @__PURE__ */ jsxs(Fragment, { children: [
22
32
  /* @__PURE__ */ jsx(IoniconsStyles, {}),
23
- /* @__PURE__ */ jsx(
33
+ /* @__PURE__ */ jsxs(
24
34
  Container,
25
35
  {
26
36
  noMargin,
@@ -28,20 +38,25 @@ const InfoIcon = ({
28
38
  noMarginRight,
29
39
  fullWidth,
30
40
  style: containerStyle,
31
- children: /* @__PURE__ */ jsx(
32
- Tooltip,
33
- {
34
- ...props,
35
- position,
36
- title,
37
- html,
38
- theme: "light",
39
- arrow: true,
40
- duration: 200,
41
- disabled,
42
- children: noIcon ? props.children : /* @__PURE__ */ jsx(Icon, { outline })
43
- }
44
- )
41
+ children: [
42
+ arrowColor && /* @__PURE__ */ jsx(ArrowColorGlobalStyle, { themeName: instanceToken, color: arrowColor }),
43
+ /* @__PURE__ */ jsx(
44
+ Tooltip,
45
+ {
46
+ ...props,
47
+ position,
48
+ title,
49
+ trigger,
50
+ html: htmlContent,
51
+ useContext: htmlContent != null,
52
+ theme: tippyTheme,
53
+ arrow: arrowColor ? true : arrow,
54
+ duration: 200,
55
+ disabled,
56
+ children: noIcon ? props.children : /* @__PURE__ */ jsx(Icon, { outline })
57
+ }
58
+ )
59
+ ]
45
60
  }
46
61
  )
47
62
  ] });
@@ -53,7 +68,12 @@ InfoIcon.propTypes = {
53
68
  noMargin: PropTypes.bool,
54
69
  noMarginLeft: PropTypes.bool,
55
70
  noMarginRight: PropTypes.bool,
56
- outline: PropTypes.bool
71
+ outline: PropTypes.bool,
72
+ children: PropTypes.node,
73
+ theme: PropTypes.string,
74
+ trigger: PropTypes.oneOf(["click", "focus"]),
75
+ arrow: PropTypes.bool,
76
+ arrowColor: PropTypes.string
57
77
  };
58
78
  export {
59
79
  InfoIcon,
@@ -1,5 +1,19 @@
1
- import styled from "styled-components";
1
+ import styled, { createGlobalStyle } from "styled-components";
2
2
  import theme from "../../styles/theme.js";
3
+ const ArrowColorGlobalStyle = createGlobalStyle`
4
+ .tippy-popper[x-placement^='top'] .tippy-tooltip.${(props) => props.themeName}-theme [x-arrow] {
5
+ border-top-color: ${(props) => props.color} !important;
6
+ }
7
+ .tippy-popper[x-placement^='bottom'] .tippy-tooltip.${(props) => props.themeName}-theme [x-arrow] {
8
+ border-bottom-color: ${(props) => props.color} !important;
9
+ }
10
+ .tippy-popper[x-placement^='left'] .tippy-tooltip.${(props) => props.themeName}-theme [x-arrow] {
11
+ border-left-color: ${(props) => props.color} !important;
12
+ }
13
+ .tippy-popper[x-placement^='right'] .tippy-tooltip.${(props) => props.themeName}-theme [x-arrow] {
14
+ border-right-color: ${(props) => props.color} !important;
15
+ }
16
+ `;
3
17
  const Container = styled.div.withConfig({
4
18
  shouldForwardProp: (props) => !["noMargin", "noMarginLeft", "noMarginRight", "fullWidth"].includes(props)
5
19
  })`
@@ -59,6 +73,7 @@ const Icon = styled.i.withConfig({
59
73
  }
60
74
  `;
61
75
  export {
76
+ ArrowColorGlobalStyle,
62
77
  Container,
63
78
  Icon
64
79
  };
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="90" height="87">
2
+ <g fill="none" stroke="#9b9b9b" strokeMiterlimit="10" strokeWidth="4">
3
+ <path data-name="Stroke 1" d="M17.176 74.939a32.212 32.212 0 0 1 29.087-17.606 32.217 32.217 0 0 1 29.09 17.606" />
4
+ <path data-name="Stroke 3" d="M88 43.5C88 66.42 68.751 85 45 85S2 66.42 2 43.5 21.249 2 45 2s43 18.58 43 41.5z" />
5
+ <path data-name="Stroke 5" d="M57.647 32.182a12.647 12.647 0 1 1-12.645-12.576" />
6
+ </g>
7
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "3.0.37",
3
+ "version": "3.0.38",
4
4
  "description": "STOKR - Components Library",
5
5
  "author": "Bilal Hodzic <bilal@stokr.io>",
6
6
  "license": "MIT",