@onehat/ui 0.3.199 → 0.3.200

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.3.199",
3
+ "version": "0.3.200",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -40,7 +40,9 @@ import Footer from '../Layout/Footer.js';
40
40
  import Label from '../Form/Label.js';
41
41
  import _ from 'lodash';
42
42
 
43
- const CONTAINER_THRESHOLD = 900;
43
+ const
44
+ ONE_COLUMN_THRESHOLD = 900, // only allow one column in form
45
+ STACK_ROW_THRESHOLD = 500; // stack field-row elements
44
46
 
45
47
  // TODO: memoize field Components
46
48
 
@@ -367,7 +369,7 @@ function Form(props) {
367
369
  return null;
368
370
  }
369
371
  if (type === 'Column') {
370
- if (containerWidth < CONTAINER_THRESHOLD) {
372
+ if (containerWidth < ONE_COLUMN_THRESHOLD) {
371
373
  // everything is in one column
372
374
  if (propsToPass.hasOwnProperty('flex')) {
373
375
  delete propsToPass.flex;
@@ -420,7 +422,7 @@ function Form(props) {
420
422
  if (defaults?.labelWidth) {
421
423
  labelProps.w = defaults.labelWidth;
422
424
  }
423
- if (containerWidth > 400) {
425
+ if (containerWidth > STACK_ROW_THRESHOLD) {
424
426
  element = <><Label {...labelProps}>{label}</Label>{element}</>;
425
427
  } else {
426
428
  element = <Column><Label {...labelProps}>{label}</Label>{element}</Column>;
@@ -530,7 +532,7 @@ function Form(props) {
530
532
 
531
533
  if (item.additionalEditButtons) {
532
534
  const buttons = buildAdditionalButtons(item.additionalEditButtons, self, { fieldState, formSetValue, formGetValues, formState });
533
- if (containerWidth > 400) {
535
+ if (containerWidth > STACK_ROW_THRESHOLD) {
534
536
  element = <Row flex={1} flexWrap="wrap">
535
537
  {element}
536
538
  {buttons}
@@ -566,7 +568,7 @@ function Form(props) {
566
568
  if (defaults?.labelWidth) {
567
569
  labelProps.w = defaults.labelWidth;
568
570
  }
569
- if (containerWidth > 400) {
571
+ if (containerWidth > STACK_ROW_THRESHOLD) {
570
572
  element = <Row w="100%" py={1}>
571
573
  <Label {...labelProps}>{requiredIndicator}{label}</Label>
572
574
  {element}
@@ -784,8 +786,8 @@ function Form(props) {
784
786
  formComponents = buildFromItems();
785
787
  const formAncillaryComponents = buildAncillary();
786
788
  editor = <>
787
- {containerWidth >= CONTAINER_THRESHOLD ? <Row p={4} pl={0}>{formComponents}</Row> : null}
788
- {containerWidth < CONTAINER_THRESHOLD ? <Column p={4}>{formComponents}</Column> : null}
789
+ {containerWidth >= ONE_COLUMN_THRESHOLD ? <Row p={4} pl={0}>{formComponents}</Row> : null}
790
+ {containerWidth < ONE_COLUMN_THRESHOLD ? <Column p={4}>{formComponents}</Column> : null}
789
791
  <Column m={2} pt={4} px={2}>{formAncillaryComponents}</Column>
790
792
  </>;
791
793