@juantroconisf/lib 3.2.5 → 3.2.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 +5 -5
- package/dist/index.mjs +5 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -154,7 +154,7 @@ function useValidation() {
|
|
|
154
154
|
const { lang } = useComponentLanguage();
|
|
155
155
|
const getValidation = (value, isTouched, types, errorMessages) => {
|
|
156
156
|
if (!types) return { isValid: true, validationProps: nxError() };
|
|
157
|
-
const items = Object.entries(types),
|
|
157
|
+
const items = Object.entries(types), requiredExist = types?.required !== void 0, isRequired = requiredExist ? types.required : false;
|
|
158
158
|
if (value === "" && !isRequired || !isTouched)
|
|
159
159
|
return { isValid: true, validationProps: nxError() };
|
|
160
160
|
const validations = items.map(([name, opts]) => {
|
|
@@ -188,7 +188,7 @@ function useFormChange({
|
|
|
188
188
|
handleNestedChange({
|
|
189
189
|
state,
|
|
190
190
|
id,
|
|
191
|
-
value: typeof value === "string" ? value : Array.from(value)
|
|
191
|
+
value: typeof value === "string" || value === null ? value : Array.from(value)
|
|
192
192
|
})
|
|
193
193
|
);
|
|
194
194
|
const registerHandle = (0, import_react.useCallback)(
|
|
@@ -218,7 +218,7 @@ function useFormChange({
|
|
|
218
218
|
item.ref.current = handleNestedChange({
|
|
219
219
|
state: item.ref.current,
|
|
220
220
|
id,
|
|
221
|
-
value: req.isValid
|
|
221
|
+
value: !req.isValid
|
|
222
222
|
});
|
|
223
223
|
return req;
|
|
224
224
|
});
|
|
@@ -245,12 +245,12 @@ function useFormChange({
|
|
|
245
245
|
value: state[id]
|
|
246
246
|
}),
|
|
247
247
|
select: (id) => {
|
|
248
|
-
const isString = typeof state[id] === "string";
|
|
248
|
+
const isString = typeof state[id] === "string" || state[id] === null;
|
|
249
249
|
return {
|
|
250
250
|
...registerHandle(id),
|
|
251
251
|
onSelectionChange: (v) => onSelectionChange(
|
|
252
252
|
id,
|
|
253
|
-
|
|
253
|
+
!isString ? v : Array.from(v)[0] || null
|
|
254
254
|
),
|
|
255
255
|
selectedKeys: state[id] === null ? [] : isString ? [state[id]] : state[id]
|
|
256
256
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -135,7 +135,7 @@ function useValidation() {
|
|
|
135
135
|
const { lang } = useComponentLanguage();
|
|
136
136
|
const getValidation = (value, isTouched, types, errorMessages) => {
|
|
137
137
|
if (!types) return { isValid: true, validationProps: nxError() };
|
|
138
|
-
const items = Object.entries(types),
|
|
138
|
+
const items = Object.entries(types), requiredExist = types?.required !== void 0, isRequired = requiredExist ? types.required : false;
|
|
139
139
|
if (value === "" && !isRequired || !isTouched)
|
|
140
140
|
return { isValid: true, validationProps: nxError() };
|
|
141
141
|
const validations = items.map(([name, opts]) => {
|
|
@@ -169,7 +169,7 @@ function useFormChange({
|
|
|
169
169
|
handleNestedChange({
|
|
170
170
|
state,
|
|
171
171
|
id,
|
|
172
|
-
value: typeof value === "string" ? value : Array.from(value)
|
|
172
|
+
value: typeof value === "string" || value === null ? value : Array.from(value)
|
|
173
173
|
})
|
|
174
174
|
);
|
|
175
175
|
const registerHandle = useCallback(
|
|
@@ -199,7 +199,7 @@ function useFormChange({
|
|
|
199
199
|
item.ref.current = handleNestedChange({
|
|
200
200
|
state: item.ref.current,
|
|
201
201
|
id,
|
|
202
|
-
value: req.isValid
|
|
202
|
+
value: !req.isValid
|
|
203
203
|
});
|
|
204
204
|
return req;
|
|
205
205
|
});
|
|
@@ -226,12 +226,12 @@ function useFormChange({
|
|
|
226
226
|
value: state[id]
|
|
227
227
|
}),
|
|
228
228
|
select: (id) => {
|
|
229
|
-
const isString = typeof state[id] === "string";
|
|
229
|
+
const isString = typeof state[id] === "string" || state[id] === null;
|
|
230
230
|
return {
|
|
231
231
|
...registerHandle(id),
|
|
232
232
|
onSelectionChange: (v) => onSelectionChange(
|
|
233
233
|
id,
|
|
234
|
-
|
|
234
|
+
!isString ? v : Array.from(v)[0] || null
|
|
235
235
|
),
|
|
236
236
|
selectedKeys: state[id] === null ? [] : isString ? [state[id]] : state[id]
|
|
237
237
|
};
|