@gustavo-valsechi/client 1.4.21 → 1.4.23

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.
@@ -59,7 +59,8 @@ function Form(props) {
59
59
  register,
60
60
  handleSubmit,
61
61
  reset,
62
- formState: { errors }
62
+ formState: { errors },
63
+ setValue
63
64
  } = (0, import_react_hook_form.useForm)({
64
65
  resolver: (0, import_zod2.zodResolver)(schema),
65
66
  defaultValues: props.defaultValues,
@@ -96,7 +97,8 @@ function Form(props) {
96
97
  id: data.name,
97
98
  type: component2 ? void 0 : data.type,
98
99
  error: (_a = errors[data.name]) == null ? void 0 : _a.message,
99
- register
100
+ register,
101
+ setValue: data.type === "InputCustom" ? setValue : void 0
100
102
  }
101
103
  );
102
104
  };
@@ -25,7 +25,8 @@ function Form(props) {
25
25
  register,
26
26
  handleSubmit,
27
27
  reset,
28
- formState: { errors }
28
+ formState: { errors },
29
+ setValue
29
30
  } = useForm({
30
31
  resolver: zodResolver(schema),
31
32
  defaultValues: props.defaultValues,
@@ -62,7 +63,8 @@ function Form(props) {
62
63
  id: data.name,
63
64
  type: component2 ? void 0 : data.type,
64
65
  error: (_a = errors[data.name]) == null ? void 0 : _a.message,
65
- register
66
+ register,
67
+ setValue: data.type === "InputCustom" ? setValue : void 0
66
68
  }
67
69
  );
68
70
  };
@@ -28,19 +28,18 @@ var import_styles = require("./styles");
28
28
  var import_label = require("../label");
29
29
  var import_error = require("../error");
30
30
  function InputCustom(props) {
31
- const inputRef = (0, import_react.useRef)({});
32
31
  const register = (props.register || ((name) => ({})))(props.name || "");
33
32
  (0, import_react.useEffect)(() => {
34
- if (!inputRef.current) return;
35
- inputRef.current.value = props.value;
36
- }, [inputRef, props.value]);
33
+ var _a;
34
+ (_a = props.setValue) == null ? void 0 : _a.call(props, props.name, props.value);
35
+ }, [props.name, props.value]);
37
36
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { className: props.className, children: [
38
37
  !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_label.InputLabel, { children: [
39
38
  props.label,
40
39
  props.required ? "*" : ""
41
40
  ] }),
42
41
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "iz-input-content", children: [
43
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { ref: inputRef, hidden: true, ...register }),
42
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { hidden: true, ...register }),
44
43
  props.children
45
44
  ] }),
46
45
  !!props.error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_error.InputError, { className: "iz-input-custom-error", children: props.error })
@@ -1,23 +1,22 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useEffect, useRef } from "react";
3
+ import { useEffect } from "react";
4
4
  import { Container } from "./styles";
5
5
  import { InputLabel } from "../label";
6
6
  import { InputError } from "../error";
7
7
  function InputCustom(props) {
8
- const inputRef = useRef({});
9
8
  const register = (props.register || ((name) => ({})))(props.name || "");
10
9
  useEffect(() => {
11
- if (!inputRef.current) return;
12
- inputRef.current.value = props.value;
13
- }, [inputRef, props.value]);
10
+ var _a;
11
+ (_a = props.setValue) == null ? void 0 : _a.call(props, props.name, props.value);
12
+ }, [props.name, props.value]);
14
13
  return /* @__PURE__ */ jsxs(Container, { className: props.className, children: [
15
14
  !!props.label && /* @__PURE__ */ jsxs(InputLabel, { children: [
16
15
  props.label,
17
16
  props.required ? "*" : ""
18
17
  ] }),
19
18
  /* @__PURE__ */ jsxs("div", { className: "iz-input-content", children: [
20
- /* @__PURE__ */ jsx("input", { ref: inputRef, hidden: true, ...register }),
19
+ /* @__PURE__ */ jsx("input", { hidden: true, ...register }),
21
20
  props.children
22
21
  ] }),
23
22
  !!props.error && /* @__PURE__ */ jsx(InputError, { className: "iz-input-custom-error", children: props.error })
@@ -13,6 +13,7 @@ export interface IInputCustom {
13
13
  disabled?: boolean;
14
14
  required?: boolean;
15
15
  register?: UseFormRegister<any>;
16
+ setValue?: (...args: any[]) => void;
16
17
  children: React.ReactNode;
17
18
  validation?: typeof z;
18
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.21",
3
+ "version": "1.4.23",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",