@gustavo-valsechi/client 1.4.13 → 1.4.15

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,2 +1,2 @@
1
- export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
2
- export declare const RowContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
1
+ export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
2
+ export declare const RowContainer: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
@@ -1,2 +1,2 @@
1
1
  export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
2
- export declare const Content: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
2
+ export declare const Content: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
@@ -109,7 +109,7 @@ function Form(props) {
109
109
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { ref: formRef, onSubmit: handleSubmit(onSubmit), children: [
110
110
  import_lodash.default.map(
111
111
  props.inputs,
112
- (data, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.Fragment, { children: component(data) }, index)
112
+ (data, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.Fragment, { children: data.type === "custom" ? data.component : component(data) }, index)
113
113
  ),
114
114
  import_lodash.default.isArray(props.buttons) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "form-buttons", children: import_lodash.default.map(
115
115
  props.buttons,
@@ -75,7 +75,7 @@ function Form(props) {
75
75
  return /* @__PURE__ */ jsxs(Container, { ref: formRef, onSubmit: handleSubmit(onSubmit), children: [
76
76
  _.map(
77
77
  props.inputs,
78
- (data, index) => /* @__PURE__ */ jsx(React.Fragment, { children: component(data) }, index)
78
+ (data, index) => /* @__PURE__ */ jsx(React.Fragment, { children: data.type === "custom" ? data.component : component(data) }, index)
79
79
  ),
80
80
  _.isArray(props.buttons) && /* @__PURE__ */ jsx("div", { className: "form-buttons", children: _.map(
81
81
  props.buttons,
@@ -38,7 +38,7 @@ var import__ = require("../..");
38
38
  var import_lodash = __toESM(require("lodash"));
39
39
  function Modal(props) {
40
40
  var _a, _b, _c;
41
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { ...import_lodash.default.omit(props, ["className"]), position: props.position || "center", children: [
41
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { ...import_lodash.default.omit(props, ["className"]), position: props.position || "center", title: "", children: [
42
42
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "iz-modal-back", onClick: props.onClose }),
43
43
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "iz-modal-container", children: [
44
44
  (!!props.title || !!props.header) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "iz-modal-header", children: [
@@ -5,7 +5,7 @@ import { Button } from "../..";
5
5
  import _ from "lodash";
6
6
  function Modal(props) {
7
7
  var _a, _b, _c;
8
- return /* @__PURE__ */ jsxs(Container, { ..._.omit(props, ["className"]), position: props.position || "center", children: [
8
+ return /* @__PURE__ */ jsxs(Container, { ..._.omit(props, ["className"]), position: props.position || "center", title: "", children: [
9
9
  /* @__PURE__ */ jsx("div", { className: "iz-modal-back", onClick: props.onClose }),
10
10
  /* @__PURE__ */ jsxs("div", { className: "iz-modal-container", children: [
11
11
  (!!props.title || !!props.header) && /* @__PURE__ */ jsxs("div", { className: "iz-modal-header", children: [
@@ -125,7 +125,8 @@ function Table(props) {
125
125
  "div",
126
126
  {
127
127
  className: "iz-table-content-elipse",
128
- title: import_lodash.default.isString(body) ? body : "",
128
+ "data-tooltip": import_lodash.default.isString(body) ? body : "",
129
+ "data-tooltip-props": '{"position":"bottom"}',
129
130
  children: body
130
131
  }
131
132
  );
@@ -91,7 +91,8 @@ function Table(props) {
91
91
  "div",
92
92
  {
93
93
  className: "iz-table-content-elipse",
94
- title: _.isString(body) ? body : "",
94
+ "data-tooltip": _.isString(body) ? body : "",
95
+ "data-tooltip-props": '{"position":"bottom"}',
95
96
  children: body
96
97
  }
97
98
  );
@@ -1 +1 @@
1
- export declare const Content: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
1
+ export declare const Content: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
@@ -1 +1 @@
1
- export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
1
+ export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
@@ -1 +1 @@
1
- export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
1
+ export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
@@ -1 +1 @@
1
- export declare const Switcher: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
1
+ export declare const Switcher: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
@@ -41,12 +41,30 @@ 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;
44
+ var _a, _b, _c;
45
45
  const rect = target.getBoundingClientRect();
46
- return {
46
+ const props = JSON.parse(((_a = target.dataset) == null ? void 0 : _a["tooltip-props"]) || "{}");
47
+ const coords = {
47
48
  top: rect.top + window.scrollY - (target.offsetHeight + 8),
48
- left: rect.left + window.scrollX + target.offsetWidth / 2,
49
- content: ((_a = target.dataset) == null ? void 0 : _a.tooltip) || ""
49
+ left: rect.left + window.scrollX + target.offsetWidth / 2
50
+ };
51
+ switch (props.position) {
52
+ case "bottom":
53
+ coords.top = rect.top + window.scrollY + (target.offsetHeight + 8);
54
+ break;
55
+ case "left":
56
+ coords.top = rect.top + window.scrollY;
57
+ coords.left = rect.left + window.scrollX - target.offsetWidth;
58
+ break;
59
+ case "right":
60
+ coords.top = rect.top + window.scrollY;
61
+ coords.left = rect.left + window.scrollX + target.offsetWidth;
62
+ break;
63
+ }
64
+ return {
65
+ ...coords,
66
+ content: ((_b = target.dataset) == null ? void 0 : _b.tooltip) || "",
67
+ props: JSON.parse(((_c = target.dataset) == null ? void 0 : _c["tooltip-props"]) || "{}")
50
68
  };
51
69
  };
52
70
  (0, import_react.useEffect)(() => {
@@ -90,6 +108,7 @@ const TooltipProviderContainer = ({ children }) => {
90
108
  top: data.top,
91
109
  left: data.left
92
110
  },
111
+ ...data.props,
93
112
  children: data.content
94
113
  },
95
114
  index
@@ -7,12 +7,30 @@ const TooltipContext = createContext({});
7
7
  const TooltipProviderContainer = ({ children }) => {
8
8
  const [tooltips, setTooltips] = useState([]);
9
9
  const getContent = (target) => {
10
- var _a;
10
+ var _a, _b, _c;
11
11
  const rect = target.getBoundingClientRect();
12
- return {
12
+ const props = JSON.parse(((_a = target.dataset) == null ? void 0 : _a["tooltip-props"]) || "{}");
13
+ const coords = {
13
14
  top: rect.top + window.scrollY - (target.offsetHeight + 8),
14
- left: rect.left + window.scrollX + target.offsetWidth / 2,
15
- content: ((_a = target.dataset) == null ? void 0 : _a.tooltip) || ""
15
+ left: rect.left + window.scrollX + target.offsetWidth / 2
16
+ };
17
+ switch (props.position) {
18
+ case "bottom":
19
+ coords.top = rect.top + window.scrollY + (target.offsetHeight + 8);
20
+ break;
21
+ case "left":
22
+ coords.top = rect.top + window.scrollY;
23
+ coords.left = rect.left + window.scrollX - target.offsetWidth;
24
+ break;
25
+ case "right":
26
+ coords.top = rect.top + window.scrollY;
27
+ coords.left = rect.left + window.scrollX + target.offsetWidth;
28
+ break;
29
+ }
30
+ return {
31
+ ...coords,
32
+ content: ((_b = target.dataset) == null ? void 0 : _b.tooltip) || "",
33
+ props: JSON.parse(((_c = target.dataset) == null ? void 0 : _c["tooltip-props"]) || "{}")
16
34
  };
17
35
  };
18
36
  useEffect(() => {
@@ -56,6 +74,7 @@ const TooltipProviderContainer = ({ children }) => {
56
74
  top: data.top,
57
75
  left: data.left
58
76
  },
77
+ ...data.props,
59
78
  children: data.content
60
79
  },
61
80
  index
@@ -1 +1 @@
1
- export declare const Tooltip: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
1
+ export declare const Tooltip: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
@@ -32,6 +32,49 @@ __export(styles_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(styles_exports);
34
34
  var import_styled_components = __toESM(require("styled-components"));
35
+ const setPosition = (position = "top", isBorder) => {
36
+ const defaultPosition = `
37
+ transform: translateX(-50%);
38
+ bottom: -${isBorder ? "9" : "8"}px;
39
+ left: 50%;
40
+ border-left: 8px solid transparent;
41
+ border-right: 8px solid transparent;
42
+ border-top: 8px solid ${({ theme }) => theme.t05};
43
+ `;
44
+ switch (position) {
45
+ case "bottom":
46
+ return `
47
+ transform: translateX(-50%);
48
+ top: -${isBorder ? "9" : "8"}px;
49
+ left: 50%;
50
+ border-left: 8px solid transparent;
51
+ border-right: 8px solid transparent;
52
+ border-bottom: 8px solid ${({ theme }) => theme.t05};
53
+ `;
54
+ case "left":
55
+ return `
56
+ transform: translateY(-50%);
57
+ right: -${isBorder ? "9" : "8"}px;
58
+ top: 50%;
59
+ border-top: 8px solid transparent;
60
+ border-bottom: 8px solid transparent;
61
+ border-left: 8px solid ${({ theme }) => theme.t05};
62
+ `;
63
+ case "right":
64
+ return `
65
+ transform: translateY(-50%);
66
+ left: -${isBorder ? "9" : "8"}px;
67
+ top: 50%;
68
+ border-top: 8px solid transparent;
69
+ border-bottom: 8px solid transparent;
70
+ border-right: 8px solid ${({ theme }) => theme.t05};
71
+ `;
72
+ case "top":
73
+ return defaultPosition;
74
+ default:
75
+ return defaultPosition;
76
+ }
77
+ };
35
78
  const Tooltip = import_styled_components.default.div`
36
79
  position: fixed;
37
80
  background: ${({ theme }) => theme.tooltip};
@@ -41,34 +84,42 @@ const Tooltip = import_styled_components.default.div`
41
84
  text-align: center;
42
85
  padding: .3rem .8rem;
43
86
  border-radius: 5px;
44
- transform: translateX(-50%);
45
87
  z-index: 10;
46
88
  border: 1px solid ${({ theme }) => theme.t05};
89
+ transform: ${({ position = "top" }) => {
90
+ const defaultPosition = "translateX(-50%)";
91
+ switch (position) {
92
+ case "left":
93
+ return "translateX(0)";
94
+ case "right":
95
+ return "translateX(-100%)";
96
+ case "bottom":
97
+ return defaultPosition;
98
+ case "top":
99
+ return defaultPosition;
100
+ default:
101
+ return defaultPosition;
102
+ }
103
+ }};
104
+
105
+ @media(max-width: ${({ theme }) => theme.mobileMaxWidth}) {
106
+ display: none;
107
+ }
47
108
 
48
109
  &::before {
49
110
  content: "";
50
111
  position: absolute;
51
- bottom: -9px;
52
- left: 50%;
53
- transform: translateX(-50%);
54
112
  width: 0;
55
113
  height: 0;
56
- border-left: 8px solid transparent;
57
- border-right: 8px solid transparent;
58
- border-top: 8px solid ${({ theme }) => theme.t05};
114
+ ${({ position = "top" }) => setPosition(position, true)}
59
115
  }
60
116
 
61
117
  &::after {
62
118
  content: "";
63
119
  position: absolute;
64
- bottom: -8px;
65
- left: 50%;
66
- transform: translateX(-50%);
67
120
  width: 0;
68
121
  height: 0;
69
- border-left: 8px solid transparent;
70
- border-right: 8px solid transparent;
71
- border-top: 8px solid ${({ theme }) => theme.tooltip};
122
+ ${({ position = "top" }) => setPosition(position, true)}
72
123
  }
73
124
  `;
74
125
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,4 +1,47 @@
1
1
  import styled from "styled-components";
2
+ const setPosition = (position = "top", isBorder) => {
3
+ const defaultPosition = `
4
+ transform: translateX(-50%);
5
+ bottom: -${isBorder ? "9" : "8"}px;
6
+ left: 50%;
7
+ border-left: 8px solid transparent;
8
+ border-right: 8px solid transparent;
9
+ border-top: 8px solid ${({ theme }) => theme.t05};
10
+ `;
11
+ switch (position) {
12
+ case "bottom":
13
+ return `
14
+ transform: translateX(-50%);
15
+ top: -${isBorder ? "9" : "8"}px;
16
+ left: 50%;
17
+ border-left: 8px solid transparent;
18
+ border-right: 8px solid transparent;
19
+ border-bottom: 8px solid ${({ theme }) => theme.t05};
20
+ `;
21
+ case "left":
22
+ return `
23
+ transform: translateY(-50%);
24
+ right: -${isBorder ? "9" : "8"}px;
25
+ top: 50%;
26
+ border-top: 8px solid transparent;
27
+ border-bottom: 8px solid transparent;
28
+ border-left: 8px solid ${({ theme }) => theme.t05};
29
+ `;
30
+ case "right":
31
+ return `
32
+ transform: translateY(-50%);
33
+ left: -${isBorder ? "9" : "8"}px;
34
+ top: 50%;
35
+ border-top: 8px solid transparent;
36
+ border-bottom: 8px solid transparent;
37
+ border-right: 8px solid ${({ theme }) => theme.t05};
38
+ `;
39
+ case "top":
40
+ return defaultPosition;
41
+ default:
42
+ return defaultPosition;
43
+ }
44
+ };
2
45
  const Tooltip = styled.div`
3
46
  position: fixed;
4
47
  background: ${({ theme }) => theme.tooltip};
@@ -8,34 +51,42 @@ const Tooltip = styled.div`
8
51
  text-align: center;
9
52
  padding: .3rem .8rem;
10
53
  border-radius: 5px;
11
- transform: translateX(-50%);
12
54
  z-index: 10;
13
55
  border: 1px solid ${({ theme }) => theme.t05};
56
+ transform: ${({ position = "top" }) => {
57
+ const defaultPosition = "translateX(-50%)";
58
+ switch (position) {
59
+ case "left":
60
+ return "translateX(0)";
61
+ case "right":
62
+ return "translateX(-100%)";
63
+ case "bottom":
64
+ return defaultPosition;
65
+ case "top":
66
+ return defaultPosition;
67
+ default:
68
+ return defaultPosition;
69
+ }
70
+ }};
71
+
72
+ @media(max-width: ${({ theme }) => theme.mobileMaxWidth}) {
73
+ display: none;
74
+ }
14
75
 
15
76
  &::before {
16
77
  content: "";
17
78
  position: absolute;
18
- bottom: -9px;
19
- left: 50%;
20
- transform: translateX(-50%);
21
79
  width: 0;
22
80
  height: 0;
23
- border-left: 8px solid transparent;
24
- border-right: 8px solid transparent;
25
- border-top: 8px solid ${({ theme }) => theme.t05};
81
+ ${({ position = "top" }) => setPosition(position, true)}
26
82
  }
27
83
 
28
84
  &::after {
29
85
  content: "";
30
86
  position: absolute;
31
- bottom: -8px;
32
- left: 50%;
33
- transform: translateX(-50%);
34
87
  width: 0;
35
88
  height: 0;
36
- border-left: 8px solid transparent;
37
- border-right: 8px solid transparent;
38
- border-top: 8px solid ${({ theme }) => theme.tooltip};
89
+ ${({ position = "top" }) => setPosition(position, true)}
39
90
  }
40
91
  `;
41
92
  export {
@@ -1,5 +1,8 @@
1
1
  import { UseFormRegister } from "react-hook-form";
2
+ import { IInputType } from "@interfaces";
3
+ import { z } from "zod";
2
4
  export interface IInputDateTime {
5
+ type?: IInputType;
3
6
  className?: string;
4
7
  label?: string;
5
8
  name: string;
@@ -12,4 +15,5 @@ export interface IInputDateTime {
12
15
  disabled?: boolean;
13
16
  required?: boolean;
14
17
  register?: UseFormRegister<any>;
18
+ validation?: typeof z;
15
19
  }
@@ -1,5 +1,8 @@
1
1
  import { UseFormRegister } from "react-hook-form";
2
+ import { IInputType } from "@interfaces";
3
+ import { z } from "zod";
2
4
  export interface IInputFile {
5
+ type?: IInputType;
3
6
  className?: string;
4
7
  label?: string;
5
8
  name: string;
@@ -11,4 +14,5 @@ export interface IInputFile {
11
14
  onFocus: (value: string) => void;
12
15
  required?: boolean;
13
16
  register?: UseFormRegister<any>;
17
+ validation?: typeof z;
14
18
  }
@@ -1,3 +1,5 @@
1
+ import React from "react";
2
+ import { IButton, IInputSelect, IInputFile, IInputText, IInputTextarea, IInputDateTime } from "@interfaces";
1
3
  export * from "./file";
2
4
  export * from "./label";
3
5
  export * from "./input";
@@ -5,12 +7,16 @@ export * from "./select";
5
7
  export * from "./button";
6
8
  export * from "./datetime";
7
9
  export * from "./textarea";
10
+ export type IInputType = "text" | "password" | "select" | "textarea" | "date-time" | "file" | "custom";
8
11
  export interface IForm {
9
12
  defaultValues?: any;
10
13
  validation?: any;
11
14
  formRef?: any;
12
15
  onSubmit: (values: any, actions?: any) => void;
13
16
  clearWhen?: boolean;
14
- inputs: Array<any>;
15
- buttons?: Array<any>;
17
+ inputs: Array<IInputSelect & IInputFile & IInputText & IInputTextarea & IInputDateTime & {
18
+ type: IInputType;
19
+ component: React.ReactNode;
20
+ }>;
21
+ buttons?: Array<IButton>;
16
22
  }
@@ -1,10 +1,12 @@
1
1
  import { UseFormRegister } from "react-hook-form";
2
+ import { IInputType } from "@interfaces";
3
+ import { z } from "zod";
2
4
  export interface IInputText {
3
5
  className?: string;
4
6
  label?: string;
5
7
  id?: string;
6
8
  name?: string;
7
- type?: string;
9
+ type?: IInputType;
8
10
  value?: string;
9
11
  mask?: (value: string) => void;
10
12
  onChange?: (event: any) => void;
@@ -14,4 +16,5 @@ export interface IInputText {
14
16
  onFocus?: (value: any) => void;
15
17
  required?: boolean;
16
18
  register?: UseFormRegister<any>;
19
+ validation?: typeof z;
17
20
  }
@@ -1,5 +1,8 @@
1
1
  import { UseFormRegister } from "react-hook-form";
2
+ import { IInputType } from "@interfaces";
3
+ import { z } from "zod";
2
4
  export interface IInputSelect {
5
+ type?: IInputType;
3
6
  className?: string;
4
7
  label?: string;
5
8
  name: string;
@@ -11,4 +14,5 @@ export interface IInputSelect {
11
14
  onFocus: (value: any) => void;
12
15
  required?: boolean;
13
16
  register?: UseFormRegister<any>;
17
+ validation?: typeof z;
14
18
  }
@@ -1,5 +1,8 @@
1
1
  import { UseFormRegister } from "react-hook-form";
2
+ import { IInputType } from "@interfaces";
3
+ import { z } from "zod";
2
4
  export interface IInputTextarea {
5
+ type?: IInputType;
3
6
  className?: string;
4
7
  label?: string;
5
8
  name: string;
@@ -13,4 +16,5 @@ export interface IInputTextarea {
13
16
  onFocus: (value: string) => void;
14
17
  required?: boolean;
15
18
  register?: UseFormRegister<any>;
19
+ validation?: typeof z;
16
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.13",
3
+ "version": "1.4.15",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",