@gustavo-valsechi/client 1.4.36 → 1.4.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.
@@ -95,7 +95,7 @@ function Form(props) {
95
95
  ComponentType,
96
96
  {
97
97
  ...import_lodash.default.omit(data, ["validation"]),
98
- id: data.name,
98
+ id: `iz-input-${data.name}`,
99
99
  type: component2 ? void 0 : data.type,
100
100
  error: (_a = errors[data.name]) == null ? void 0 : _a.message,
101
101
  register,
@@ -61,7 +61,7 @@ function Form(props) {
61
61
  ComponentType,
62
62
  {
63
63
  ..._.omit(data, ["validation"]),
64
- id: data.name,
64
+ id: `iz-input-${data.name}`,
65
65
  type: component2 ? void 0 : data.type,
66
66
  error: (_a = errors[data.name]) == null ? void 0 : _a.message,
67
67
  register,
@@ -53,6 +53,7 @@ function Button(props) {
53
53
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
54
54
  import_styles.Container,
55
55
  {
56
+ id: `iz-button-${import_lodash.default.replace(import_lodash.default.lowerCase(props.label), /\s/g, "-")}`,
56
57
  loading: String(loading || !!props.loading),
57
58
  disabled: props.disabled,
58
59
  type: props.type || "button",
@@ -20,6 +20,7 @@ function Button(props) {
20
20
  return /* @__PURE__ */ jsxs(
21
21
  Container,
22
22
  {
23
+ id: `iz-button-${_.replace(_.lowerCase(props.label), /\s/g, "-")}`,
23
24
  loading: String(loading || !!props.loading),
24
25
  disabled: props.disabled,
25
26
  type: props.type || "button",
@@ -35,24 +35,22 @@ __export(target_exports, {
35
35
  module.exports = __toCommonJS(target_exports);
36
36
  var import_jsx_runtime = require("react/jsx-runtime");
37
37
  var import_react = require("react");
38
+ var import_styles = require("./styles");
38
39
  var import_lodash = __toESM(require("lodash"));
39
40
  const TargetContext = (0, import_react.createContext)({});
41
+ const memory = [];
40
42
  const TargetProviderContainer = ({ children }) => {
41
43
  const [targets, setTargets] = (0, import_react.useState)([]);
42
44
  (0, import_react.useEffect)(() => {
43
- let newTargets = [...targets];
44
45
  import_lodash.default.forEach(targets, (target, index) => {
45
46
  var _a;
46
47
  const element = (_a = target.ref) == null ? void 0 : _a.current;
47
48
  if (!element) return;
48
- const handleClick = (index2) => {
49
- console.log("CLICANDO");
50
- if (JSON.stringify(import_lodash.default.pick(targets, ["show"])) === JSON.stringify(import_lodash.default.pick(newTargets, ["show"]))) return;
51
- newTargets.splice(index2, 1, { ...target, show: !target.show });
49
+ element.addEventListener("click", () => {
50
+ const newTargets = [...targets];
51
+ newTargets.splice(index, 1, { ...target, show: !target.show });
52
52
  setTargets(newTargets);
53
- };
54
- element.addEventListener("click", handleClick);
55
- return () => element.removeEventListener("click", handleClick);
53
+ });
56
54
  });
57
55
  }, [targets]);
58
56
  const getCoords = (target) => {
@@ -72,10 +70,13 @@ const TargetProviderContainer = ({ children }) => {
72
70
  return coords;
73
71
  };
74
72
  const add = (target) => {
75
- setTargets(import_lodash.default.concat(targets, target));
73
+ memory.push(target);
74
+ setTargets(memory);
76
75
  };
77
76
  const remove = (ref) => {
78
- setTargets(import_lodash.default.filter(targets, (data) => data.ref.current !== ref.current));
77
+ const index = import_lodash.default.findIndex(memory, (data) => data.ref.current === ref.current);
78
+ memory.slice(index, 1);
79
+ setTargets(memory);
79
80
  };
80
81
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
81
82
  TargetContext.Provider,
@@ -87,8 +88,8 @@ const TargetProviderContainer = ({ children }) => {
87
88
  children: [
88
89
  import_lodash.default.map(
89
90
  targets,
90
- (target, index) => target.show && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
91
- "div",
91
+ (target, index) => !!target.show && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
92
+ import_styles.Container,
92
93
  {
93
94
  style: getCoords(target.ref.current),
94
95
  children: target.component
@@ -1,24 +1,22 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { createContext, useContext, useEffect, useState } from "react";
4
+ import { Container } from "./styles";
4
5
  import _ from "lodash";
5
6
  const TargetContext = createContext({});
7
+ const memory = [];
6
8
  const TargetProviderContainer = ({ children }) => {
7
9
  const [targets, setTargets] = useState([]);
8
10
  useEffect(() => {
9
- let newTargets = [...targets];
10
11
  _.forEach(targets, (target, index) => {
11
12
  var _a;
12
13
  const element = (_a = target.ref) == null ? void 0 : _a.current;
13
14
  if (!element) return;
14
- const handleClick = (index2) => {
15
- console.log("CLICANDO");
16
- if (JSON.stringify(_.pick(targets, ["show"])) === JSON.stringify(_.pick(newTargets, ["show"]))) return;
17
- newTargets.splice(index2, 1, { ...target, show: !target.show });
15
+ element.addEventListener("click", () => {
16
+ const newTargets = [...targets];
17
+ newTargets.splice(index, 1, { ...target, show: !target.show });
18
18
  setTargets(newTargets);
19
- };
20
- element.addEventListener("click", handleClick);
21
- return () => element.removeEventListener("click", handleClick);
19
+ });
22
20
  });
23
21
  }, [targets]);
24
22
  const getCoords = (target) => {
@@ -38,10 +36,13 @@ const TargetProviderContainer = ({ children }) => {
38
36
  return coords;
39
37
  };
40
38
  const add = (target) => {
41
- setTargets(_.concat(targets, target));
39
+ memory.push(target);
40
+ setTargets(memory);
42
41
  };
43
42
  const remove = (ref) => {
44
- setTargets(_.filter(targets, (data) => data.ref.current !== ref.current));
43
+ const index = _.findIndex(memory, (data) => data.ref.current === ref.current);
44
+ memory.slice(index, 1);
45
+ setTargets(memory);
45
46
  };
46
47
  return /* @__PURE__ */ jsxs(
47
48
  TargetContext.Provider,
@@ -53,8 +54,8 @@ const TargetProviderContainer = ({ children }) => {
53
54
  children: [
54
55
  _.map(
55
56
  targets,
56
- (target, index) => target.show && /* @__PURE__ */ jsx(
57
- "div",
57
+ (target, index) => !!target.show && /* @__PURE__ */ jsx(
58
+ Container,
58
59
  {
59
60
  style: getCoords(target.ref.current),
60
61
  children: target.component
@@ -1 +1 @@
1
- export declare const Tooltip: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
1
+ export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
@@ -28,103 +28,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var styles_exports = {};
30
30
  __export(styles_exports, {
31
- Tooltip: () => Tooltip
31
+ Container: () => Container
32
32
  });
33
33
  module.exports = __toCommonJS(styles_exports);
34
34
  var import_styled_components = __toESM(require("styled-components"));
35
- const setPosition = ({ position = "top", theme }, isBorder) => {
36
- const coord = isBorder ? "9" : "8";
37
- const color = isBorder ? theme.t05 : theme.tooltip;
38
- const defaultPosition = `
39
- transform: translateX(-50%);
40
- bottom: -${coord}px;
41
- left: 50%;
42
- border-left: 8px solid transparent;
43
- border-right: 8px solid transparent;
44
- border-top: 8px solid ${color};
45
- `;
46
- switch (position) {
47
- case "bottom":
48
- return `
49
- transform: translateX(-50%);
50
- top: -${coord}px;
51
- left: 50%;
52
- border-left: 8px solid transparent;
53
- border-right: 8px solid transparent;
54
- border-bottom: 8px solid ${color};
55
- `;
56
- case "left":
57
- return `
58
- transform: translateY(-50%);
59
- right: -${coord}px;
60
- top: 50%;
61
- border-top: 8px solid transparent;
62
- border-bottom: 8px solid transparent;
63
- border-left: 8px solid ${color};
64
- `;
65
- case "right":
66
- return `
67
- transform: translateY(-50%);
68
- left: -${coord}px;
69
- top: 50%;
70
- border-top: 8px solid transparent;
71
- border-bottom: 8px solid transparent;
72
- border-right: 8px solid ${color};
73
- `;
74
- case "top":
75
- return defaultPosition;
76
- default:
77
- return defaultPosition;
78
- }
79
- };
80
- const Tooltip = import_styled_components.default.div`
81
- position: fixed;
82
- background: ${({ theme }) => theme.tooltip};
83
- color: ${({ theme }) => theme.t6};
84
- font-size: .8rem;
85
- font-weight: 500;
86
- text-align: center;
87
- padding: .3rem .8rem;
88
- border-radius: 5px;
89
- z-index: 10;
90
- border: 1px solid ${({ theme }) => theme.t05};
91
- transform: ${({ position = "top" }) => {
92
- const defaultPosition = "translateX(-50%)";
93
- switch (position) {
94
- case "left":
95
- return "translateX(0)";
96
- case "right":
97
- return "translateX(-100%)";
98
- case "bottom":
99
- return defaultPosition;
100
- case "top":
101
- return defaultPosition;
102
- default:
103
- return defaultPosition;
104
- }
105
- }};
106
-
107
- @media(max-width: ${({ theme }) => theme.mobileMaxWidth}) {
108
- display: none;
109
- }
110
-
111
- &::before {
112
- content: "";
113
- position: absolute;
114
- width: 0;
115
- height: 0;
116
- ${(props) => setPosition(props, true)}
117
- }
118
-
119
- &::after {
120
- content: "";
121
- position: absolute;
122
- width: 0;
123
- height: 0;
124
- ${(props) => setPosition(props)}
125
- }
35
+ const Container = import_styled_components.default.div`
36
+ position: absolute;
126
37
  `;
127
38
  // Annotate the CommonJS export names for ESM import in node:
128
39
  0 && (module.exports = {
129
- Tooltip
40
+ Container
130
41
  });
@@ -1,96 +1,7 @@
1
1
  import styled from "styled-components";
2
- const setPosition = ({ position = "top", theme }, isBorder) => {
3
- const coord = isBorder ? "9" : "8";
4
- const color = isBorder ? theme.t05 : theme.tooltip;
5
- const defaultPosition = `
6
- transform: translateX(-50%);
7
- bottom: -${coord}px;
8
- left: 50%;
9
- border-left: 8px solid transparent;
10
- border-right: 8px solid transparent;
11
- border-top: 8px solid ${color};
12
- `;
13
- switch (position) {
14
- case "bottom":
15
- return `
16
- transform: translateX(-50%);
17
- top: -${coord}px;
18
- left: 50%;
19
- border-left: 8px solid transparent;
20
- border-right: 8px solid transparent;
21
- border-bottom: 8px solid ${color};
22
- `;
23
- case "left":
24
- return `
25
- transform: translateY(-50%);
26
- right: -${coord}px;
27
- top: 50%;
28
- border-top: 8px solid transparent;
29
- border-bottom: 8px solid transparent;
30
- border-left: 8px solid ${color};
31
- `;
32
- case "right":
33
- return `
34
- transform: translateY(-50%);
35
- left: -${coord}px;
36
- top: 50%;
37
- border-top: 8px solid transparent;
38
- border-bottom: 8px solid transparent;
39
- border-right: 8px solid ${color};
40
- `;
41
- case "top":
42
- return defaultPosition;
43
- default:
44
- return defaultPosition;
45
- }
46
- };
47
- const Tooltip = styled.div`
48
- position: fixed;
49
- background: ${({ theme }) => theme.tooltip};
50
- color: ${({ theme }) => theme.t6};
51
- font-size: .8rem;
52
- font-weight: 500;
53
- text-align: center;
54
- padding: .3rem .8rem;
55
- border-radius: 5px;
56
- z-index: 10;
57
- border: 1px solid ${({ theme }) => theme.t05};
58
- transform: ${({ position = "top" }) => {
59
- const defaultPosition = "translateX(-50%)";
60
- switch (position) {
61
- case "left":
62
- return "translateX(0)";
63
- case "right":
64
- return "translateX(-100%)";
65
- case "bottom":
66
- return defaultPosition;
67
- case "top":
68
- return defaultPosition;
69
- default:
70
- return defaultPosition;
71
- }
72
- }};
73
-
74
- @media(max-width: ${({ theme }) => theme.mobileMaxWidth}) {
75
- display: none;
76
- }
77
-
78
- &::before {
79
- content: "";
80
- position: absolute;
81
- width: 0;
82
- height: 0;
83
- ${(props) => setPosition(props, true)}
84
- }
85
-
86
- &::after {
87
- content: "";
88
- position: absolute;
89
- width: 0;
90
- height: 0;
91
- ${(props) => setPosition(props)}
92
- }
2
+ const Container = styled.div`
3
+ position: absolute;
93
4
  `;
94
5
  export {
95
- Tooltip
6
+ Container
96
7
  };
@@ -1,4 +1,4 @@
1
- import { IButton, IInputSelect, IInputFile, IInputText, IInputTextarea, IInputDateTime, IInputCustom } from "@interfaces";
1
+ import { IButton, IInputSelect } from "@interfaces";
2
2
  export * from "./file";
3
3
  export * from "./label";
4
4
  export * from "./text";
@@ -15,6 +15,6 @@ export interface IForm {
15
15
  formRef?: any;
16
16
  onSubmit: (values: any, actions?: any) => void;
17
17
  clearWhen?: boolean;
18
- inputs: Array<IInputSelect & IInputFile & IInputText & IInputTextarea & IInputDateTime & IInputCustom>;
18
+ inputs: Array<IInputSelect>;
19
19
  buttons?: Array<IButton>;
20
20
  }
@@ -9,9 +9,9 @@ export interface IInputSelect {
9
9
  value?: string;
10
10
  onChange?: (event: any) => void;
11
11
  options: Array<any>;
12
- error: string;
12
+ error?: string;
13
13
  disabled?: boolean;
14
- onFocus: (value: any) => void;
14
+ onFocus?: (value: any) => void;
15
15
  required?: boolean;
16
16
  register?: UseFormRegister<any>;
17
17
  validation?: typeof z;
@@ -0,0 +1 @@
1
+ export default function App(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.36",
3
+ "version": "1.4.38",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,7 +15,8 @@
15
15
  "build:remodel": "node scripts/remodel.js",
16
16
  "build:assets": "node scripts/assets.js",
17
17
  "build": "npm run clean && npm run build:js && npm run build:types && npm run build:assets && npm run build:remodel",
18
- "commit": "npm run build && npm version patch --no-git-tag-version && npm publish --access public"
18
+ "commit": "npm run build && npm version patch --no-git-tag-version && npm publish --access public",
19
+ "dev": "vite --open test/index.html"
19
20
  },
20
21
  "peerDependencies": {
21
22
  "react": "18.3.1",
@@ -24,8 +25,8 @@
24
25
  },
25
26
  "dependencies": {
26
27
  "@emotion/is-prop-valid": "1.3.0",
27
- "@gustavo-valsechi/utils": "1.0.4",
28
28
  "@gustavo-valsechi/server": "1.0.13",
29
+ "@gustavo-valsechi/utils": "1.0.4",
29
30
  "@hookform/resolvers": "5.2.2",
30
31
  "apexcharts": "3.51.0",
31
32
  "lodash": "4.17.21",
@@ -48,6 +49,7 @@
48
49
  "@types/react-dom": "18.3.0",
49
50
  "@types/react-lottie": "1.2.10",
50
51
  "@types/styled-components": "5.1.34",
52
+ "@vitejs/plugin-react": "^5.1.0",
51
53
  "esbuild": "0.25.11",
52
54
  "esbuild-css-modules-plugin": "^3.1.5",
53
55
  "raw-loader": "4.0.2",
@@ -56,7 +58,8 @@
56
58
  "rimraf": "6.1.0",
57
59
  "styled-components": "6.1.12",
58
60
  "tsc-alias": "1.8.16",
59
- "typescript": "5.5.4"
61
+ "typescript": "5.5.4",
62
+ "vite": "^7.2.1"
60
63
  },
61
64
  "publishConfig": {
62
65
  "access": "public"