@abgov/jsonforms-components 1.24.1 → 1.24.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 +18 -4
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -5845,7 +5845,7 @@ const ctxToNonEmptyCellProps = (ctx, ownProps) => {
5845
5845
  };
5846
5846
  };
5847
5847
  const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellComponent(props) {
5848
- var _a, _b, _c;
5848
+ var _a, _b;
5849
5849
  const {
5850
5850
  schema,
5851
5851
  errors,
@@ -5864,11 +5864,25 @@ const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellCompo
5864
5864
  const scopesNotInElements = propScopes.filter(scope => {
5865
5865
  return !scopesInElements.includes(scope);
5866
5866
  });
5867
+ /**
5868
+ * Get the first layout type in the elements for the object array and used it
5869
+ * as the default type, if none is provided.
5870
+ * @returns layout type
5871
+ */
5872
+ const getFirstLayoutType = () => {
5873
+ var _a, _b, _c, _d, _e, _f, _g, _h;
5874
+ let defaultType = 'VerticalLayout';
5875
+ if ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.defaultType) return (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.defaultType;
5876
+ if (((_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.detail) && ((_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.detail) === null || _e === void 0 ? void 0 : _e.elements) === null || _f === void 0 ? void 0 : _f.length) > 0) {
5877
+ defaultType = (_h = (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.detail) === null || _h === void 0 ? void 0 : _h.elements.at(0).type;
5878
+ }
5879
+ return defaultType;
5880
+ };
5867
5881
  /* Create default elements for scope not defined in the uischema
5868
5882
  * future work: merge the options
5869
5883
  */
5870
5884
  const uiSchemaElementsForNotDefined = {
5871
- type: ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.defaultType) || 'VerticalLayout',
5885
+ type: getFirstLayoutType(),
5872
5886
  elements: scopesNotInElements.map(scope => {
5873
5887
  return {
5874
5888
  type: 'Control',
@@ -5879,7 +5893,7 @@ const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellCompo
5879
5893
  return jsxs(Fragment, {
5880
5894
  children: [
5881
5895
  // eslint-disable-next-line
5882
- (_b = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _b === void 0 ? void 0 : _b.map(element => {
5896
+ (_a = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _a === void 0 ? void 0 : _a.map(element => {
5883
5897
  return jsx(JsonFormsDispatch, {
5884
5898
  "data-testid": `jsonforms-object-list-defined-elements-dispatch`,
5885
5899
  schema: schema,
@@ -5889,7 +5903,7 @@ const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellCompo
5889
5903
  renderers: renderers,
5890
5904
  cells: cells
5891
5905
  }, rowPath);
5892
- }), ((_c = uiSchemaElementsForNotDefined === null || uiSchemaElementsForNotDefined === void 0 ? void 0 : uiSchemaElementsForNotDefined.elements) === null || _c === void 0 ? void 0 : _c.length) > 0 && jsx(JsonFormsDispatch, {
5906
+ }), ((_b = uiSchemaElementsForNotDefined === null || uiSchemaElementsForNotDefined === void 0 ? void 0 : uiSchemaElementsForNotDefined.elements) === null || _b === void 0 ? void 0 : _b.length) > 0 && jsx(JsonFormsDispatch, {
5893
5907
  schema: schema,
5894
5908
  uischema: uiSchemaElementsForNotDefined,
5895
5909
  path: rowPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.24.1",
3
+ "version": "1.24.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",