@gustavo-valsechi/client 1.4.316 → 1.4.318

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.
@@ -44,7 +44,8 @@ const Container = import_styled_components.default.div`
44
44
  bottom: 0;
45
45
  left: 0;
46
46
  background: ${({ initialization, theme }) => initialization ? `${theme.maingrad}, ${theme.primary}` : "transparent"};
47
- z-index: ${({ initialization }) => initialization ? "9" : "0"};
47
+ z-index: ${({ initialization }) => initialization ? "9" : "1"};
48
+ pointer-events: none;
48
49
 
49
50
  .loading-logo {
50
51
  font-size: 4rem;
@@ -11,7 +11,8 @@ const Container = styled.div`
11
11
  bottom: 0;
12
12
  left: 0;
13
13
  background: ${({ initialization, theme }) => initialization ? `${theme.maingrad}, ${theme.primary}` : "transparent"};
14
- z-index: ${({ initialization }) => initialization ? "9" : "0"};
14
+ z-index: ${({ initialization }) => initialization ? "9" : "1"};
15
+ pointer-events: none;
15
16
 
16
17
  .loading-logo {
17
18
  font-size: 4rem;
@@ -129,7 +129,7 @@ function Table(props) {
129
129
  {
130
130
  className: "table-content-elipse",
131
131
  "data-tooltip": import_lodash.default.isString(body) && !row.info ? body : "",
132
- "data-tooltip-props": '{"position":"bottom"}',
132
+ "data-tooltip-props": '{"position":"bottom","align":"start"}',
133
133
  children: body
134
134
  }
135
135
  );
@@ -95,7 +95,7 @@ function Table(props) {
95
95
  {
96
96
  className: "table-content-elipse",
97
97
  "data-tooltip": _.isString(body) && !row.info ? body : "",
98
- "data-tooltip-props": '{"position":"bottom"}',
98
+ "data-tooltip-props": '{"position":"bottom","align":"start"}',
99
99
  children: body
100
100
  }
101
101
  );
@@ -34,44 +34,59 @@ __export(styles_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(styles_exports);
36
36
  var import_styled_components = __toESM(require("styled-components"));
37
- const setPosition = ({ position = "top", theme }, isBorder) => {
37
+ const setPosition = ({
38
+ position = "top",
39
+ align = "center",
40
+ noArrow = false,
41
+ theme
42
+ }, isBorder) => {
43
+ const arrow = noArrow ? "0px" : "8px";
38
44
  const coord = isBorder ? "9" : "8";
39
45
  const color = isBorder ? theme.t05 : theme.tooltip;
46
+ let alignment = "50%";
47
+ switch (align) {
48
+ case "end":
49
+ alignment = `calc(100% - ${arrow} - 5px)`;
50
+ break;
51
+ case "start":
52
+ alignment = `calc(${arrow} + 5px)`;
53
+ break;
54
+ }
40
55
  const defaultPosition = `
41
56
  transform: translateX(-50%);
42
57
  bottom: -${coord}px;
43
- left: 50%;
44
- border-left: 8px solid transparent;
45
- border-right: 8px solid transparent;
46
- border-top: 8px solid ${color};
58
+ left: ${alignment};
59
+ border-left: ${arrow} solid transparent;
60
+ border-right: ${arrow} solid transparent;
61
+ border-top: ${arrow} solid ${color};
47
62
  `;
48
63
  switch (position) {
49
64
  case "bottom":
50
65
  return `
51
66
  transform: translateX(-50%);
52
67
  top: -${coord}px;
53
- left: 50%;
54
- border-left: 8px solid transparent;
55
- border-right: 8px solid transparent;
56
- border-bottom: 8px solid ${color};
68
+ left: ${alignment};
69
+ border-left: ${arrow} solid transparent;
70
+ border-right: ${arrow} solid transparent;
71
+ border-bottom: ${arrow} solid ${color};
57
72
  `;
58
73
  case "left":
59
74
  return `
60
75
  transform: translateY(-50%);
61
76
  right: -${coord}px;
62
- top: 50%;
63
- border-top: 8px solid transparent;
64
- border-bottom: 8px solid transparent;
65
- border-left: 8px solid ${color};
77
+ top: ${alignment};
78
+ border-top: ${arrow} solid transparent;
79
+ border-bottom: ${arrow} solid transparent;
80
+ border-left: ${arrow} solid ${color};
66
81
  `;
67
82
  case "right":
68
83
  return `
69
84
  transform: translateY(-50%);
70
85
  left: -${coord}px;
71
- top: 50%;
72
- border-top: 8px solid transparent;
73
- border-bottom: 8px solid transparent;
74
- border-right: 8px solid ${color};
86
+ top: ${alignment};
87
+ border-top: ${arrow} solid transparent;
88
+ border-bottom: ${arrow} solid transparent;
89
+ border-right: ${arrow} solid ${color};
75
90
  `;
76
91
  case "top":
77
92
  return defaultPosition;
@@ -90,21 +105,6 @@ const Container = import_styled_components.default.div`
90
105
  border-radius: 5px;
91
106
  z-index: 10;
92
107
  border: 1px solid ${({ theme }) => theme.t05};
93
- transform: ${({ position = "top" }) => {
94
- const defaultPosition = "translateX(-50%)";
95
- switch (position) {
96
- case "left":
97
- return "translateX(0)";
98
- case "right":
99
- return "translateX(-100%)";
100
- case "bottom":
101
- return defaultPosition;
102
- case "top":
103
- return defaultPosition;
104
- default:
105
- return defaultPosition;
106
- }
107
- }};
108
108
 
109
109
  @media(max-width: ${({ theme }) => theme.mobileMaxWidth}) {
110
110
  display: none;
@@ -1,44 +1,59 @@
1
1
  "use client";
2
2
  "use client";
3
3
  import styled from "styled-components";
4
- const setPosition = ({ position = "top", theme }, isBorder) => {
4
+ const setPosition = ({
5
+ position = "top",
6
+ align = "center",
7
+ noArrow = false,
8
+ theme
9
+ }, isBorder) => {
10
+ const arrow = noArrow ? "0px" : "8px";
5
11
  const coord = isBorder ? "9" : "8";
6
12
  const color = isBorder ? theme.t05 : theme.tooltip;
13
+ let alignment = "50%";
14
+ switch (align) {
15
+ case "end":
16
+ alignment = `calc(100% - ${arrow} - 5px)`;
17
+ break;
18
+ case "start":
19
+ alignment = `calc(${arrow} + 5px)`;
20
+ break;
21
+ }
7
22
  const defaultPosition = `
8
23
  transform: translateX(-50%);
9
24
  bottom: -${coord}px;
10
- left: 50%;
11
- border-left: 8px solid transparent;
12
- border-right: 8px solid transparent;
13
- border-top: 8px solid ${color};
25
+ left: ${alignment};
26
+ border-left: ${arrow} solid transparent;
27
+ border-right: ${arrow} solid transparent;
28
+ border-top: ${arrow} solid ${color};
14
29
  `;
15
30
  switch (position) {
16
31
  case "bottom":
17
32
  return `
18
33
  transform: translateX(-50%);
19
34
  top: -${coord}px;
20
- left: 50%;
21
- border-left: 8px solid transparent;
22
- border-right: 8px solid transparent;
23
- border-bottom: 8px solid ${color};
35
+ left: ${alignment};
36
+ border-left: ${arrow} solid transparent;
37
+ border-right: ${arrow} solid transparent;
38
+ border-bottom: ${arrow} solid ${color};
24
39
  `;
25
40
  case "left":
26
41
  return `
27
42
  transform: translateY(-50%);
28
43
  right: -${coord}px;
29
- top: 50%;
30
- border-top: 8px solid transparent;
31
- border-bottom: 8px solid transparent;
32
- border-left: 8px solid ${color};
44
+ top: ${alignment};
45
+ border-top: ${arrow} solid transparent;
46
+ border-bottom: ${arrow} solid transparent;
47
+ border-left: ${arrow} solid ${color};
33
48
  `;
34
49
  case "right":
35
50
  return `
36
51
  transform: translateY(-50%);
37
52
  left: -${coord}px;
38
- top: 50%;
39
- border-top: 8px solid transparent;
40
- border-bottom: 8px solid transparent;
41
- border-right: 8px solid ${color};
53
+ top: ${alignment};
54
+ border-top: ${arrow} solid transparent;
55
+ border-bottom: ${arrow} solid transparent;
56
+ border-right: ${arrow} solid ${color};
42
57
  `;
43
58
  case "top":
44
59
  return defaultPosition;
@@ -57,21 +72,6 @@ const Container = styled.div`
57
72
  border-radius: 5px;
58
73
  z-index: 10;
59
74
  border: 1px solid ${({ theme }) => theme.t05};
60
- transform: ${({ position = "top" }) => {
61
- const defaultPosition = "translateX(-50%)";
62
- switch (position) {
63
- case "left":
64
- return "translateX(0)";
65
- case "right":
66
- return "translateX(-100%)";
67
- case "bottom":
68
- return defaultPosition;
69
- case "top":
70
- return defaultPosition;
71
- default:
72
- return defaultPosition;
73
- }
74
- }};
75
75
 
76
76
  @media(max-width: ${({ theme }) => theme.mobileMaxWidth}) {
77
77
  display: none;
@@ -40,7 +40,6 @@ var import_styles = require("./styles");
40
40
  var import_theme = require("../theme");
41
41
  var import_react_dom = require("react-dom");
42
42
  var import_events = require("./events");
43
- var import_navigation = require("next/navigation");
44
43
  var import_lodash = __toESM(require("lodash"));
45
44
  var import_modal = __toESM(require("./modal"));
46
45
  const TargetContext = (0, import_react.createContext)({});
@@ -50,7 +49,6 @@ const TargetProviderContainer = ({ children }) => {
50
49
  const inputRef = (0, import_react.useRef)([]);
51
50
  const containerRef = (0, import_react.useRef)([]);
52
51
  const theme = (0, import_theme.useTheme)();
53
- const pathname = (0, import_navigation.usePathname)();
54
52
  const [targets, setTargets] = (0, import_react.useState)([]);
55
53
  const [modal, setModal] = (0, import_react.useState)(-1);
56
54
  (0, import_react.useEffect)(() => {
@@ -72,18 +70,17 @@ const TargetProviderContainer = ({ children }) => {
72
70
  });
73
71
  }, [targets, inputRef, containerRef, theme.content.isMobile]);
74
72
  (0, import_react.useEffect)(() => {
75
- const removeTarget = (node) => {
76
- if (!(node instanceof HTMLElement)) return;
77
- memory = import_lodash.default.filter(memory, (target) => !!target.ref.current);
78
- insideMemory = [];
79
- setTargets([...memory]);
80
- };
81
73
  const observer = new MutationObserver((mutations) => {
82
74
  for (const mutation of mutations) {
83
- mutation.removedNodes.forEach(removeTarget);
75
+ mutation.removedNodes.forEach((node) => {
76
+ if (!(node instanceof HTMLElement)) return;
77
+ memory = import_lodash.default.filter(memory, (target) => !!target.ref.current);
78
+ insideMemory = [];
79
+ setTargets([...memory]);
80
+ });
84
81
  }
85
82
  });
86
- observer.observe(document.getElementById("modal-context-container"), { childList: true, subtree: true });
83
+ observer.observe(document.body, { childList: true, subtree: true });
87
84
  return () => observer.disconnect();
88
85
  }, []);
89
86
  const getCoords = (target, component) => {
@@ -6,7 +6,6 @@ import { Container } from "./styles";
6
6
  import { useTheme } from "../theme";
7
7
  import { createPortal } from "react-dom";
8
8
  import { onScroll, onBlur, onFocus, onClick } from "./events";
9
- import { usePathname } from "next/navigation";
10
9
  import _ from "lodash";
11
10
  import Modal from "./modal";
12
11
  const TargetContext = createContext({});
@@ -16,7 +15,6 @@ const TargetProviderContainer = ({ children }) => {
16
15
  const inputRef = useRef([]);
17
16
  const containerRef = useRef([]);
18
17
  const theme = useTheme();
19
- const pathname = usePathname();
20
18
  const [targets, setTargets] = useState([]);
21
19
  const [modal, setModal] = useState(-1);
22
20
  useEffect(() => {
@@ -38,18 +36,17 @@ const TargetProviderContainer = ({ children }) => {
38
36
  });
39
37
  }, [targets, inputRef, containerRef, theme.content.isMobile]);
40
38
  useEffect(() => {
41
- const removeTarget = (node) => {
42
- if (!(node instanceof HTMLElement)) return;
43
- memory = _.filter(memory, (target) => !!target.ref.current);
44
- insideMemory = [];
45
- setTargets([...memory]);
46
- };
47
39
  const observer = new MutationObserver((mutations) => {
48
40
  for (const mutation of mutations) {
49
- mutation.removedNodes.forEach(removeTarget);
41
+ mutation.removedNodes.forEach((node) => {
42
+ if (!(node instanceof HTMLElement)) return;
43
+ memory = _.filter(memory, (target) => !!target.ref.current);
44
+ insideMemory = [];
45
+ setTargets([...memory]);
46
+ });
50
47
  }
51
48
  });
52
- observer.observe(document.getElementById("modal-context-container"), { childList: true, subtree: true });
49
+ observer.observe(document.body, { childList: true, subtree: true });
53
50
  return () => observer.disconnect();
54
51
  }, []);
55
52
  const getCoords = (target, component) => {
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(tooltip_exports);
37
37
  var import_jsx_runtime = require("react/jsx-runtime");
38
38
  var import_react = require("react");
39
39
  var import_components = require("../../components");
40
+ var import_styles = require("./styles");
40
41
  var import_lodash = __toESM(require("lodash"));
41
42
  const TooltipContext = (0, import_react.createContext)({});
42
43
  const TooltipProviderContainer = ({ children }) => {
@@ -47,26 +48,54 @@ const TooltipProviderContainer = ({ children }) => {
47
48
  const props = JSON.parse(((_a = target.dataset) == null ? void 0 : _a.tooltipProps) || "{}");
48
49
  const targetTop = rect.top + window.scrollY;
49
50
  const targetLeft = rect.left + window.scrollX;
50
- const coords = {
51
- top: targetTop - (target.offsetHeight + 8),
52
- left: targetLeft + target.offsetWidth / 2
51
+ const arrowSize = props.noArrow ? 0 : 8;
52
+ const style = {
53
+ top: targetTop - (target.offsetHeight + arrowSize),
54
+ left: targetLeft + target.offsetWidth / 2,
55
+ transform: "translateX(-50%)"
56
+ };
57
+ switch (props.align) {
58
+ case "start":
59
+ style.left = targetLeft;
60
+ style.transform = "translateX(0)";
61
+ break;
62
+ case "end":
63
+ style.left = targetLeft + target.offsetWidth;
64
+ style.transform = "translateX(-100%)";
65
+ break;
66
+ }
67
+ const verticalAlign = (params) => {
68
+ switch (props.align) {
69
+ case "start":
70
+ params.top = targetTop;
71
+ params.transform = props.position === "left" ? "translateX(-100%) translateY(0)" : "translateY(0)";
72
+ break;
73
+ case "end":
74
+ params.top = targetTop + target.offsetHeight;
75
+ params.transform = props.position === "left" ? "translateX(-100%) translateY(-100%)" : "translateY(-100%)";
76
+ break;
77
+ }
53
78
  };
54
79
  switch (props.position) {
55
80
  case "bottom":
56
- coords.top = targetTop + (target.offsetHeight + 8);
81
+ style.top = targetTop + (target.offsetHeight + arrowSize);
57
82
  break;
58
83
  case "left":
59
- coords.top = targetTop;
60
- coords.left = targetLeft - target.offsetWidth;
84
+ style.top = targetTop + target.offsetHeight / 2;
85
+ style.left = targetLeft - arrowSize;
86
+ style.transform = "translateX(-100%) translateY(-50%)";
87
+ verticalAlign(style);
61
88
  break;
62
89
  case "right":
63
- coords.top = targetTop;
64
- coords.left = targetLeft + target.offsetWidth;
90
+ style.top = targetTop + target.offsetHeight / 2;
91
+ style.left = targetLeft + target.offsetWidth + arrowSize;
92
+ style.transform = "translateX(0) translateY(-50%)";
93
+ verticalAlign(style);
65
94
  break;
66
95
  }
67
96
  return {
68
- ...coords,
69
97
  content: ((_b = target.dataset) == null ? void 0 : _b.tooltip) || "",
98
+ style,
70
99
  props
71
100
  };
72
101
  };
@@ -109,21 +138,18 @@ const TooltipProviderContainer = ({ children }) => {
109
138
  return () => observer.disconnect();
110
139
  }, []);
111
140
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TooltipContext.Provider, { value: {}, children: [
112
- import_lodash.default.map(
141
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Container, { id: "tooltip-context-container", children: import_lodash.default.map(
113
142
  tooltips,
114
143
  (data, index) => !!data.content && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
115
144
  import_components.Tooltip,
116
145
  {
117
- style: {
118
- top: data.top,
119
- left: data.left
120
- },
146
+ style: data.style,
121
147
  ...data.props,
122
148
  children: data.content
123
149
  },
124
150
  index
125
151
  )
126
- ),
152
+ ) }),
127
153
  children
128
154
  ] });
129
155
  };
@@ -3,6 +3,7 @@
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { createContext, useContext, useEffect, useState } from "react";
5
5
  import { Tooltip } from "../../components";
6
+ import { Container } from "./styles";
6
7
  import _ from "lodash";
7
8
  const TooltipContext = createContext({});
8
9
  const TooltipProviderContainer = ({ children }) => {
@@ -13,26 +14,54 @@ const TooltipProviderContainer = ({ children }) => {
13
14
  const props = JSON.parse(((_a = target.dataset) == null ? void 0 : _a.tooltipProps) || "{}");
14
15
  const targetTop = rect.top + window.scrollY;
15
16
  const targetLeft = rect.left + window.scrollX;
16
- const coords = {
17
- top: targetTop - (target.offsetHeight + 8),
18
- left: targetLeft + target.offsetWidth / 2
17
+ const arrowSize = props.noArrow ? 0 : 8;
18
+ const style = {
19
+ top: targetTop - (target.offsetHeight + arrowSize),
20
+ left: targetLeft + target.offsetWidth / 2,
21
+ transform: "translateX(-50%)"
22
+ };
23
+ switch (props.align) {
24
+ case "start":
25
+ style.left = targetLeft;
26
+ style.transform = "translateX(0)";
27
+ break;
28
+ case "end":
29
+ style.left = targetLeft + target.offsetWidth;
30
+ style.transform = "translateX(-100%)";
31
+ break;
32
+ }
33
+ const verticalAlign = (params) => {
34
+ switch (props.align) {
35
+ case "start":
36
+ params.top = targetTop;
37
+ params.transform = props.position === "left" ? "translateX(-100%) translateY(0)" : "translateY(0)";
38
+ break;
39
+ case "end":
40
+ params.top = targetTop + target.offsetHeight;
41
+ params.transform = props.position === "left" ? "translateX(-100%) translateY(-100%)" : "translateY(-100%)";
42
+ break;
43
+ }
19
44
  };
20
45
  switch (props.position) {
21
46
  case "bottom":
22
- coords.top = targetTop + (target.offsetHeight + 8);
47
+ style.top = targetTop + (target.offsetHeight + arrowSize);
23
48
  break;
24
49
  case "left":
25
- coords.top = targetTop;
26
- coords.left = targetLeft - target.offsetWidth;
50
+ style.top = targetTop + target.offsetHeight / 2;
51
+ style.left = targetLeft - arrowSize;
52
+ style.transform = "translateX(-100%) translateY(-50%)";
53
+ verticalAlign(style);
27
54
  break;
28
55
  case "right":
29
- coords.top = targetTop;
30
- coords.left = targetLeft + target.offsetWidth;
56
+ style.top = targetTop + target.offsetHeight / 2;
57
+ style.left = targetLeft + target.offsetWidth + arrowSize;
58
+ style.transform = "translateX(0) translateY(-50%)";
59
+ verticalAlign(style);
31
60
  break;
32
61
  }
33
62
  return {
34
- ...coords,
35
63
  content: ((_b = target.dataset) == null ? void 0 : _b.tooltip) || "",
64
+ style,
36
65
  props
37
66
  };
38
67
  };
@@ -75,21 +104,18 @@ const TooltipProviderContainer = ({ children }) => {
75
104
  return () => observer.disconnect();
76
105
  }, []);
77
106
  return /* @__PURE__ */ jsxs(TooltipContext.Provider, { value: {}, children: [
78
- _.map(
107
+ /* @__PURE__ */ jsx(Container, { id: "tooltip-context-container", children: _.map(
79
108
  tooltips,
80
109
  (data, index) => !!data.content && /* @__PURE__ */ jsx(
81
110
  Tooltip,
82
111
  {
83
- style: {
84
- top: data.top,
85
- left: data.left
86
- },
112
+ style: data.style,
87
113
  ...data.props,
88
114
  children: data.content
89
115
  },
90
116
  index
91
117
  )
92
- ),
118
+ ) }),
93
119
  children
94
120
  ] });
95
121
  };
@@ -0,0 +1 @@
1
+ export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ "use strict";
3
+ "use client";
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+ var styles_exports = {};
32
+ __export(styles_exports, {
33
+ Container: () => Container
34
+ });
35
+ module.exports = __toCommonJS(styles_exports);
36
+ var import_styled_components = __toESM(require("styled-components"));
37
+ const Container = import_styled_components.default.div`
38
+
39
+ `;
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ Container
43
+ });
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ "use client";
3
+ import styled from "styled-components";
4
+ const Container = styled.div`
5
+
6
+ `;
7
+ export {
8
+ Container
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.316",
3
+ "version": "1.4.318",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",