@abgov/jsonforms-components 2.67.7 → 2.67.8

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/index.esm.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import React, { useContext, useReducer, useMemo, useEffect, createContext, useCallback, useRef, useState, useLayoutEffect } from 'react';
3
- import { GoabFormItem, GoabDropdown, GoabDropdownItem, GoabInput, GoabTextArea, GoabCallout, GoabRadioGroup, GoabRadioItem, GoabCheckbox, GoabIcon, GoabButton, GoabGrid, GoabIconButton, GoabTable, GoabModal, GoabButtonGroup, GoabContainer, GoabDetails, GoabFormStepper, GoabFormStep, GoabPages, GoabBadge, GoabText, GoabFileUploadInput, GoabCircularProgress, GoabSpinner } from '@abgov/react-components';
3
+ import { GoabFormItem, GoabDropdown, GoabDropdownItem, GoabInput, GoabTextArea, GoabCallout, GoabRadioGroup, GoabRadioItem, GoabCheckbox, GoabIcon, GoabButton, GoabTable, GoabGrid, GoabIconButton, GoabModal, GoabButtonGroup, GoabContainer, GoabDetails, GoabFormStepper, GoabFormStep, GoabPages, GoabBadge, GoabText, GoabFileUploadInput, GoabCircularProgress, GoabSpinner } from '@abgov/react-components';
4
4
  import Ajv from 'ajv';
5
5
  import styled from 'styled-components';
6
6
  import axios from 'axios';
7
7
  import get$1 from 'lodash/get';
8
8
  import { isVisible, isEnabled, deriveLabelForUISchemaElement, rankWith, isStringControl, and, optionIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, uiTypeIs, isControl as isControl$1, isEnumControl, or, isOneOfEnumControl, isBooleanControl, createDefaultValue, Paths, Resolve, toDataPath, schemaTypeIs, formatIs, getAjv, schemaMatches, isObjectArrayControl, isPrimitiveArrayControl, composePaths, hasType, isCategorization, isLayout, INIT, UPDATE_CORE } from '@jsonforms/core';
9
9
  import * as _$c from 'lodash';
10
- import ___default, { isObject as isObject$i, isEmpty as isEmpty$1 } from 'lodash';
10
+ import ___default, { isEmpty, isObject as isObject$i } from 'lodash';
11
11
  import { useJsonForms, withJsonFormsControlProps, withJsonFormsEnumProps, withTranslateProps, JsonFormsDispatch, withJsonFormsAllOfProps, withJsonFormsArrayLayoutProps, withJsonFormsLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
12
12
  import dompurify from 'dompurify';
13
13
  import * as xss from 'xss';
14
14
  import merge from 'lodash/merge';
15
- import isEmpty from 'lodash/isEmpty';
15
+ import isEmpty$1 from 'lodash/isEmpty';
16
16
  import range from 'lodash/range';
17
17
  import pluralize from 'pluralize';
18
18
  import { compileSync } from '@mdx-js/mdx';
@@ -7270,6 +7270,16 @@ const ADDRESS_LOOKUP_LABELS = {
7270
7270
  subdivisionCode: 'Province',
7271
7271
  country: 'Country'
7272
7272
  };
7273
+ const VALIDATION_KEYWORDS = {
7274
+ REQUIRED: 'required',
7275
+ MIN_LENGTH: 'minLength',
7276
+ MAX_LENGTH: 'maxLength',
7277
+ FORMAT: 'format',
7278
+ MINIMUM: 'minimum',
7279
+ MAXIMUM: 'maximum',
7280
+ TYPE: 'type',
7281
+ ERROR_MESSAGE: 'errorMessage'
7282
+ };
7273
7283
  const getAddressLookupFieldLabel = fieldName => {
7274
7284
  return ADDRESS_LOOKUP_LABELS[fieldName] || fieldName;
7275
7285
  };
@@ -9109,6 +9119,195 @@ const ObjectArrayToolBar = /*#__PURE__*/React.memo(function TableToolbar({
9109
9119
  });
9110
9120
  });
9111
9121
 
9122
+ const jsonPreviewStyle = {
9123
+ display: 'block',
9124
+ width: '100%',
9125
+ boxSizing: 'border-box',
9126
+ margin: 0,
9127
+ padding: 0,
9128
+ whiteSpace: 'pre-wrap',
9129
+ textAlign: 'left',
9130
+ overflowX: 'auto'
9131
+ };
9132
+ function prettify(prop) {
9133
+ return prop.replace(/([A-Z])/g, ' $1').replace(/[_-]/g, ' ').replace(/^./, c => c.toUpperCase()).trim();
9134
+ }
9135
+ /**
9136
+ * Extract Json data schema name attribute and the ui schema label name.
9137
+ * @param obj
9138
+ * @param names
9139
+ * @returns A key value of the data attribute name and the uiSchema label value
9140
+ */
9141
+ const extractNames = (obj, names = {}) => {
9142
+ if (Array.isArray(obj)) {
9143
+ obj.forEach(item => extractNames(item, names));
9144
+ } else if (typeof obj === 'object' && obj !== null) {
9145
+ const typedObj = obj;
9146
+ if (typeof typedObj.scope === 'string') {
9147
+ const parts = typedObj.scope.split('/');
9148
+ const key = parts[parts.length - 1];
9149
+ if (typeof typedObj.label === 'string' && typedObj.label.trim()) {
9150
+ names[key] = typedObj.label;
9151
+ } else if (typeof typedObj.label === 'object' && typedObj.label !== null && 'text' in typedObj.label && typeof typedObj.label.text === 'string' && typedObj.label.text.trim()) {
9152
+ names[key] = typedObj.label.text;
9153
+ } else {
9154
+ names[key] = prettify(key);
9155
+ }
9156
+ }
9157
+ Object.values(typedObj).forEach(value => extractNames(value, names));
9158
+ }
9159
+ return names;
9160
+ };
9161
+ function getHeaderLabel(headName, itemsSchema, columnLabels) {
9162
+ if (columnLabels != null && columnLabels[headName]) {
9163
+ return columnLabels[headName];
9164
+ }
9165
+ const fieldSchema = itemsSchema == null ? void 0 : itemsSchema[headName];
9166
+ if (fieldSchema && typeof fieldSchema.title === 'string' && fieldSchema.title.trim()) {
9167
+ return fieldSchema.title;
9168
+ }
9169
+ return prettify(headName);
9170
+ }
9171
+ const DataTable = ({
9172
+ itemsSchema,
9173
+ data,
9174
+ columnLabels
9175
+ }) => {
9176
+ var _Object$keys;
9177
+ return jsxs(GoabTable, {
9178
+ width: "100%",
9179
+ children: [jsx("thead", {
9180
+ children: jsx("tr", {
9181
+ children: itemsSchema && ((_Object$keys = Object.keys(itemsSchema)) == null ? void 0 : _Object$keys.map((headNames, ix) => {
9182
+ return jsx("th", {
9183
+ children: getHeaderLabel(headNames, itemsSchema, columnLabels)
9184
+ }, ix);
9185
+ }))
9186
+ })
9187
+ }), jsx("tbody", {
9188
+ children: data.map((obj, index) => jsx("tr", {
9189
+ children: itemsSchema && Object.keys(itemsSchema).map((headNames, ix) => {
9190
+ return jsx("td", {
9191
+ children: obj[headNames]
9192
+ }, ix);
9193
+ })
9194
+ }, index))
9195
+ })]
9196
+ });
9197
+ };
9198
+ const isObjectArrayEmpty = currentData => {
9199
+ const result = isEmpty(currentData) || JSON.stringify(currentData) === '[{}]';
9200
+ return result;
9201
+ };
9202
+ const renderNoneGivenText = data => {
9203
+ return !data ? jsxs(Fragment, {
9204
+ children: [jsx(NoneGivenTableText, {
9205
+ children: "(none given)"
9206
+ }), jsx("br", {})]
9207
+ }) : data;
9208
+ };
9209
+ const renderCellColumn = ({
9210
+ data,
9211
+ error,
9212
+ errors,
9213
+ index,
9214
+ rowPath,
9215
+ element,
9216
+ isRequired
9217
+ }) => {
9218
+ const renderWarningCell = error => {
9219
+ return jsxs(HilightCellWarning, {
9220
+ children: [renderNoneGivenText(data), error && jsxs(ObjectArrayWarningIconDiv, {
9221
+ children: [jsx(GoabIcon, {
9222
+ type: "warning",
9223
+ title: "warning",
9224
+ size: "small",
9225
+ theme: "filled",
9226
+ mt: "2xs"
9227
+ }), error ? error : '']
9228
+ })]
9229
+ });
9230
+ };
9231
+ if (data === undefined && isRequired || error !== '' && error !== undefined) {
9232
+ const message = error || (isRequired && data === undefined ? 'Required' : data);
9233
+ return renderWarningCell(message);
9234
+ } else if (data === undefined && !isRequired) {
9235
+ return renderWarningCell('');
9236
+ } else if (data !== undefined && isRequired && error) {
9237
+ return renderWarningCell(error);
9238
+ }
9239
+ const path = `/${rowPath}/${index}/${element}/${index === 0 ? index : index - 1}`;
9240
+ const nestedErrors = errors == null ? void 0 : errors.filter(e => e.instancePath.includes(path));
9241
+ /* istanbul ignore next */
9242
+ if (typeof data === 'boolean') {
9243
+ return data ? 'Yes' : 'No';
9244
+ } else if (typeof data === 'number') {
9245
+ return String(data);
9246
+ } else if (typeof data === 'string') {
9247
+ return data;
9248
+ } else if (typeof data === 'object' || Array.isArray(data)) {
9249
+ const result = Object.keys(data);
9250
+ if (!isRequired && nestedErrors.length === 0) {
9251
+ if ('year' in data && 'month' in data && ('day' in data || 'date' in data)) {
9252
+ const dateObj = data;
9253
+ const dayValue = 'day' in dateObj ? dateObj.day : dateObj.date;
9254
+ return `${dateObj.year}-${dateObj.month}-${dayValue}`;
9255
+ }
9256
+ return jsx("pre", {
9257
+ style: jsonPreviewStyle,
9258
+ children: JSON.stringify(data, null, 2)
9259
+ });
9260
+ } else if (result.length === 0) {
9261
+ return renderWarningCell();
9262
+ } else if (result.length > 0 && (isObjectArrayEmpty(data) || nestedErrors.length > 0)) {
9263
+ return jsx("pre", {
9264
+ style: jsonPreviewStyle,
9265
+ children: renderWarningCell(JSON.stringify(data, null, 2))
9266
+ });
9267
+ } else if (data !== undefined && result.length > 0 && error !== '' && error !== undefined) {
9268
+ const values = Object.values(data);
9269
+ if (values && values.length > 0) {
9270
+ return jsx("pre", {
9271
+ style: jsonPreviewStyle,
9272
+ children: renderWarningCell(JSON.stringify(values.at(0), null, 2))
9273
+ });
9274
+ }
9275
+ } else {
9276
+ const firstRow = Array.isArray(data) ? data[0] : undefined;
9277
+ const columnLabels = extractNames(firstRow);
9278
+ return jsx(DataTable, {
9279
+ itemsSchema: data[0],
9280
+ data: data,
9281
+ columnLabels: columnLabels
9282
+ });
9283
+ }
9284
+ }
9285
+ return null;
9286
+ };
9287
+ const createHumanizeError = (error, schema, uischema) => {
9288
+ let humanMessage;
9289
+ if (error) {
9290
+ try {
9291
+ humanMessage = humanizeAjvError(error, schema, uischema);
9292
+ if (typeof humanMessage === 'string' && (humanMessage.includes('must have required property') || humanMessage.includes(REQUIRED_PROPERTY_ERROR))) {
9293
+ const propertyMatch = humanMessage.match(/'([^']+)'/);
9294
+ if (propertyMatch && propertyMatch[1]) {
9295
+ humanMessage = prettify(propertyMatch[1]) + ' is required';
9296
+ }
9297
+ }
9298
+ } catch (err) {
9299
+ const raw = error.message;
9300
+ const propertyMatch = raw == null ? void 0 : raw.match(/'([^']+)'/);
9301
+ if (propertyMatch && propertyMatch[1]) {
9302
+ humanMessage = prettify(propertyMatch[1]) + ' is required';
9303
+ } else {
9304
+ humanMessage = raw;
9305
+ }
9306
+ }
9307
+ }
9308
+ return humanMessage;
9309
+ };
9310
+
9112
9311
  const _excluded$5 = ["label", "path", "schema", "rootSchema", "uischema", "errors", "openDeleteDialog", "visible", "enabled", "cells", "data", "config"];
9113
9312
  const getItemsTitle = schema => {
9114
9313
  const items = schema == null ? void 0 : schema.items;
@@ -9244,12 +9443,10 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
9244
9443
  var _uischema$elements3, _uischema$options0, _uiSchemaElementsForN;
9245
9444
  const {
9246
9445
  schema,
9247
- errors,
9248
9446
  enabled,
9249
9447
  renderers,
9250
9448
  cells,
9251
9449
  rowPath,
9252
- isValid,
9253
9450
  uischema
9254
9451
  } = props;
9255
9452
  const propNames = getValidColumnProps$1(schema);
@@ -9328,7 +9525,7 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
9328
9525
  const NonEmptyCell$1 = ownProps => {
9329
9526
  const ctx = useJsonForms();
9330
9527
  const emptyCellProps = ctxToNonEmptyCellProps$1(ctx, ownProps);
9331
- const isValid = isEmpty(emptyCellProps.errors);
9528
+ const isValid = isEmpty$1(emptyCellProps.errors);
9332
9529
  return jsx(NonEmptyCellComponent$1, Object.assign({}, emptyCellProps, {
9333
9530
  isValid: isValid
9334
9531
  }));
@@ -9377,12 +9574,9 @@ function getValue(obj, path) {
9377
9574
  return undefined;
9378
9575
  }, obj);
9379
9576
  }
9380
- function prettify$1(prop) {
9381
- return prop.replace(/([A-Z])/g, ' $1').replace(/[_-]/g, ' ').replace(/^./, c => c.toUpperCase());
9382
- }
9383
9577
  function findLabelForPath(path, uiSchema, schema) {
9384
9578
  const propertyKey = path.split('.').pop() || path;
9385
- const fallbackLabel = prettify$1(propertyKey);
9579
+ const fallbackLabel = prettify(propertyKey);
9386
9580
  if (!uiSchema) {
9387
9581
  return fallbackLabel;
9388
9582
  }
@@ -9573,7 +9767,7 @@ function resolveLabel(instancePath, schema, uischema) {
9573
9767
  if (resolvedSchema != null && resolvedSchema.title) {
9574
9768
  return resolvedSchema.title;
9575
9769
  }
9576
- return prettify$1(prop || 'Unknown field');
9770
+ return prettify(prop || 'Unknown field');
9577
9771
  }
9578
9772
  function ajvPathToSchemaPath(instancePath) {
9579
9773
  const parts = instancePath.split('/').filter(Boolean);
@@ -9604,15 +9798,6 @@ function findControlLabel(uischema, scope) {
9604
9798
  }
9605
9799
  return;
9606
9800
  }
9607
- const VALIDATION_KEYWORDS = {
9608
- REQUIRED: 'required',
9609
- MIN_LENGTH: 'minLength',
9610
- MAX_LENGTH: 'maxLength',
9611
- FORMAT: 'format',
9612
- MINIMUM: 'minimum',
9613
- MAXIMUM: 'maximum',
9614
- TYPE: 'type'
9615
- };
9616
9801
  function humanizeAjvError(error, schema, uischema) {
9617
9802
  var _error$message;
9618
9803
  const path = getEffectiveInstancePath(error);
@@ -9729,9 +9914,9 @@ const MainTab = ({
9729
9914
  const rowData = getDataAtPath(core == null ? void 0 : core.data, childPath);
9730
9915
  function resolveField(e) {
9731
9916
  var _e$params;
9732
- if (e.keyword === 'required') {
9917
+ if (e.keyword === VALIDATION_KEYWORDS.REQUIRED) {
9733
9918
  return e.params.missingProperty;
9734
- } else if (e.keyword === 'errorMessage' && (_e$params = e.params) != null && _e$params.errors[0].params.missingProperty) {
9919
+ } else if (e.keyword === VALIDATION_KEYWORDS.ERROR_MESSAGE && (_e$params = e.params) != null && _e$params.errors[0].params.missingProperty) {
9735
9920
  return e.params.errors[0].params.missingProperty;
9736
9921
  }
9737
9922
  const path = e.instancePath.split('/');
@@ -9741,22 +9926,22 @@ const MainTab = ({
9741
9926
  const fieldErrors = core == null || (_core$errors = core.errors) == null ? void 0 : _core$errors.filter(e => e.instancePath === rowBase || e.instancePath.startsWith(rowBase + '/')).reduce((acc, e) => {
9742
9927
  var _e$params2;
9743
9928
  const field = resolveField(e);
9744
- if (e.keyword === 'errorMessage' && (_e$params2 = e.params) != null && _e$params2.errors) {
9929
+ if (e.keyword === VALIDATION_KEYWORDS.ERROR_MESSAGE && (_e$params2 = e.params) != null && _e$params2.errors) {
9745
9930
  const nestedErrors = e.params.errors;
9746
9931
  if (field) {
9747
9932
  try {
9748
- acc.fields[field] = nestedErrors.map(ne => humanizeAjvError(ne, core.schema, core.uischema)).join(', ');
9933
+ acc.fields[field] = e.message ? e.message : nestedErrors.map(ne => humanizeAjvError(ne, core.schema, core.uischema)).join(', ');
9749
9934
  } catch (err) {
9750
9935
  var _nestedErrors$;
9751
9936
  // Fallback: if nestedErrors contain a missingProperty, use it
9752
9937
  const missingFromNested = nestedErrors == null || (_nestedErrors$ = nestedErrors[0]) == null || (_nestedErrors$ = _nestedErrors$.params) == null ? void 0 : _nestedErrors$.missingProperty;
9753
9938
  if (missingFromNested) {
9754
- acc.fields[field] = prettify$1(missingFromNested) + ' is required';
9939
+ acc.fields[field] = prettify(missingFromNested) + ' is required';
9755
9940
  } else {
9756
9941
  const raw = e.message;
9757
9942
  if (raw && (raw.includes('must have required property') || raw.includes(REQUIRED_PROPERTY_ERROR))) {
9758
9943
  const m = raw.match(/'([^']+)'/);
9759
- if (m && m[1]) acc.fields[field] = prettify$1(m[1]) + ' is required';else acc.fields[field] = raw;
9944
+ if (m && m[1]) acc.fields[field] = prettify(m[1]) + ' is required';else acc.fields[field] = raw;
9760
9945
  } else {
9761
9946
  acc.fields[field] = raw || 'Unknown error';
9762
9947
  }
@@ -9769,12 +9954,12 @@ const MainTab = ({
9769
9954
  var _nestedErrors$2;
9770
9955
  const missingFromNested = nestedErrors == null || (_nestedErrors$2 = nestedErrors[0]) == null || (_nestedErrors$2 = _nestedErrors$2.params) == null ? void 0 : _nestedErrors$2.missingProperty;
9771
9956
  if (missingFromNested) {
9772
- acc.row = prettify$1(missingFromNested) + ' is required';
9957
+ acc.row = prettify(missingFromNested) + ' is required';
9773
9958
  } else {
9774
9959
  const raw = e == null ? void 0 : e.message;
9775
9960
  if (raw && (raw.includes('must have required property') || raw.includes(REQUIRED_PROPERTY_ERROR))) {
9776
9961
  const m = raw.match(/'([^']+)'/);
9777
- if (m && m[1]) acc.row = prettify$1(m[1]) + ' is required';else acc.row = raw;
9962
+ if (m && m[1]) acc.row = prettify(m[1]) + ' is required';else acc.row = raw;
9778
9963
  } else {
9779
9964
  acc.row = raw || 'Unknown error';
9780
9965
  }
@@ -9788,7 +9973,7 @@ const MainTab = ({
9788
9973
  if (typeof msg === 'string' && (msg.includes('must have required property') || msg.includes(REQUIRED_PROPERTY_ERROR))) {
9789
9974
  const propertyMatch = msg.match(/'([^']+)'/);
9790
9975
  if (propertyMatch && propertyMatch[1]) {
9791
- msg = prettify$1(propertyMatch[1]) + ' is required';
9976
+ msg = prettify(propertyMatch[1]) + ' is required';
9792
9977
  }
9793
9978
  }
9794
9979
  acc.fields[field] = msg;
@@ -10604,7 +10789,7 @@ const LayoutRenderer = ({
10604
10789
  visible,
10605
10790
  width
10606
10791
  }) => {
10607
- if (isEmpty(elements)) {
10792
+ if (isEmpty$1(elements)) {
10608
10793
  return null;
10609
10794
  } else {
10610
10795
  if (direction === 'row') {
@@ -10634,7 +10819,7 @@ const ReviewLayoutRenderer = ({
10634
10819
  visible,
10635
10820
  width
10636
10821
  }) => {
10637
- if (isEmpty(elements)) {
10822
+ if (isEmpty$1(elements)) {
10638
10823
  return null;
10639
10824
  } else {
10640
10825
  if (direction === 'row') {
@@ -11941,195 +12126,6 @@ const DeleteDialog = /*#__PURE__*/React.memo(function DeleteDialog({
11941
12126
  }, 1);
11942
12127
  });
11943
12128
 
11944
- const jsonPreviewStyle = {
11945
- display: 'block',
11946
- width: '100%',
11947
- boxSizing: 'border-box',
11948
- margin: 0,
11949
- padding: 0,
11950
- whiteSpace: 'pre-wrap',
11951
- textAlign: 'left',
11952
- overflowX: 'auto'
11953
- };
11954
- function prettify(prop) {
11955
- return prop.replace(/([A-Z])/g, ' $1').replace(/[_-]/g, ' ').replace(/^./, c => c.toUpperCase()).trim();
11956
- }
11957
- /**
11958
- * Extract Json data schema name attribute and the ui schema label name.
11959
- * @param obj
11960
- * @param names
11961
- * @returns A key value of the data attribute name and the uiSchema label value
11962
- */
11963
- const extractNames = (obj, names = {}) => {
11964
- if (Array.isArray(obj)) {
11965
- obj.forEach(item => extractNames(item, names));
11966
- } else if (typeof obj === 'object' && obj !== null) {
11967
- const typedObj = obj;
11968
- if (typeof typedObj.scope === 'string') {
11969
- const parts = typedObj.scope.split('/');
11970
- const key = parts[parts.length - 1];
11971
- if (typeof typedObj.label === 'string' && typedObj.label.trim()) {
11972
- names[key] = typedObj.label;
11973
- } else if (typeof typedObj.label === 'object' && typedObj.label !== null && 'text' in typedObj.label && typeof typedObj.label.text === 'string' && typedObj.label.text.trim()) {
11974
- names[key] = typedObj.label.text;
11975
- } else {
11976
- names[key] = prettify(key);
11977
- }
11978
- }
11979
- Object.values(typedObj).forEach(value => extractNames(value, names));
11980
- }
11981
- return names;
11982
- };
11983
- function getHeaderLabel(headName, itemsSchema, columnLabels) {
11984
- if (columnLabels != null && columnLabels[headName]) {
11985
- return columnLabels[headName];
11986
- }
11987
- const fieldSchema = itemsSchema == null ? void 0 : itemsSchema[headName];
11988
- if (fieldSchema && typeof fieldSchema.title === 'string' && fieldSchema.title.trim()) {
11989
- return fieldSchema.title;
11990
- }
11991
- return prettify(headName);
11992
- }
11993
- const DataTable = ({
11994
- itemsSchema,
11995
- data,
11996
- columnLabels
11997
- }) => {
11998
- var _Object$keys;
11999
- return jsxs(GoabTable, {
12000
- width: "100%",
12001
- children: [jsx("thead", {
12002
- children: jsx("tr", {
12003
- children: itemsSchema && ((_Object$keys = Object.keys(itemsSchema)) == null ? void 0 : _Object$keys.map((headNames, ix) => {
12004
- return jsx("th", {
12005
- children: getHeaderLabel(headNames, itemsSchema, columnLabels)
12006
- }, ix);
12007
- }))
12008
- })
12009
- }), jsx("tbody", {
12010
- children: data.map((obj, index) => jsx("tr", {
12011
- children: itemsSchema && Object.keys(itemsSchema).map((headNames, ix) => {
12012
- return jsx("td", {
12013
- children: obj[headNames]
12014
- }, ix);
12015
- })
12016
- }, index))
12017
- })]
12018
- });
12019
- };
12020
- const isObjectArrayEmpty = currentData => {
12021
- const result = isEmpty$1(currentData) || JSON.stringify(currentData) === '[{}]';
12022
- return result;
12023
- };
12024
- const renderNoneGivenText = data => {
12025
- return !data ? jsxs(Fragment, {
12026
- children: [jsx(NoneGivenTableText, {
12027
- children: "(none given)"
12028
- }), jsx("br", {})]
12029
- }) : data;
12030
- };
12031
- const renderCellColumn = ({
12032
- data,
12033
- error,
12034
- errors,
12035
- index,
12036
- rowPath,
12037
- element,
12038
- isRequired
12039
- }) => {
12040
- const renderWarningCell = error => {
12041
- return jsxs(HilightCellWarning, {
12042
- children: [renderNoneGivenText(data), error && jsxs(ObjectArrayWarningIconDiv, {
12043
- children: [jsx(GoabIcon, {
12044
- type: "warning",
12045
- title: "warning",
12046
- size: "small",
12047
- theme: "filled",
12048
- mt: "2xs"
12049
- }), error ? error : '']
12050
- })]
12051
- });
12052
- };
12053
- if (data === undefined && isRequired || error !== '' && error !== undefined) {
12054
- const message = error || (isRequired && data === undefined ? 'Required' : data);
12055
- return renderWarningCell(message);
12056
- } else if (data === undefined && !isRequired) {
12057
- return renderWarningCell('');
12058
- } else if (data !== undefined && isRequired && error) {
12059
- return renderWarningCell(error);
12060
- }
12061
- const path = `/${rowPath}/${index}/${element}/${index === 0 ? index : index - 1}`;
12062
- const nestedErrors = errors == null ? void 0 : errors.filter(e => e.instancePath.includes(path));
12063
- /* istanbul ignore next */
12064
- if (typeof data === 'boolean') {
12065
- return data ? 'Yes' : 'No';
12066
- } else if (typeof data === 'number') {
12067
- return String(data);
12068
- } else if (typeof data === 'string') {
12069
- return data;
12070
- } else if (typeof data === 'object' || Array.isArray(data)) {
12071
- const result = Object.keys(data);
12072
- if (!isRequired && nestedErrors.length === 0) {
12073
- if ('year' in data && 'month' in data && ('day' in data || 'date' in data)) {
12074
- const dateObj = data;
12075
- const dayValue = 'day' in dateObj ? dateObj.day : dateObj.date;
12076
- return `${dateObj.year}-${dateObj.month}-${dayValue}`;
12077
- }
12078
- return jsx("pre", {
12079
- style: jsonPreviewStyle,
12080
- children: JSON.stringify(data, null, 2)
12081
- });
12082
- } else if (result.length === 0) {
12083
- return renderWarningCell();
12084
- } else if (result.length > 0 && (isObjectArrayEmpty(data) || nestedErrors.length > 0)) {
12085
- return jsx("pre", {
12086
- style: jsonPreviewStyle,
12087
- children: renderWarningCell(JSON.stringify(data, null, 2))
12088
- });
12089
- } else if (data !== undefined && result.length > 0 && error !== '' && error !== undefined) {
12090
- const values = Object.values(data);
12091
- if (values && values.length > 0) {
12092
- return jsx("pre", {
12093
- style: jsonPreviewStyle,
12094
- children: renderWarningCell(JSON.stringify(values.at(0), null, 2))
12095
- });
12096
- }
12097
- } else {
12098
- const firstRow = Array.isArray(data) ? data[0] : undefined;
12099
- const columnLabels = extractNames(firstRow);
12100
- return jsx(DataTable, {
12101
- itemsSchema: data[0],
12102
- data: data,
12103
- columnLabels: columnLabels
12104
- });
12105
- }
12106
- }
12107
- return null;
12108
- };
12109
- const createHumanizeError = (error, schema, uischema) => {
12110
- let humanMessage;
12111
- if (error) {
12112
- try {
12113
- humanMessage = humanizeAjvError(error, schema, uischema);
12114
- if (typeof humanMessage === 'string' && (humanMessage.includes('must have required property') || humanMessage.includes(REQUIRED_PROPERTY_ERROR))) {
12115
- const propertyMatch = humanMessage.match(/'([^']+)'/);
12116
- if (propertyMatch && propertyMatch[1]) {
12117
- humanMessage = prettify(propertyMatch[1]) + ' is required';
12118
- }
12119
- }
12120
- } catch (err) {
12121
- const raw = error.message;
12122
- const propertyMatch = raw == null ? void 0 : raw.match(/'([^']+)'/);
12123
- if (propertyMatch && propertyMatch[1]) {
12124
- humanMessage = prettify(propertyMatch[1]) + ' is required';
12125
- } else {
12126
- humanMessage = raw;
12127
- }
12128
- }
12129
- }
12130
- return humanMessage;
12131
- };
12132
-
12133
12129
  const _excluded$4 = ["label", "path", "schema", "rootSchema", "uischema", "errors", "visible", "enabled", "cells", "data", "config", "isStepperReview", "handleChange", "removeItems"];
12134
12130
  const GenerateRows = (Cell, schema, rowPath, enabled, openDeleteDialog, handleChange, cells, uischema, isInReview, count, data, errors) => {
12135
12131
  if ((schema == null ? void 0 : schema.type) === 'object') {
@@ -12459,7 +12455,7 @@ const NonEmptyCell = ownProps => {
12459
12455
  const emptyCellProps = ctxToNonEmptyCellProps(ctx, Object.assign({}, ownProps, {
12460
12456
  data
12461
12457
  }));
12462
- const isValid = isEmpty(emptyCellProps.errors);
12458
+ const isValid = isEmpty$1(emptyCellProps.errors);
12463
12459
  return jsx(NonEmptyCellComponent, Object.assign({}, emptyCellProps, {
12464
12460
  handleChange: ownProps == null ? void 0 : ownProps.handleChange,
12465
12461
  isInReview: ownProps == null ? void 0 : ownProps.isInReview,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.67.7",
3
+ "version": "2.67.8",
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",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": "1.0.0",
3
- "generatedAt": "2026-06-24T15:43:06.124Z",
4
- "sourceCommit": "08d590f507a0d7cc7dfd71287692ce6bc227e6df",
3
+ "generatedAt": "2026-06-25T21:22:05.583Z",
4
+ "sourceCommit": "a25b638498bc63728b41889ca6e86a9972cfde8a",
5
5
  "sourcePath": "libs/jsonforms-components/src/index.ts",
6
6
  "rendererCount": 33,
7
7
  "renderers": [
@@ -1,26 +1,10 @@
1
+ import { ArrayLayoutProps, ControlElement, JsonSchema, JsonFormsCellRendererRegistryEntry, ArrayTranslations, UISchemaElement } from '@jsonforms/core';
1
2
  import React from 'react';
2
3
  import type { ErrorObject } from 'ajv';
3
- import { ArrayLayoutProps, ControlElement, JsonSchema, JsonFormsRendererRegistryEntry, JsonFormsCellRendererRegistryEntry, ArrayTranslations, UISchemaElement, Layout } from '@jsonforms/core';
4
4
  import { WithDeleteDialogSupport } from './DeleteDialog';
5
+ import { NonEmptyRowComponentProps } from './ListWithDetailTypes';
5
6
  export type ObjectArrayControlProps = ArrayLayoutProps & WithDeleteDialogSupport;
6
7
  export declare const extractScopesFromUISchema: (uischema: any) => string[];
7
- export interface EmptyListProps {
8
- numColumns: number;
9
- noDataMessage: string;
10
- translations: ArrayTranslations;
11
- }
12
- interface NonEmptyRowComponentProps {
13
- propName?: string;
14
- schema: JsonSchema;
15
- rootSchema?: JsonSchema;
16
- rowPath: string;
17
- errors: string;
18
- enabled: boolean;
19
- renderers?: JsonFormsRendererRegistryEntry[];
20
- cells?: JsonFormsCellRendererRegistryEntry[];
21
- isValid: boolean;
22
- uischema?: ControlElement | Layout;
23
- }
24
8
  export declare const NonEmptyCellComponent: React.NamedExoticComponent<NonEmptyRowComponentProps>;
25
9
  interface NonEmptyRowProps {
26
10
  childPath: string;
@@ -0,0 +1,92 @@
1
+ import { ArrayLayoutProps, ArrayTranslations, ControlElement, JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonSchema, Layout, UISchemaElement } from '@jsonforms/core';
2
+ import { WithDeleteDialogSupport } from './DeleteDialog';
3
+ export type ListWithDetailArrayControlProps = ArrayLayoutProps & WithDeleteDialogSupport;
4
+ export interface EmptyListProps {
5
+ numColumns: number;
6
+ noDataMessage: string;
7
+ translations: ArrayTranslations;
8
+ }
9
+ export interface NonEmptyCellProps extends OwnPropsOfNonEmptyCell {
10
+ rootSchema?: JsonSchema;
11
+ errors: string;
12
+ enabled: boolean;
13
+ }
14
+ export interface OwnPropsOfNonEmptyCell {
15
+ rowPath: string;
16
+ propName?: string;
17
+ schema: JsonSchema;
18
+ enabled: boolean;
19
+ renderers?: JsonFormsRendererRegistryEntry[];
20
+ cells?: JsonFormsCellRendererRegistryEntry[];
21
+ uischema?: ControlElement;
22
+ }
23
+ export interface NonEmptyRowComponentProps {
24
+ propName?: string;
25
+ schema: JsonSchema;
26
+ rootSchema?: JsonSchema;
27
+ rowPath: string;
28
+ errors: string;
29
+ enabled: boolean;
30
+ renderers?: JsonFormsRendererRegistryEntry[];
31
+ cells?: JsonFormsCellRendererRegistryEntry[];
32
+ isValid: boolean;
33
+ uischema?: ControlElement | Layout;
34
+ }
35
+ export interface NonEmptyRowProps {
36
+ childPath: string;
37
+ schema: JsonSchema;
38
+ rowIndex: number;
39
+ showSortButtons: boolean;
40
+ enabled: boolean;
41
+ cells?: JsonFormsCellRendererRegistryEntry[];
42
+ path: string;
43
+ translations: ArrayTranslations;
44
+ uischema: ControlElement;
45
+ listTitle?: string;
46
+ }
47
+ export interface MainRowProps {
48
+ childPath: string;
49
+ rowIndex: number;
50
+ enabled: boolean;
51
+ currentTab: number;
52
+ current: HTMLElement | null;
53
+ selectCurrentTab: (index: number) => void;
54
+ setCurrentListPage: (index: number) => void;
55
+ rowData?: Record<string, any>;
56
+ uischema?: ControlElement;
57
+ schema?: JsonSchema;
58
+ }
59
+ export interface LeftRowProps {
60
+ childPath: string;
61
+ rowIndex: number;
62
+ enabled: boolean;
63
+ currentTab: number;
64
+ current: HTMLElement | null;
65
+ selectCurrentTab: (index: number) => void;
66
+ rowData?: Record<string, any>;
67
+ uischema?: ControlElement;
68
+ schema?: JsonSchema;
69
+ name: string;
70
+ translations: ArrayTranslations;
71
+ }
72
+ export interface TableRowsProp {
73
+ data: number;
74
+ path: string;
75
+ schema: JsonSchema;
76
+ uischema: ControlElement;
77
+ config?: any;
78
+ enabled: boolean;
79
+ cells?: JsonFormsCellRendererRegistryEntry[];
80
+ translations: ArrayTranslations;
81
+ currentIndex: number;
82
+ setCurrentIndex: (index: number) => void;
83
+ setCurrentListPage: (index: number) => void;
84
+ currentListPage: number;
85
+ listTitle?: string;
86
+ errors: string;
87
+ }
88
+ export interface SummaryDisplayProps {
89
+ rowData: Record<string, unknown> | undefined;
90
+ uischema?: UISchemaElement;
91
+ schema?: JsonSchema;
92
+ }
@@ -10,4 +10,14 @@ export declare const ADDRESS_LOOKUP_LABELS: {
10
10
  readonly subdivisionCode: "Province";
11
11
  readonly country: "Country";
12
12
  };
13
+ export declare const VALIDATION_KEYWORDS: {
14
+ REQUIRED: string;
15
+ MIN_LENGTH: string;
16
+ MAX_LENGTH: string;
17
+ FORMAT: string;
18
+ MINIMUM: string;
19
+ MAXIMUM: string;
20
+ TYPE: string;
21
+ ERROR_MESSAGE: string;
22
+ };
13
23
  export declare const getAddressLookupFieldLabel: (fieldName: string) => string;