@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/ui",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -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 = <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
- // const nextSchema = validator.clone();
497
- // return nextSchema.withMutation((next) => {
498
- // if (typeof next.fields === 'object' && next.fields != null) {
499
- // for (const key in next.fields) {
500
- // const nestedField = next.fields[key];
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
- // let nestedFieldNext = nestedField.notRequired();
508
+ let nestedFieldNext = nestedField.notRequired();
503
509
 
504
- // if (Array.isArray(nestedField.conditions) && nestedField.conditions.length > 0) {
505
- // // Next is done to disable required() inside a condition
506
- // // https://github.com/jquense/yup/issues/1002
507
- // nestedFieldNext = nestedFieldNext.when('whatever', (_: unknown, schema: yup.AnySchema) =>
508
- // schema.notRequired(),
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
- // next.fields[key] = nestedFieldNext;
513
- // }
514
- // }
515
- // });
518
+ next.fields[key] = nestedFieldNext;
519
+ }
520
+ }
521
+ });
516
522
  }
517
523
  function getNullFieldValues(initialValues, Repository) {
518
524
  const ret = {};