@onehat/ui 0.2.5 → 0.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/package.json +1 -1
- package/src/Components/Form/Form.js +26 -20
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState, } from 'react';
|
|
1
|
+
import { useEffect, useState, isValidElement, } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
4
|
Button,
|
|
@@ -192,7 +192,12 @@ function Form(props) {
|
|
|
192
192
|
// Getting an error that the OrdersEditor is missing users__email.
|
|
193
193
|
// Why is this even on the OrdersEditor? Runner?
|
|
194
194
|
}
|
|
195
|
-
let element
|
|
195
|
+
let element;
|
|
196
|
+
if (isValidElement(Element)) {
|
|
197
|
+
element = Element;
|
|
198
|
+
debugger;
|
|
199
|
+
} else {
|
|
200
|
+
element = <Element
|
|
196
201
|
name={name}
|
|
197
202
|
value={value}
|
|
198
203
|
setValue={(newValue) => {
|
|
@@ -206,6 +211,7 @@ function Form(props) {
|
|
|
206
211
|
// {...defaults}
|
|
207
212
|
// {...propsToPass}
|
|
208
213
|
/>;
|
|
214
|
+
}
|
|
209
215
|
|
|
210
216
|
// element = <Tooltip key={ix} label={header} placement="bottom">
|
|
211
217
|
// {element}
|
|
@@ -251,7 +257,7 @@ function Form(props) {
|
|
|
251
257
|
type = t;
|
|
252
258
|
editorTypeProps = p;
|
|
253
259
|
}
|
|
254
|
-
if (type.match(/Combo$/) && Repository?.isRemote && !Repository?.isLoaded) {
|
|
260
|
+
if (type?.match && type.match(/Combo$/) && Repository?.isRemote && !Repository?.isLoaded) {
|
|
255
261
|
editorTypeProps.autoLoad = true;
|
|
256
262
|
}
|
|
257
263
|
const Element = getComponentFromType(type);
|
|
@@ -493,26 +499,26 @@ function disableRequiredYupFields(validator) {
|
|
|
493
499
|
return null;
|
|
494
500
|
}
|
|
495
501
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
502
|
+
const nextSchema = validator.clone();
|
|
503
|
+
return nextSchema.withMutation((next) => {
|
|
504
|
+
if (typeof next.fields === 'object' && next.fields != null) {
|
|
505
|
+
for (const key in next.fields) {
|
|
506
|
+
const nestedField = next.fields[key];
|
|
501
507
|
|
|
502
|
-
|
|
508
|
+
let nestedFieldNext = nestedField.notRequired();
|
|
503
509
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
510
|
+
if (Array.isArray(nestedField.conditions) && nestedField.conditions.length > 0) {
|
|
511
|
+
// Next is done to disable required() inside a condition
|
|
512
|
+
// https://github.com/jquense/yup/issues/1002
|
|
513
|
+
nestedFieldNext = nestedFieldNext.when('whatever', (unused, schema) => {
|
|
514
|
+
return schema.notRequired();
|
|
515
|
+
});
|
|
516
|
+
}
|
|
511
517
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
518
|
+
next.fields[key] = nestedFieldNext;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
});
|
|
516
522
|
}
|
|
517
523
|
function getNullFieldValues(initialValues, Repository) {
|
|
518
524
|
const ret = {};
|