@juantroconisf/lib 2.2.1 → 2.2.3

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
@@ -41,8 +41,10 @@ var getNestedValueByKey = (obj, nestedKey) => nestedKey.split(".").reduce((acc,
41
41
  function handleNestedChange({
42
42
  state,
43
43
  id,
44
- value
44
+ value,
45
+ hasNestedValues = false
45
46
  }) {
47
+ if (!hasNestedValues) return { ...state, [id]: value };
46
48
  const propertyDepth = id.split("."), newValues = state;
47
49
  let current = newValues;
48
50
  for (let i = 0; i < propertyDepth.length - 1; i++) {
@@ -146,10 +148,10 @@ function useComponentLanguage() {
146
148
  function useValidation() {
147
149
  const { lang } = useComponentLanguage();
148
150
  const getValidation = (value, isTouched, types, errorMessages) => {
149
- const items = Object.entries(types), isRequired = items.map(([key]) => key).includes("required");
151
+ const items = Object.entries(types), isRequired = items.some(([key]) => key === "required");
150
152
  if (isRequired && !isTouched)
151
153
  return {
152
- isValid: false,
154
+ isValid: true,
153
155
  validationProps: nxError()
154
156
  };
155
157
  const validations = items.map(([name, opts]) => {
package/dist/index.mjs CHANGED
@@ -23,8 +23,10 @@ var getNestedValueByKey = (obj, nestedKey) => nestedKey.split(".").reduce((acc,
23
23
  function handleNestedChange({
24
24
  state,
25
25
  id,
26
- value
26
+ value,
27
+ hasNestedValues = false
27
28
  }) {
29
+ if (!hasNestedValues) return { ...state, [id]: value };
28
30
  const propertyDepth = id.split("."), newValues = state;
29
31
  let current = newValues;
30
32
  for (let i = 0; i < propertyDepth.length - 1; i++) {
@@ -128,10 +130,10 @@ function useComponentLanguage() {
128
130
  function useValidation() {
129
131
  const { lang } = useComponentLanguage();
130
132
  const getValidation = (value, isTouched, types, errorMessages) => {
131
- const items = Object.entries(types), isRequired = items.map(([key]) => key).includes("required");
133
+ const items = Object.entries(types), isRequired = items.some(([key]) => key === "required");
132
134
  if (isRequired && !isTouched)
133
135
  return {
134
- isValid: false,
136
+ isValid: true,
135
137
  validationProps: nxError()
136
138
  };
137
139
  const validations = items.map(([name, opts]) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juantroconisf/lib",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",