@evoke-platform/ui-components 1.8.0-testing.5 → 1.8.0-testing.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.
@@ -230,6 +230,10 @@ export const ObjectPropertyInput = (props) => {
230
230
  ? (options.find((o) => o.id === option)?.name ?? '')
231
231
  : option.label;
232
232
  }, onKeyDownCapture: (e) => {
233
+ // prevents keyboard trap
234
+ if (e.key === 'Tab') {
235
+ return;
236
+ }
233
237
  if (instance?.[property.id]?.id || selectedInstance?.id) {
234
238
  e.preventDefault();
235
239
  }
@@ -89,6 +89,10 @@ export const UserProperty = (props) => {
89
89
  }
90
90
  }
91
91
  }, onKeyDownCapture: (e) => {
92
+ // prevents keyboard trap
93
+ if (e.key === 'Tab') {
94
+ return;
95
+ }
92
96
  if (value) {
93
97
  e.preventDefault();
94
98
  }
@@ -489,49 +489,76 @@ export function flattenFormComponents(components) {
489
489
  export async function addObjectPropertiesToComponentProps(properties,
490
490
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
491
491
  formComponents, allCriteriaInputs, instance, objectPropertyInputProps, associatedObject, autoSave, readOnly, defaultPages, navigateTo, queryAddresses, apiServices, isModal, fieldHeight, richTextEditor) {
492
+ function removeEmptySections(component) {
493
+ // if a component is an entry to a property that the user doesn't have permission to view, remove it
494
+ if (component?.property?.id) {
495
+ const hasPermission = allProperties.some((p) => p.id === component.property.id);
496
+ if (!hasPermission)
497
+ return undefined;
498
+ }
499
+ // remove sections or tabs with no components
500
+ if (component.components) {
501
+ component.components = component.components
502
+ .map(removeEmptySections)
503
+ .filter((c) => c !== undefined);
504
+ if (component.components.length === 0)
505
+ return undefined;
506
+ }
507
+ // check columns for empty components or sections with no components
508
+ const actionInput = component;
509
+ if (actionInput.columns) {
510
+ const processedColumns = actionInput.columns.map((col) => ({
511
+ ...col,
512
+ components: (col.components || [])
513
+ .map(removeEmptySections)
514
+ .filter((c) => c !== undefined),
515
+ }));
516
+ actionInput.columns = processedColumns;
517
+ if (processedColumns.every((col) => col.components.length === 0)) {
518
+ return undefined;
519
+ }
520
+ }
521
+ return component;
522
+ }
523
+ const allProperties = properties.flatMap((property) => property.type === 'address'
524
+ ? [
525
+ {
526
+ id: `${property.id}.line1`,
527
+ name: `${property.name} Line 1`,
528
+ type: 'string',
529
+ },
530
+ {
531
+ id: `${property.id}.line2`,
532
+ name: `${property.name} Line 2`,
533
+ type: 'string',
534
+ },
535
+ {
536
+ id: `${property.id}.city`,
537
+ name: `${property.name} City`,
538
+ type: 'string',
539
+ },
540
+ {
541
+ id: `${property.id}.county`,
542
+ name: `${property.name} County`,
543
+ type: 'string',
544
+ },
545
+ {
546
+ id: `${property.id}.state`,
547
+ name: `${property.name} State`,
548
+ type: 'string',
549
+ },
550
+ {
551
+ id: `${property.id}.zipCode`,
552
+ name: `${property.name} Zip Code`,
553
+ type: 'string',
554
+ },
555
+ ]
556
+ : [property]);
492
557
  return [
493
558
  ...(await Promise.all(formComponents
494
559
  ?.filter((component) => !isUndefined(component) && !isNil(component))
495
560
  ?.map(async (component) => {
496
- const property = properties
497
- .flatMap((property) => {
498
- if (property.type === 'address') {
499
- return [
500
- {
501
- id: `${property.id}.line1`,
502
- name: `${property.name} Line 1`,
503
- type: 'string',
504
- },
505
- {
506
- id: `${property.id}.line2`,
507
- name: `${property.name} Line 2`,
508
- type: 'string',
509
- },
510
- {
511
- id: `${property.id}.city`,
512
- name: `${property.name} City`,
513
- type: 'string',
514
- },
515
- {
516
- id: `${property.id}.county`,
517
- name: `${property.name} County`,
518
- type: 'string',
519
- },
520
- {
521
- id: `${property.id}.state`,
522
- name: `${property.name} State`,
523
- type: 'string',
524
- },
525
- {
526
- id: `${property.id}.zipCode`,
527
- name: `${property.name} Zip Code`,
528
- type: 'string',
529
- },
530
- ];
531
- }
532
- return property;
533
- })
534
- .find((property) => property.id === component.key);
561
+ const property = allProperties.find((prop) => prop.id === component.key);
535
562
  const id = property?.id ?? component.key;
536
563
  if (component.type === 'Content') {
537
564
  return component;
@@ -543,7 +570,7 @@ formComponents, allCriteriaInputs, instance, objectPropertyInputProps, associate
543
570
  ? DateTime.now().toISODate()
544
571
  : DateTime.fromISO(component.initialValue).toISODate();
545
572
  }
546
- // @Deprecrated
573
+ // @Deprecated
547
574
  // This will overwrite the default value
548
575
  if (component.defaultToCurrentDate) {
549
576
  component.initialValue = DateTime.now().toISODate();
@@ -556,7 +583,7 @@ formComponents, allCriteriaInputs, instance, objectPropertyInputProps, associate
556
583
  ? DateTime.now().toISO()
557
584
  : DateTime.fromISO(component.initialValue).toISO();
558
585
  }
559
- // @Deprecrated
586
+ // @Deprecated
560
587
  // This will overwrite the default value
561
588
  if (component.defaultToCurrentDate) {
562
589
  component.initialValue = DateTime.now().toISO();
@@ -575,7 +602,7 @@ formComponents, allCriteriaInputs, instance, objectPropertyInputProps, associate
575
602
  suppressMilliseconds: true,
576
603
  });
577
604
  }
578
- // @Deprecrated
605
+ // @Deprecated
579
606
  // This will overwrite the default value
580
607
  if (component.defaultToCurrentTime) {
581
608
  component.initialValue = DateTime.now().toISOTime({
@@ -709,13 +736,16 @@ formComponents, allCriteriaInputs, instance, objectPropertyInputProps, associate
709
736
  : undefined,
710
737
  };
711
738
  }
712
- if (component.columns) {
739
+ else {
740
+ component = removeEmptySections(component);
741
+ }
742
+ if (component?.columns) {
713
743
  for (const column of component.columns) {
714
744
  column.components = await addObjectPropertiesToComponentProps(properties, column.components, allCriteriaInputs, instance, objectPropertyInputProps, associatedObject, autoSave, readOnly, undefined, undefined, queryAddresses, apiServices, isModal, fieldHeight, richTextEditor);
715
745
  }
716
746
  return component;
717
747
  }
718
- if (component.components) {
748
+ if (component?.components) {
719
749
  for (const item of component.components) {
720
750
  const nestedFieldProperty = properties.find((property) => property.id === item.key);
721
751
  if (item.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.8.0-testing.5",
3
+ "version": "1.8.0-testing.7",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",