@abgov/jsonforms-components 2.42.1 → 2.42.2

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.
Files changed (2) hide show
  1. package/index.esm.js +81 -74
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -10154,7 +10154,7 @@ const Trash = styled.div(_t12 || (_t12 = _$3`
10154
10154
  const ListContainer = styled.div(_t13 || (_t13 = _$3`
10155
10155
  padding: 0 0 0 0;
10156
10156
  `));
10157
- const DetailMargin = styled.div(_t14 || (_t14 = _$3`
10157
+ styled.div(_t14 || (_t14 = _$3`
10158
10158
  padding: 0 0 var(--goa-space-l) 0;
10159
10159
  `));
10160
10160
  const IconPadding = styled.div(_t15 || (_t15 = _$3`
@@ -11526,17 +11526,24 @@ const MainTab = ({
11526
11526
  } = useJsonForms();
11527
11527
  const rowData = getDataAtPath(core === null || core === void 0 ? void 0 : core.data, childPath);
11528
11528
  const orderedRowData = orderRowData(rowData, (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.detail);
11529
- const rowErrors = (_b = core === null || core === void 0 ? void 0 : core.errors) === null || _b === void 0 ? void 0 : _b.filter(e => {
11530
- const base = `/${childPath.replace(/\./g, '/')}`;
11531
- return e.instancePath === base || e.instancePath.startsWith(base + '/');
11532
- }).filter(e => {
11533
- var _a;
11534
- return (((_a = e === null || e === void 0 ? void 0 : e.message) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0;
11535
- }).map(e => humanizeAjvError(e, core.schema, core.uischema)).map((msg, index, arr) => `${msg}${index < arr.length - 1 ? ', ' : ''}`);
11529
+ function resolveField(e) {
11530
+ if (e.keyword === 'required') {
11531
+ return e.params.missingProperty;
11532
+ }
11533
+ const path = e.instancePath.split('/');
11534
+ return path[path.length - 1];
11535
+ }
11536
+ const rowBase = `/${childPath.replace(/\./g, '/')}`;
11537
+ const fieldErrors = (_b = core === null || core === void 0 ? void 0 : core.errors) === null || _b === void 0 ? void 0 : _b.filter(e => e.instancePath === rowBase || e.instancePath.startsWith(rowBase + '/')).reduce((acc, e) => {
11538
+ const field = resolveField(e);
11539
+ acc[field] = humanizeAjvError(e, core.schema, core.uischema); //e.message;
11540
+ return acc;
11541
+ }, {});
11542
+ const errorText = fieldErrors && Object.values(fieldErrors).length > 0 ? Object.values(fieldErrors).join(', ') : undefined;
11536
11543
  return jsx("div", {
11537
11544
  "data-testid": `object-array-main-item-${rowIndex}`,
11538
- children: (rowErrors === null || rowErrors === void 0 ? void 0 : rowErrors.length) ? jsx(GoabFormItem, {
11539
- error: (rowErrors === null || rowErrors === void 0 ? void 0 : rowErrors.length) ? rowErrors : null,
11545
+ children: errorText ? jsx(GoabFormItem, {
11546
+ error: errorText,
11540
11547
  children: jsx(MainItemComponent, {
11541
11548
  rowData: orderedRowData,
11542
11549
  childPath: childPath,
@@ -11579,7 +11586,7 @@ const ObjectArrayList = ({
11579
11586
  listTitle,
11580
11587
  errors
11581
11588
  }) => {
11582
- var _a, _b;
11589
+ var _a, _b, _c, _d;
11583
11590
  const isEmptyList = data === 0;
11584
11591
  const rightRef = useRef(null);
11585
11592
  const current = rightRef.current;
@@ -11611,6 +11618,7 @@ const ObjectArrayList = ({
11611
11618
  const selectCurrentTab = index => {
11612
11619
  setCurrentIndex(index);
11613
11620
  };
11621
+ const continueButtonTitle = (_d = (_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.componentProps) === null || _d === void 0 ? void 0 : _d.listWithDetailsContinueButtonTitle;
11614
11622
  return jsx(ListContainer, {
11615
11623
  children: jsxs(RowFlex, {
11616
11624
  children: [currentListPage === 0 && jsx(FlexTabs, {
@@ -11628,7 +11636,8 @@ const ObjectArrayList = ({
11628
11636
  enabled: enabled,
11629
11637
  current: current,
11630
11638
  setCurrentListPage: index => setCurrentListPage(index),
11631
- uischema: uischema
11639
+ uischema: uischema,
11640
+ schema: schema
11632
11641
  }, childPath);
11633
11642
  })
11634
11643
  }), currentListPage > 0 && jsxs(UpdateListContainer, {
@@ -11655,7 +11664,7 @@ const ObjectArrayList = ({
11655
11664
  setCurrentListPage(0);
11656
11665
  },
11657
11666
  testId: "next-list-button",
11658
- children: "Continue"
11667
+ children: continueButtonTitle ? continueButtonTitle : 'Continue'
11659
11668
  })]
11660
11669
  })]
11661
11670
  })
@@ -11721,67 +11730,23 @@ class ListWithDetailControl extends React.Component {
11721
11730
  const controlElement = uischema;
11722
11731
  // eslint-disable-next-line
11723
11732
  const listTitle = (_e = (_d = (_c = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.label) !== null && _a !== void 0 ? _a : (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : getItemsTitle(schema)) !== null && _d !== void 0 ? _d : schema === null || schema === void 0 ? void 0 : schema.title) !== null && _e !== void 0 ? _e : label;
11724
- return jsx(Visible, {
11733
+ return jsxs(Visible, {
11725
11734
  visible: visible,
11726
11735
  "data-testid": "jsonforms-object-list-wrapper",
11727
- children: jsxs(DetailMargin, {
11728
- children: [jsxs(ToolBarHeader, {
11729
- children: [listTitle && this.state.currentListPage === 0 && jsx(MarginTop, {
11730
- children: jsxs(ObjectArrayTitle, {
11731
- children: [listTitle, " ", jsx("span", {
11732
- children: additionalProps.required && '(required)'
11733
- }), this.state.maxItemsError && jsx("span", {
11734
- style: {
11735
- color: 'red',
11736
- marginLeft: '1rem'
11737
- },
11738
- children: this.state.maxItemsError
11739
- })]
11740
- })
11741
- }), this.state.currentListPage === 0 && data === 0 && jsx(ObjectArrayToolBar, {
11742
- data: data,
11743
- errors: errors,
11744
- label: label,
11745
- addItem: (path, value) => () => {
11746
- this.addItem(path, value);
11747
- },
11748
- numColumns: 0,
11749
- path: path,
11750
- uischema: controlElement,
11751
- schema: schema,
11752
- rootSchema: rootSchema,
11753
- enabled: enabled,
11754
- setCurrentListPage: listPage => {
11755
- this.setState({
11756
- currentListPage: listPage
11757
- });
11758
- },
11759
- currentListPage: this.state.currentListPage,
11760
- buttonType: "secondary"
11761
- })]
11762
- }), jsx("div", {
11763
- children: jsx(ObjectArrayList, Object.assign({
11764
- path: path,
11765
- schema: schema,
11766
- uischema: uischema,
11767
- enabled: enabled,
11768
- openDeleteDialog: openDeleteDialog,
11769
- translations: {},
11770
- data: data,
11771
- cells: cells,
11772
- config: config,
11773
- currentIndex: this.props.currentTab,
11774
- setCurrentIndex: this.props.setCurrentTab,
11775
- setCurrentListPage: listPage => {
11776
- this.setState({
11777
- currentListPage: listPage
11778
- });
11779
- },
11780
- errors: errors,
11781
- currentListPage: this.state.currentListPage,
11782
- listTitle: listTitle
11783
- }, additionalProps))
11784
- }), this.state.currentListPage === 0 && data > 0 && jsx(ObjectArrayToolBar, {
11736
+ children: [jsxs(ToolBarHeader, {
11737
+ children: [listTitle && this.state.currentListPage === 0 && jsx(MarginTop, {
11738
+ children: jsxs(ObjectArrayTitle, {
11739
+ children: [listTitle, " ", jsx("span", {
11740
+ children: additionalProps.required && '(required)'
11741
+ }), this.state.maxItemsError && jsx("span", {
11742
+ style: {
11743
+ color: 'red',
11744
+ marginLeft: '1rem'
11745
+ },
11746
+ children: this.state.maxItemsError
11747
+ })]
11748
+ })
11749
+ }), this.state.currentListPage === 0 && data === 0 && jsx(ObjectArrayToolBar, {
11785
11750
  data: data,
11786
11751
  errors: errors,
11787
11752
  label: label,
@@ -11800,9 +11765,51 @@ class ListWithDetailControl extends React.Component {
11800
11765
  });
11801
11766
  },
11802
11767
  currentListPage: this.state.currentListPage,
11803
- buttonType: "tertiary"
11768
+ buttonType: "secondary"
11804
11769
  })]
11805
- })
11770
+ }), jsx("div", {
11771
+ children: jsx(ObjectArrayList, Object.assign({
11772
+ path: path,
11773
+ schema: schema,
11774
+ uischema: uischema,
11775
+ enabled: enabled,
11776
+ openDeleteDialog: openDeleteDialog,
11777
+ translations: {},
11778
+ data: data,
11779
+ cells: cells,
11780
+ config: config,
11781
+ currentIndex: this.props.currentTab,
11782
+ setCurrentIndex: this.props.setCurrentTab,
11783
+ setCurrentListPage: listPage => {
11784
+ this.setState({
11785
+ currentListPage: listPage
11786
+ });
11787
+ },
11788
+ errors: errors,
11789
+ currentListPage: this.state.currentListPage,
11790
+ listTitle: listTitle
11791
+ }, additionalProps))
11792
+ }), this.state.currentListPage === 0 && data > 0 && jsx(ObjectArrayToolBar, {
11793
+ data: data,
11794
+ errors: errors,
11795
+ label: label,
11796
+ addItem: (path, value) => () => {
11797
+ this.addItem(path, value);
11798
+ },
11799
+ numColumns: 0,
11800
+ path: path,
11801
+ uischema: controlElement,
11802
+ schema: schema,
11803
+ rootSchema: rootSchema,
11804
+ enabled: enabled,
11805
+ setCurrentListPage: listPage => {
11806
+ this.setState({
11807
+ currentListPage: listPage
11808
+ });
11809
+ },
11810
+ currentListPage: this.state.currentListPage,
11811
+ buttonType: "tertiary"
11812
+ })]
11806
11813
  });
11807
11814
  }
11808
11815
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.42.1",
3
+ "version": "2.42.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
6
6
  "repository": "https://github.com/GovAlta/adsp-monorepo",