@juantroconisf/lib 2.3.4 → 2.3.5

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.
package/dist/index.js CHANGED
@@ -192,22 +192,25 @@ function useFormChange(initialObj) {
192
192
  setTouched(allToValue(initialObj, false));
193
193
  setState(initialObj);
194
194
  };
195
- function register(id, validations, errorMessages) {
196
- const [value, isTouched] = [state[id], touched[id]], hasValidations = validations !== void 0, inputValidations = hasValidations ? getValidation(value, isTouched, validations, errorMessages) : {};
197
- errors2.current = handleNestedChange({
198
- state: errors2.current,
199
- id,
200
- value: hasValidations ? !inputValidations.isValid : false
201
- });
202
- return {
203
- id,
204
- onChange,
205
- onBlur,
206
- value,
207
- isInvalid: hasValidations ? !inputValidations.isValid : false,
208
- errorMessage: hasValidations ? inputValidations.validationProps.errorMessage : ""
209
- };
210
- }
195
+ const register = (0, import_react.useCallback)(
196
+ (id, validations, errorMessages) => {
197
+ const [value, isTouched] = [state[id], touched[id]], hasValidations = validations !== void 0, inputValidations = hasValidations ? getValidation(value, isTouched, validations, errorMessages) : {};
198
+ errors2.current = handleNestedChange({
199
+ state: errors2.current,
200
+ id,
201
+ value: hasValidations ? !inputValidations.isValid : false
202
+ });
203
+ return {
204
+ id,
205
+ onChange,
206
+ onBlur,
207
+ value,
208
+ isInvalid: hasValidations ? !inputValidations.isValid : false,
209
+ errorMessage: hasValidations ? inputValidations.validationProps.errorMessage : ""
210
+ };
211
+ },
212
+ [getValidation, onChange, onBlur]
213
+ );
211
214
  const hasInvalidValues = () => {
212
215
  setTouched(allToValue(touched, true));
213
216
  return JSON.stringify(errors2.current).includes(":true");
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  });
7
7
 
8
8
  // src/hooks/useFormChange.tsx
9
- import { useState, useRef } from "react";
9
+ import { useState, useRef, useCallback } from "react";
10
10
 
11
11
  // types/errors.ts
12
12
  var NextUIError = class {
@@ -174,22 +174,25 @@ function useFormChange(initialObj) {
174
174
  setTouched(allToValue(initialObj, false));
175
175
  setState(initialObj);
176
176
  };
177
- function register(id, validations, errorMessages) {
178
- const [value, isTouched] = [state[id], touched[id]], hasValidations = validations !== void 0, inputValidations = hasValidations ? getValidation(value, isTouched, validations, errorMessages) : {};
179
- errors2.current = handleNestedChange({
180
- state: errors2.current,
181
- id,
182
- value: hasValidations ? !inputValidations.isValid : false
183
- });
184
- return {
185
- id,
186
- onChange,
187
- onBlur,
188
- value,
189
- isInvalid: hasValidations ? !inputValidations.isValid : false,
190
- errorMessage: hasValidations ? inputValidations.validationProps.errorMessage : ""
191
- };
192
- }
177
+ const register = useCallback(
178
+ (id, validations, errorMessages) => {
179
+ const [value, isTouched] = [state[id], touched[id]], hasValidations = validations !== void 0, inputValidations = hasValidations ? getValidation(value, isTouched, validations, errorMessages) : {};
180
+ errors2.current = handleNestedChange({
181
+ state: errors2.current,
182
+ id,
183
+ value: hasValidations ? !inputValidations.isValid : false
184
+ });
185
+ return {
186
+ id,
187
+ onChange,
188
+ onBlur,
189
+ value,
190
+ isInvalid: hasValidations ? !inputValidations.isValid : false,
191
+ errorMessage: hasValidations ? inputValidations.validationProps.errorMessage : ""
192
+ };
193
+ },
194
+ [getValidation, onChange, onBlur]
195
+ );
193
196
  const hasInvalidValues = () => {
194
197
  setTouched(allToValue(touched, true));
195
198
  return JSON.stringify(errors2.current).includes(":true");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juantroconisf/lib",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",