@juantroconisf/lib 3.1.5 → 3.1.7
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 +15 -8
- package/dist/index.mjs +15 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -184,13 +184,16 @@ function useFormChange({
|
|
|
184
184
|
const [state, setState] = (0, import_react.useState)(newState), falseState = allToValue(state, false), [touched, setTouched] = (0, import_react.useState)(falseState), errors2 = (0, import_react.useRef)({ ...falseState }), untouchedErrors = (0, import_react.useRef)({ ...falseState }), { getValidation } = useValidation();
|
|
185
185
|
const onBlur = (id) => setTouched(
|
|
186
186
|
handleNestedChange({ state: touched, id, value: true })
|
|
187
|
-
), onValueChange = (id, value) => setState(handleNestedChange({ state, id, value })), onSelectionChange = (id, value) =>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
), onValueChange = (id, value) => setState(handleNestedChange({ state, id, value })), onSelectionChange = (id, value) => {
|
|
188
|
+
console.log("onSelectionChange", state[id], value);
|
|
189
|
+
setState(
|
|
190
|
+
handleNestedChange({
|
|
191
|
+
state,
|
|
192
|
+
id,
|
|
193
|
+
value: state[id] === "string" ? value : Array.from(value)
|
|
194
|
+
})
|
|
195
|
+
);
|
|
196
|
+
};
|
|
194
197
|
const registerHandle = (0, import_react.useCallback)(
|
|
195
198
|
(id) => {
|
|
196
199
|
const [value, isTouched] = [state[id], touched[id]], selectedValidations = validations?.[id], hasValidations = selectedValidations !== void 0, inputValidations = getValidation(
|
|
@@ -247,11 +250,15 @@ function useFormChange({
|
|
|
247
250
|
),
|
|
248
251
|
hasInvalidValues: () => {
|
|
249
252
|
setTouched(allToValue(touched, true));
|
|
253
|
+
console.log("Errors count", JSON.stringify(untouchedErrors.current));
|
|
250
254
|
return JSON.stringify(untouchedErrors.current).includes(":true");
|
|
251
255
|
},
|
|
252
256
|
touched,
|
|
253
257
|
resetForm: () => {
|
|
254
|
-
|
|
258
|
+
const val = allToValue(newState, false);
|
|
259
|
+
setTouched(val);
|
|
260
|
+
errors2.current = val;
|
|
261
|
+
untouchedErrors.current = val;
|
|
255
262
|
setState(newState);
|
|
256
263
|
}
|
|
257
264
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -165,13 +165,16 @@ function useFormChange({
|
|
|
165
165
|
const [state, setState] = useState(newState), falseState = allToValue(state, false), [touched, setTouched] = useState(falseState), errors2 = useRef({ ...falseState }), untouchedErrors = useRef({ ...falseState }), { getValidation } = useValidation();
|
|
166
166
|
const onBlur = (id) => setTouched(
|
|
167
167
|
handleNestedChange({ state: touched, id, value: true })
|
|
168
|
-
), onValueChange = (id, value) => setState(handleNestedChange({ state, id, value })), onSelectionChange = (id, value) =>
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
168
|
+
), onValueChange = (id, value) => setState(handleNestedChange({ state, id, value })), onSelectionChange = (id, value) => {
|
|
169
|
+
console.log("onSelectionChange", state[id], value);
|
|
170
|
+
setState(
|
|
171
|
+
handleNestedChange({
|
|
172
|
+
state,
|
|
173
|
+
id,
|
|
174
|
+
value: state[id] === "string" ? value : Array.from(value)
|
|
175
|
+
})
|
|
176
|
+
);
|
|
177
|
+
};
|
|
175
178
|
const registerHandle = useCallback(
|
|
176
179
|
(id) => {
|
|
177
180
|
const [value, isTouched] = [state[id], touched[id]], selectedValidations = validations?.[id], hasValidations = selectedValidations !== void 0, inputValidations = getValidation(
|
|
@@ -228,11 +231,15 @@ function useFormChange({
|
|
|
228
231
|
),
|
|
229
232
|
hasInvalidValues: () => {
|
|
230
233
|
setTouched(allToValue(touched, true));
|
|
234
|
+
console.log("Errors count", JSON.stringify(untouchedErrors.current));
|
|
231
235
|
return JSON.stringify(untouchedErrors.current).includes(":true");
|
|
232
236
|
},
|
|
233
237
|
touched,
|
|
234
238
|
resetForm: () => {
|
|
235
|
-
|
|
239
|
+
const val = allToValue(newState, false);
|
|
240
|
+
setTouched(val);
|
|
241
|
+
errors2.current = val;
|
|
242
|
+
untouchedErrors.current = val;
|
|
236
243
|
setState(newState);
|
|
237
244
|
}
|
|
238
245
|
};
|