@gustavo-valsechi/client 1.4.16 → 1.4.18

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.
@@ -41,10 +41,9 @@ const TooltipContext = (0, import_react.createContext)({});
41
41
  const TooltipProviderContainer = ({ children }) => {
42
42
  const [tooltips, setTooltips] = (0, import_react.useState)([]);
43
43
  const getContent = (target) => {
44
- var _a, _b, _c;
44
+ var _a, _b;
45
45
  const rect = target.getBoundingClientRect();
46
- console.log(target.dataset);
47
- const props = JSON.parse(((_a = target.dataset) == null ? void 0 : _a["tooltip-props"]) || "{}");
46
+ const props = JSON.parse(((_a = target.dataset) == null ? void 0 : _a.tooltipProps) || "{}");
48
47
  const coords = {
49
48
  top: rect.top + window.scrollY - (target.offsetHeight + 8),
50
49
  left: rect.left + window.scrollX + target.offsetWidth / 2
@@ -65,7 +64,7 @@ const TooltipProviderContainer = ({ children }) => {
65
64
  return {
66
65
  ...coords,
67
66
  content: ((_b = target.dataset) == null ? void 0 : _b.tooltip) || "",
68
- props: JSON.parse(((_c = target.dataset) == null ? void 0 : _c["tooltip-props"]) || "{}")
67
+ props
69
68
  };
70
69
  };
71
70
  (0, import_react.useEffect)(() => {
@@ -7,10 +7,9 @@ const TooltipContext = createContext({});
7
7
  const TooltipProviderContainer = ({ children }) => {
8
8
  const [tooltips, setTooltips] = useState([]);
9
9
  const getContent = (target) => {
10
- var _a, _b, _c;
10
+ var _a, _b;
11
11
  const rect = target.getBoundingClientRect();
12
- console.log(target.dataset);
13
- const props = JSON.parse(((_a = target.dataset) == null ? void 0 : _a["tooltip-props"]) || "{}");
12
+ const props = JSON.parse(((_a = target.dataset) == null ? void 0 : _a.tooltipProps) || "{}");
14
13
  const coords = {
15
14
  top: rect.top + window.scrollY - (target.offsetHeight + 8),
16
15
  left: rect.left + window.scrollX + target.offsetWidth / 2
@@ -31,7 +30,7 @@ const TooltipProviderContainer = ({ children }) => {
31
30
  return {
32
31
  ...coords,
33
32
  content: ((_b = target.dataset) == null ? void 0 : _b.tooltip) || "",
34
- props: JSON.parse(((_c = target.dataset) == null ? void 0 : _c["tooltip-props"]) || "{}")
33
+ props
35
34
  };
36
35
  };
37
36
  useEffect(() => {
@@ -33,41 +33,43 @@ __export(styles_exports, {
33
33
  module.exports = __toCommonJS(styles_exports);
34
34
  var import_styled_components = __toESM(require("styled-components"));
35
35
  const setPosition = ({ position = "top", theme }, isBorder) => {
36
+ const coord = isBorder ? "9" : "8";
37
+ const color = isBorder ? theme.t05 : theme.tooltip;
36
38
  const defaultPosition = `
37
39
  transform: translateX(-50%);
38
- bottom: -${isBorder ? "9" : "8"}px;
40
+ bottom: -${coord}px;
39
41
  left: 50%;
40
42
  border-left: 8px solid transparent;
41
43
  border-right: 8px solid transparent;
42
- border-top: 8px solid ${theme.t05};
44
+ border-top: 8px solid ${color};
43
45
  `;
44
46
  switch (position) {
45
47
  case "bottom":
46
48
  return `
47
49
  transform: translateX(-50%);
48
- top: -${isBorder ? "9" : "8"}px;
50
+ top: -${coord}px;
49
51
  left: 50%;
50
52
  border-left: 8px solid transparent;
51
53
  border-right: 8px solid transparent;
52
- border-bottom: 8px solid ${theme.t05};
54
+ border-bottom: 8px solid ${color};
53
55
  `;
54
56
  case "left":
55
57
  return `
56
58
  transform: translateY(-50%);
57
- right: -${isBorder ? "9" : "8"}px;
59
+ right: -${coord}px;
58
60
  top: 50%;
59
61
  border-top: 8px solid transparent;
60
62
  border-bottom: 8px solid transparent;
61
- border-left: 8px solid ${theme.t05};
63
+ border-left: 8px solid ${color};
62
64
  `;
63
65
  case "right":
64
66
  return `
65
67
  transform: translateY(-50%);
66
- left: -${isBorder ? "9" : "8"}px;
68
+ left: -${coord}px;
67
69
  top: 50%;
68
70
  border-top: 8px solid transparent;
69
71
  border-bottom: 8px solid transparent;
70
- border-right: 8px solid ${theme.t05};
72
+ border-right: 8px solid ${color};
71
73
  `;
72
74
  case "top":
73
75
  return defaultPosition;
@@ -119,7 +121,7 @@ const Tooltip = import_styled_components.default.div`
119
121
  position: absolute;
120
122
  width: 0;
121
123
  height: 0;
122
- ${(props) => setPosition(props, true)}
124
+ ${(props) => setPosition(props)}
123
125
  }
124
126
  `;
125
127
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,40 +1,42 @@
1
1
  import styled from "styled-components";
2
2
  const setPosition = ({ position = "top", theme }, isBorder) => {
3
+ const coord = isBorder ? "9" : "8";
4
+ const color = isBorder ? theme.t05 : theme.tooltip;
3
5
  const defaultPosition = `
4
6
  transform: translateX(-50%);
5
- bottom: -${isBorder ? "9" : "8"}px;
7
+ bottom: -${coord}px;
6
8
  left: 50%;
7
9
  border-left: 8px solid transparent;
8
10
  border-right: 8px solid transparent;
9
- border-top: 8px solid ${theme.t05};
11
+ border-top: 8px solid ${color};
10
12
  `;
11
13
  switch (position) {
12
14
  case "bottom":
13
15
  return `
14
16
  transform: translateX(-50%);
15
- top: -${isBorder ? "9" : "8"}px;
17
+ top: -${coord}px;
16
18
  left: 50%;
17
19
  border-left: 8px solid transparent;
18
20
  border-right: 8px solid transparent;
19
- border-bottom: 8px solid ${theme.t05};
21
+ border-bottom: 8px solid ${color};
20
22
  `;
21
23
  case "left":
22
24
  return `
23
25
  transform: translateY(-50%);
24
- right: -${isBorder ? "9" : "8"}px;
26
+ right: -${coord}px;
25
27
  top: 50%;
26
28
  border-top: 8px solid transparent;
27
29
  border-bottom: 8px solid transparent;
28
- border-left: 8px solid ${theme.t05};
30
+ border-left: 8px solid ${color};
29
31
  `;
30
32
  case "right":
31
33
  return `
32
34
  transform: translateY(-50%);
33
- left: -${isBorder ? "9" : "8"}px;
35
+ left: -${coord}px;
34
36
  top: 50%;
35
37
  border-top: 8px solid transparent;
36
38
  border-bottom: 8px solid transparent;
37
- border-right: 8px solid ${theme.t05};
39
+ border-right: 8px solid ${color};
38
40
  `;
39
41
  case "top":
40
42
  return defaultPosition;
@@ -86,7 +88,7 @@ const Tooltip = styled.div`
86
88
  position: absolute;
87
89
  width: 0;
88
90
  height: 0;
89
- ${(props) => setPosition(props, true)}
91
+ ${(props) => setPosition(props)}
90
92
  }
91
93
  `;
92
94
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.16",
3
+ "version": "1.4.18",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",