@abgov/jsonforms-components 1.57.0 → 1.58.0

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,11 +1,11 @@
1
1
  import * as runtime from 'react/jsx-runtime';
2
2
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
3
  import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useRef, useCallback } from 'react';
4
- import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoARadioGroup, GoARadioItem, GoACheckbox, GoAIcon, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoATable, GoADropdown, GoADropdownItem, GoADetails, GoASpinner } from '@abgov/react-components';
4
+ import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoARadioGroup, GoARadioItem, GoACheckbox, GoAIcon, GoAButton, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAModal, GoAButtonGroup, GoATable, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoADropdown, GoADropdownItem, GoADetails, GoASpinner } from '@abgov/react-components';
5
5
  import styled from 'styled-components';
6
6
  import axios from 'axios';
7
7
  import get$1 from 'lodash/get';
8
- import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, getAjv, isVisible, getControlPath, toDataPath, deriveLabelForUISchemaElement, isEnabled, schemaTypeIs, formatIs, createDefaultValue, or, isObjectArrayControl, isPrimitiveArrayControl, Paths, schemaMatches, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
8
+ import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, getControlPath, toDataPath, deriveLabelForUISchemaElement, isEnabled, getAjv, isVisible, schemaTypeIs, formatIs, createDefaultValue, or, isObjectArrayControl, isPrimitiveArrayControl, Paths, schemaMatches, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
9
9
  import { withJsonFormsControlProps, withJsonFormsRendererProps, withJsonFormsEnumProps, withTranslateProps, useJsonForms, JsonFormsDispatch, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
10
10
  import * as _$c from 'lodash';
11
11
  import { isEqual, isObject as isObject$f } from 'lodash';
@@ -3800,7 +3800,11 @@ const JsonFormRegisterProvider = ({
3800
3800
  let _$a = t => t,
3801
3801
  _t$a,
3802
3802
  _t2$6,
3803
- _t3$5;
3803
+ _t3$5,
3804
+ _t4$5,
3805
+ _t5$3,
3806
+ _t6$3,
3807
+ _t7$2;
3804
3808
  const FormFieldWrapper = styled.div(_t$a || (_t$a = _$a`
3805
3809
  margin-bottom: var(--goa-space-l);
3806
3810
  `));
@@ -3818,6 +3822,23 @@ const RequiredTextLabel = styled.label(_t3$5 || (_t3$5 = _$a`
3818
3822
  line-height: var(--goa-line-height-1);
3819
3823
  font-style: normal;
3820
3824
  `));
3825
+ const PageReviewNameCol = styled.td(_t4$5 || (_t4$5 = _$a`
3826
+ width: 70%;
3827
+ padding-top: var(--goa-space-s);
3828
+ padding-bottom: var(--goa-space-s);
3829
+ padding-right: var(--goa-space-m);
3830
+ `));
3831
+ const PageReviewValueCol = styled.td(_t5$3 || (_t5$3 = _$a`
3832
+ width: 20%;
3833
+ text-align: left;
3834
+ `));
3835
+ const PageReviewActionCol = styled.td(_t6$3 || (_t6$3 = _$a`
3836
+ width: 10%;
3837
+ `));
3838
+ //Check and unchecked are different heights otherwise
3839
+ const CheckboxWrapper = styled.div(_t7$2 || (_t7$2 = _$a`
3840
+ height: 28px;
3841
+ `));
3821
3842
 
3822
3843
  const GoAInputBaseControl = props => {
3823
3844
  var _a, _b;
@@ -5057,19 +5078,21 @@ const BooleanComponent = ({
5057
5078
  }) => {
5058
5079
  var _a, _b, _c;
5059
5080
  const text = `${((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.text) ? (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.text : (schema === null || schema === void 0 ? void 0 : schema.title) ? schema === null || schema === void 0 ? void 0 : schema.title : schema === null || schema === void 0 ? void 0 : schema.description}${required ? ' (required)' : ''}`;
5060
- return jsx(GoACheckbox, Object.assign({
5061
- error: isVisited && errors.length > 0,
5062
- testId: `${path}-checkbox-test-id`,
5063
- disabled: !enabled,
5064
- text: text && text !== 'undefined' ? text : convertToReadableFormat(getLastSegmentFromPointer(uischema.scope)),
5065
- name: `${path}`,
5066
- checked: data,
5067
- onChange: (_, checked) => {
5068
- handleChange(path, checked);
5069
- }
5070
- }, (_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.componentProps, {
5071
- mb: "none"
5072
- }));
5081
+ return jsx(CheckboxWrapper, {
5082
+ children: jsx(GoACheckbox, Object.assign({
5083
+ error: isVisited && errors.length > 0,
5084
+ testId: `${path}-checkbox-test-id`,
5085
+ disabled: !enabled,
5086
+ text: text && text !== 'undefined' ? text : convertToReadableFormat(getLastSegmentFromPointer(uischema.scope)),
5087
+ name: `${path}`,
5088
+ checked: data,
5089
+ onChange: (_, checked) => {
5090
+ handleChange(path, checked);
5091
+ }
5092
+ }, (_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.componentProps, {
5093
+ mb: "none"
5094
+ }))
5095
+ });
5073
5096
  };
5074
5097
  const BooleanControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
5075
5098
  input: BooleanComponent
@@ -5158,10 +5181,9 @@ const CheckBoxGroupDiv = styled.div(_t$8 || (_t$8 = _$8`
5158
5181
  `));
5159
5182
 
5160
5183
  const CheckboxGroup = props => {
5161
- var _a, _b;
5184
+ var _a, _b, _c;
5162
5185
  const {
5163
5186
  data,
5164
- className,
5165
5187
  id,
5166
5188
  schema,
5167
5189
  uischema,
@@ -5172,10 +5194,14 @@ const CheckboxGroup = props => {
5172
5194
  label,
5173
5195
  t
5174
5196
  } = props;
5175
- const enumData = (schema === null || schema === void 0 ? void 0 : schema.enum) || [];
5197
+ const newSchema = schema;
5198
+ const enumData = (schema === null || schema === void 0 ? void 0 : schema.enum) || ((_a = newSchema === null || newSchema === void 0 ? void 0 : newSchema.items) === null || _a === void 0 ? void 0 : _a.enum) || [];
5176
5199
  const appliedUiSchemaOptions = merge({}, config, props.uischema.options, options);
5200
+ useEffect(() => {
5201
+ handleChange(path, data || []);
5202
+ }, []);
5177
5203
  return jsx(Checkboxes, {
5178
- orientation: ((_a = uischema.options) === null || _a === void 0 ? void 0 : _a.orientation) ? (_b = uischema.options) === null || _b === void 0 ? void 0 : _b.orientation : 'vertical',
5204
+ orientation: ((_b = uischema.options) === null || _b === void 0 ? void 0 : _b.orientation) ? (_c = uischema.options) === null || _c === void 0 ? void 0 : _c.orientation : 'vertical',
5179
5205
  testId: `${label || id}-jsonforms-checkboxes`,
5180
5206
  children: enumData.map(enumValue => {
5181
5207
  return jsx(GoACheckbox, Object.assign({
@@ -5186,7 +5212,13 @@ const CheckboxGroup = props => {
5186
5212
  text: enumValue,
5187
5213
  testId: `${enumValue}-checkbox`,
5188
5214
  onChange: (name, value) => {
5189
- handleChange(path, value === 'true' ? 'Yes' : 'No');
5215
+ let newData = Array.isArray(data) ? [...data] : [];
5216
+ if (value) {
5217
+ newData.push(enumValue);
5218
+ } else {
5219
+ newData = newData.filter(item => item !== enumValue);
5220
+ }
5221
+ handleChange(path, newData);
5190
5222
  }
5191
5223
  }));
5192
5224
  })
@@ -5198,7 +5230,7 @@ const EnumCheckboxControl = props => {
5198
5230
  }));
5199
5231
  };
5200
5232
  const GoAEnumCheckboxGroupControl = withJsonFormsEnumProps(withTranslateProps(EnumCheckboxControl), true);
5201
- const GoACheckoutGroupControlTester = rankWith(18, and(isEnumControl, optionIs('format', 'checkbox')));
5233
+ const GoACheckoutGroupControlTester = rankWith(18, and(optionIs('format', 'checkbox')));
5202
5234
 
5203
5235
  const warningIcon = errorMessage => {
5204
5236
  return jsxs(WarningIconDiv, {
@@ -5267,888 +5299,974 @@ const GoInputBaseReview = props => jsx(GoAInputBaseControl, Object.assign({}, pr
5267
5299
  }));
5268
5300
  const GoInputBaseReviewControl = withJsonFormsControlProps(GoInputBaseReview);
5269
5301
 
5270
- let _$7 = t => t,
5271
- _t$7;
5272
- const renderLayoutElements = (elements, schema, path, enabled, renderers, cells) => {
5273
- return elements.map((child, index) => jsx("div", {
5274
- children: jsx(JsonFormsDispatch, {
5275
- uischema: child,
5276
- schema: schema,
5277
- path: path,
5278
- enabled: enabled,
5279
- renderers: renderers,
5280
- cells: cells
5281
- }, path)
5282
- }, index));
5283
- };
5284
- const withAjvProps = Component => function WithAjvProps(props) {
5285
- const ctx = useJsonForms();
5286
- const ajv = getAjv({
5287
- jsonforms: Object.assign({}, ctx)
5288
- });
5289
- return jsx(Component, Object.assign({}, props, {
5290
- ajv: ajv
5291
- }));
5292
- };
5293
- const LayoutRenderer = ({
5294
- elements,
5295
- schema,
5296
- path,
5297
- enabled,
5298
- direction,
5299
- renderers,
5300
- cells,
5301
- visible,
5302
- width
5303
- }) => {
5304
- if (isEmpty(elements)) {
5305
- return null;
5306
- } else {
5307
- if (direction === 'row') {
5308
- return jsx(Visible, {
5309
- visible: visible,
5310
- children: jsx(GoAGrid, {
5311
- minChildWidth: width || '10ch',
5312
- children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
5313
- })
5314
- });
5315
- } else {
5316
- return jsx(Visible, {
5317
- visible: visible,
5318
- children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
5319
- });
5302
+ // eslint-disable-next-line
5303
+ const getProperty = (obj, propName) => {
5304
+ if (obj[propName] !== undefined) return obj[propName];
5305
+ for (const key in obj) {
5306
+ if (typeof obj[key] === 'object' && obj[key] !== null) {
5307
+ const result = getProperty(obj[key], propName);
5308
+ if (result !== undefined) return result;
5320
5309
  }
5321
5310
  }
5322
5311
  };
5323
- const ReviewLayoutRenderer = ({
5324
- elements,
5325
- schema,
5326
- path,
5327
- enabled,
5328
- direction,
5329
- renderers,
5330
- cells,
5331
- visible,
5332
- width
5333
- }) => {
5334
- if (isEmpty(elements)) {
5335
- return null;
5336
- } else {
5337
- if (direction === 'row') {
5338
- return jsx(Visible, {
5339
- visible: visible,
5340
- children: jsx(ReviewGrid, {
5341
- children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
5342
- })
5343
- });
5344
- } else {
5345
- return jsx(Visible, {
5346
- visible: visible,
5347
- children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
5312
+ // eslint-disable-next-line
5313
+ const pickPropertyValues = (obj, property, endWithType) => {
5314
+ let values = [];
5315
+ Object.keys(obj).forEach(function (key) {
5316
+ var _a;
5317
+ if (key === property) {
5318
+ values.push(obj[key]);
5319
+ } else if (_$c.isObject(obj[key])) {
5320
+ // if the object type is equal to end type, we are not going to continue the recursive approach
5321
+ if (endWithType && ((_a = obj[key]) === null || _a === void 0 ? void 0 : _a.type) === endWithType) {
5322
+ if (property in obj[key]) {
5323
+ values.push(obj[key][property]);
5324
+ }
5325
+ } else {
5326
+ values = [...values, ...pickPropertyValues(obj[key], property, endWithType)];
5327
+ }
5328
+ } else if (_$c.isArray(obj[key])) {
5329
+ const nextValues = obj[key].map(function (arrayObj) {
5330
+ return pickPropertyValues(arrayObj, property, endWithType);
5348
5331
  });
5332
+ values = [...values, ...nextValues];
5349
5333
  }
5350
- }
5334
+ });
5335
+ return values;
5351
5336
  };
5352
- const ReviewGrid = styled.div(_t$7 || (_t$7 = _$7`
5353
- display: grid;
5354
- grid-template-columns: repeat(auto-fit, minmax(250px, calc(50% - 8px)));
5355
- gap: 16px;
5356
- `));
5357
5337
 
5358
- let _$6 = t => t,
5359
- _t$6,
5360
- _t2$4,
5361
- _t3$3,
5362
- _t4$3,
5363
- _t5$2,
5364
- _t6$2,
5365
- _t7$1,
5366
- _t8$1,
5367
- _t9$1,
5368
- _t10$1,
5369
- _t11$1,
5370
- _t12$1,
5371
- _t13$1;
5372
- const ReviewItem = styled.div(_t$6 || (_t$6 = _$6`
5373
- display: flex;
5374
- flex-direction: column;
5375
- border: var(--goa-border-width-s) solid grey;
5376
- border-radius: var(--goa-border-radius-m);
5377
- margin: var(--goa-space-2xs);
5378
- padding: var(--goa-space-xs);
5379
- div:empty {
5380
- display: none;
5338
+ const isErrorPathIncluded = (errorPaths, path) => {
5339
+ return errorPaths.some(ePath => {
5340
+ /**
5341
+ * case A: errorPaths: [name] path: [name]
5342
+ *
5343
+ * case B: errorPath: [name] path: [name.firstName]
5344
+ * */
5345
+ return ePath === path || path.startsWith(ePath + '.');
5346
+ });
5347
+ };
5348
+ function isNumber(value) {
5349
+ return value != null && value !== '' && !isNaN(Number(value.toString()));
5350
+ }
5351
+ const getIncompletePaths = (ajv, scopes) => {
5352
+ var _a;
5353
+ const requiredErrorPaths = (_a = ajv === null || ajv === void 0 ? void 0 : ajv.errors) === null || _a === void 0 ? void 0 : _a.filter(e => e.keyword === 'required' || e.keyword === 'minLength').map(e => {
5354
+ return getControlPath(e);
5355
+ });
5356
+ const _scopes = scopes.map(scope => toDataPath(scope)).filter(path => requiredErrorPaths && isErrorPathIncluded(requiredErrorPaths, path));
5357
+ return _scopes;
5358
+ };
5359
+ const subErrorInParent = (error, paths) => {
5360
+ /*
5361
+ Detect is there sub error in an object array.
5362
+ For example: error with instance path /roadmap/0/when belongs to /roadmap
5363
+ */
5364
+ const errorPaths = error.instancePath.split('/');
5365
+ if (errorPaths.length < 2) return false;
5366
+ // For case /roadmap/0
5367
+ if (errorPaths.length > 1 && isNumber(errorPaths[errorPaths.length - 1])) {
5368
+ const parentPath = errorPaths.slice(0, errorPaths.length - 1).join('/');
5369
+ return paths.includes(parentPath);
5381
5370
  }
5382
- `));
5383
- const ReviewItemSection = styled.div(_t2$4 || (_t2$4 = _$6`
5384
- background-color: #f1f1f1;
5385
- margin-bottom: var(--goa-space-m);
5386
- padding: var(--goa-space-m);
5387
- border: 1px solid #dcdcdc;
5388
- border-radius: 5px;
5389
-
5390
- .element-style {
5391
- max-width: 1600px;
5371
+ // For case /roadmap/0/when
5372
+ if (errorPaths.length > 2 && isNumber(errorPaths[errorPaths.length - 2])) {
5373
+ const parentPath = errorPaths.slice(0, errorPaths.length - 2).join('/');
5374
+ return paths.includes(parentPath);
5392
5375
  }
5393
- `));
5394
- const ReviewItemHeader = styled.div(_t3$3 || (_t3$3 = _$6`
5395
- display: flex;
5396
- align-items: center;
5397
- justify-content: space-between;
5398
- margin-bottom: var(--goa-space-xl);
5399
- `));
5400
- const ReviewItemTitle = styled.div(_t4$3 || (_t4$3 = _$6`
5401
- font-size: var(--goa-space-l);
5402
- line-height: var(--goa-space-xl);
5403
- font-weight: 300;
5404
- `));
5405
- const Anchor = styled.div(_t5$2 || (_t5$2 = _$6`
5406
- color: #0070c4;
5407
- text-decoration: underline;
5408
- outline: none;
5409
- cursor: pointer;
5376
+ return false;
5377
+ };
5378
+ const getErrorsInScopes = (errors, scopes) => {
5379
+ return errors.filter(e => {
5380
+ // transfer scope #properties/value to data path /value
5381
+ const dataPaths = scopes.map(s => '/' + toDataPath(s));
5382
+ return dataPaths.includes(e.instancePath) || subErrorInParent(e, dataPaths);
5383
+ });
5384
+ };
5410
5385
 
5411
- &:focus {
5412
- outline: 2px solid #0070c4;
5413
- background-color: #e6f7ff;
5414
- }
5415
- `));
5416
- styled.div(_t6$2 || (_t6$2 = _$6`
5417
- margin-left: var(--goa-space-m);
5418
- `));
5419
- styled.div(_t7$1 || (_t7$1 = _$6`
5420
- margin-bottom: var(--goa-space-m);
5421
- `));
5422
- styled.div(_t8$1 || (_t8$1 = _$6`
5423
- margin: var(--goa-space-s);
5424
- width: 100%;
5425
- `));
5426
- styled.h3(_t9$1 || (_t9$1 = _$6`
5427
- text-transform: capitalize;
5428
- `));
5429
- const RightAlignmentDiv = styled.div(_t10$1 || (_t10$1 = _$6`
5430
- @media screen and (max-width: 767px) {
5431
- margin-bottom: var(--goa-space-l);
5432
- }
5433
- @media screen and (min-width: 768px) {
5434
- display: flex;
5435
- justify-content: flex-end;
5436
- margin-bottom: var(--goa-space-l);
5437
- }
5438
- `));
5439
- const FormStepperSummaryH3 = styled.h3(_t11$1 || (_t11$1 = _$6`
5440
- flex: 1;
5441
- margin-bottom: var(--goa-space-m);
5442
- font-size: var(--goa-font-size-7);
5443
- line-height: var(--goa-line-height-4);
5444
- font-weight: var(--goa-font-weight-regular);
5445
- `));
5446
- const PageRenderPadding = styled.h3(_t12$1 || (_t12$1 = _$6`
5447
- margin-top: var(--goa-space-2xl);
5448
- `));
5449
- const PageBorder = styled.h3(_t13$1 || (_t13$1 = _$6`
5450
- padding: var(--goa-space-3xl);
5451
- `));
5452
-
5453
- class ContextProviderClass {
5454
- addDataByUrl(key, url, processDataFunction, token) {
5455
- return __awaiter(this, void 0, void 0, function* () {
5456
- let header = {};
5457
- const [requestId, axiosWithConfig] = this.getAxiosInterceptorConfig(axios);
5458
- if (token) {
5459
- header = Object.assign(Object.assign({}, header), {
5460
- Authorization: `Bearer ${token}`
5461
- });
5386
+ const stepperReducer = (state, action) => {
5387
+ var _a, _b;
5388
+ const {
5389
+ activeId,
5390
+ categories
5391
+ } = state;
5392
+ const lastId = categories[categories.length - 1].id;
5393
+ switch (action.type) {
5394
+ case 'update/uischema':
5395
+ {
5396
+ return Object.assign({}, action.payload.state);
5462
5397
  }
5463
- yield axiosWithConfig.get(url, header).then(response => {
5464
- const processedData = processDataFunction(response.data);
5465
- this.enumValues.set(key, () => processedData);
5466
- }).catch(err => {
5467
- if (err.message.includes('CORS')) {
5468
- console.warn(err.message);
5398
+ case 'page/next':
5399
+ {
5400
+ state.activeId += 1;
5401
+ if (activeId === lastId) {
5402
+ state.isOnReview = true;
5403
+ state.hasNextButton = false;
5404
+ state.hasPrevButton = false;
5469
5405
  } else {
5470
- console.warn(`addDataByUrl: ${err.message}`);
5406
+ state.hasNextButton = true;
5407
+ state.hasPrevButton = true;
5408
+ state.isOnReview = false;
5471
5409
  }
5472
- });
5473
- axiosWithConfig.interceptors.request.eject(requestId);
5474
- });
5475
- }
5476
- constructor() {
5477
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5478
- this.enumValues = new Map();
5479
- this.enumFunctions = new Map();
5480
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5481
- this.enumSubmitFunctions = new Map();
5482
- this.addFormContextData = (key, data) => {
5483
- this.enumValues.set(key, () => data);
5484
- };
5485
- this.setup = props => {
5486
- var _a, _b;
5487
- this.selfProps = props;
5488
- if (props.fileManagement) {
5489
- const {
5490
- fileList,
5491
- uploadFile,
5492
- downloadFile,
5493
- deleteFile
5494
- } = props.fileManagement;
5495
- this.enumValues.set('file-list', () => fileList);
5496
- this.enumFunctions.set('upload-file', () => uploadFile);
5497
- this.enumFunctions.set('download-file', () => downloadFile);
5498
- this.enumFunctions.set('delete-file', () => deleteFile);
5410
+ state.categories[activeId].isVisited = true;
5411
+ return Object.assign({}, state);
5499
5412
  }
5500
- if (props.submit) {
5413
+ case 'page/prev':
5414
+ {
5415
+ state.categories[activeId].isVisited = true;
5416
+ if (activeId > 0) {
5417
+ state.activeId -= 1;
5418
+ state.hasPrevButton = state.activeId !== 0;
5419
+ state.hasNextButton = true;
5420
+ state.isOnReview = false;
5421
+ }
5422
+ return Object.assign({}, state);
5423
+ }
5424
+ case 'page/to/index':
5425
+ {
5501
5426
  const {
5502
- submitForm
5503
- } = props.submit;
5504
- const submitFunction = submitForm;
5505
- this.enumSubmitFunctions.set('submit-form', () => submitFunction);
5427
+ id
5428
+ } = action.payload;
5429
+ state.activeId = id;
5430
+ if (id > lastId) {
5431
+ state.isOnReview = true;
5432
+ state.hasNextButton = false;
5433
+ state.hasPrevButton = true;
5434
+ return Object.assign({}, state);
5435
+ } else {
5436
+ state.categories[id].isVisited = true;
5437
+ state.hasNextButton = id <= lastId;
5438
+ state.hasPrevButton = id !== 0;
5439
+ state.isOnReview = false;
5440
+ state.maxReachedStep = Math.max(state.maxReachedStep, activeId);
5441
+ return Object.assign({}, state);
5442
+ }
5506
5443
  }
5507
- if (props.data) {
5508
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5509
- Object.keys(props.data).forEach(item => {
5510
- this.enumValues.set(item, () => props.data[item]);
5511
- });
5444
+ case 'update/category':
5445
+ {
5446
+ const {
5447
+ id,
5448
+ ajv,
5449
+ errors
5450
+ } = action.payload;
5451
+ if (id === state.categories.length) {
5452
+ return Object.assign({}, state);
5453
+ }
5454
+ /*
5455
+ ctx.core.errors only includes required errors when the fields are touched. In this case, we still ajv to figure out the required errors at the very beginning.
5456
+ */
5457
+ const incompletePaths = getIncompletePaths(ajv, ((_a = state.categories[id]) === null || _a === void 0 ? void 0 : _a.scopes) || []);
5458
+ const errorsInCategory = getErrorsInScopes(errors, ((_b = state.categories[id]) === null || _b === void 0 ? void 0 : _b.scopes) || []);
5459
+ state.categories[id].isCompleted = (incompletePaths === null || incompletePaths === void 0 ? void 0 : incompletePaths.length) === 0;
5460
+ state.categories[id].isValid = errorsInCategory.length === 0;
5461
+ state.categories[id].isVisited = true;
5462
+ return Object.assign({}, state);
5512
5463
  }
5513
- if (!props.children) {
5514
- return null;
5464
+ case 'validate/form':
5465
+ {
5466
+ const {
5467
+ errors
5468
+ } = action.payload;
5469
+ state.isValid = errors.length === 0;
5470
+ return Object.assign({}, state);
5515
5471
  }
5516
- if (props.formUrl) {
5517
- this.baseEnumerator.formUrl = props.formUrl;
5472
+ case 'toggle/category/review-link':
5473
+ {
5474
+ const {
5475
+ id
5476
+ } = action.payload;
5477
+ state.categories[id].showReviewPageLink = !state.categories[id].showReviewPageLink;
5478
+ return Object.assign({}, state);
5518
5479
  }
5519
- this.baseEnumerator.isFormSubmitted = (_a = props.isFormSubmitted) !== null && _a !== void 0 ? _a : false;
5520
- return jsx(JsonFormContext.Provider, {
5521
- value: this.baseEnumerator,
5522
- children: (_b = this.selfProps) === null || _b === void 0 ? void 0 : _b.children
5523
- });
5524
- };
5525
- this.getContextProvider = () => {
5526
- var _a;
5527
- return jsx(JsonFormContext.Provider, {
5528
- value: this.baseEnumerator,
5529
- children: (_a = this.selfProps) === null || _a === void 0 ? void 0 : _a.children
5530
- });
5531
- };
5532
- this.getFormUrl = () => {
5533
- var _a;
5534
- return (_a = this.selfProps) === null || _a === void 0 ? void 0 : _a.formUrl;
5535
- };
5536
- this.getAxiosInterceptorConfig = axios => {
5537
- const requestId = axios.interceptors.request.use(req => {
5538
- if (req.data === undefined) {
5539
- throw new Error(`The URL: ${req.url} encountered a CORS error.`);
5540
- }
5541
- return req;
5542
- });
5543
- return [requestId, axios];
5544
- };
5545
- /**
5546
- * Grabs data stored under a given key
5547
- *
5548
- */
5549
- this.getFormContextData = key => {
5550
- const dataFunction = this.baseEnumerator.data.get(key);
5551
- return dataFunction && dataFunction();
5552
- };
5553
- /**
5554
- * Grabs all data
5555
- *
5556
- */
5557
- this.getAllFormContextData = () => {
5558
- const allData = [];
5559
- this.baseEnumerator.data.forEach((d, key) => {
5560
- allData.push({
5561
- [key]: d()
5562
- });
5563
- });
5564
- return allData;
5565
- };
5566
- this.baseEnumerator = {
5567
- data: this.enumValues,
5568
- functions: this.enumFunctions,
5569
- submitFunction: this.enumSubmitFunctions,
5570
- addFormContextData: this.addFormContextData,
5571
- getFormContextData: this.getFormContextData,
5572
- getAllFormContextData: this.getAllFormContextData,
5573
- formUrl: this.getFormUrl()
5574
- };
5575
- this.selfProps = {};
5480
+ default:
5481
+ return state;
5576
5482
  }
5577
- }
5578
- const ContextProviderC = new ContextProviderClass();
5579
- const ContextProviderFactory = () => new ContextProviderClass().setup;
5580
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5581
- const JsonFormContext = /*#__PURE__*/createContext(null);
5582
-
5583
- const RenderStepElements = props => {
5584
- return jsx(Visible, {
5585
- visible: props.visible,
5586
- "date-testid": `${props.path}-categories-${props.categoryIndex}`,
5587
- children: props.category.elements.map((uiSchema, index) => {
5588
- return jsx(JsonFormsDispatch, {
5589
- schema: props.schema,
5590
- uischema: uiSchema,
5591
- renderers: props.renderers,
5592
- cells: props.cells,
5593
- path: props.path,
5594
- visible: props.visible,
5595
- enabled: props.enabled
5596
- }, `${props.path}-category-page-${index}`);
5597
- })
5598
- });
5599
- };
5600
-
5601
- var uncurryThis$3 = functionUncurryThisClause;
5602
- var aCallable$6 = aCallable$9;
5603
- var NATIVE_BIND = functionBindNative;
5604
-
5605
- var bind$5 = uncurryThis$3(uncurryThis$3.bind);
5606
-
5607
- // optional / simple context binding
5608
- var functionBindContext = function (fn, that) {
5609
- aCallable$6(fn);
5610
- return that === undefined ? fn : NATIVE_BIND ? bind$5(fn, that) : function (/* ...args */) {
5611
- return fn.apply(that, arguments);
5612
- };
5613
5483
  };
5614
5484
 
5615
- var isArray$1 = isArray$4;
5616
- var lengthOfArrayLike$3 = lengthOfArrayLike$7;
5617
- var doesNotExceedSafeInteger = doesNotExceedSafeInteger$2;
5618
- var bind$4 = functionBindContext;
5619
-
5620
- // `FlattenIntoArray` abstract operation
5621
- // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
5622
- var flattenIntoArray$1 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
5623
- var targetIndex = start;
5624
- var sourceIndex = 0;
5625
- var mapFn = mapper ? bind$4(mapper, thisArg) : false;
5626
- var element, elementLen;
5627
-
5628
- while (sourceIndex < sourceLen) {
5629
- if (sourceIndex in source) {
5630
- element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
5485
+ const createStepperContextInitData = props => {
5486
+ var _a;
5487
+ const {
5488
+ uischema,
5489
+ data,
5490
+ schema,
5491
+ ajv,
5492
+ t,
5493
+ visible,
5494
+ path
5495
+ } = props;
5496
+ const categorization = uischema;
5497
+ const valid = ajv.validate(schema, data || {});
5498
+ const categories = (_a = categorization.elements) === null || _a === void 0 ? void 0 : _a.map((c, id) => {
5499
+ const scopes = pickPropertyValues(c, 'scope', 'ListWithDetail');
5500
+ const incompletePaths = getIncompletePaths(ajv, scopes);
5501
+ return {
5502
+ id,
5503
+ label: deriveLabelForUISchemaElement(c, t),
5504
+ scopes,
5505
+ isVisited: false,
5506
+ isCompleted: (incompletePaths === null || incompletePaths === void 0 ? void 0 : incompletePaths.length) === 0,
5507
+ isValid: (incompletePaths === null || incompletePaths === void 0 ? void 0 : incompletePaths.length) === 0,
5508
+ uischema: c,
5509
+ showReviewPageLink: props.withBackReviewBtn || false,
5510
+ isEnabled: isEnabled(c, data, '', ajv),
5511
+ visible
5512
+ };
5513
+ });
5514
+ const activeId = (props === null || props === void 0 ? void 0 : props.activeId) || 0;
5515
+ return {
5516
+ categories: categories,
5517
+ activeId,
5518
+ hasNextButton: activeId !== (categories === null || categories === void 0 ? void 0 : categories.length),
5519
+ hasPrevButton: activeId > 0 && activeId !== (categories === null || categories === void 0 ? void 0 : categories.length),
5520
+ path,
5521
+ isOnReview: activeId === (categories === null || categories === void 0 ? void 0 : categories.length),
5522
+ isValid: valid === true,
5523
+ maxReachedStep: 0
5524
+ };
5525
+ };
5526
+ const JsonFormsStepperContext = /*#__PURE__*/createContext(undefined);
5527
+ const JsonFormsStepperContextProvider = ({
5528
+ children,
5529
+ StepperProps
5530
+ }) => {
5531
+ var _a;
5532
+ const ctx = useJsonForms();
5533
+ const {
5534
+ schema,
5535
+ ajv
5536
+ } = StepperProps;
5537
+ const [stepperState, dispatch] = useReducer(stepperReducer, createStepperContextInitData(StepperProps));
5538
+ const stepperDispatch = (StepperProps === null || StepperProps === void 0 ? void 0 : StepperProps.customDispatch) || dispatch;
5539
+ const context = useMemo(() => {
5540
+ return {
5541
+ isProvided: true,
5542
+ stepperDispatch,
5543
+ selectStepperState: () => {
5544
+ return stepperState;
5545
+ },
5546
+ selectIsDisabled: () => {
5547
+ var _a;
5548
+ const category = (_a = stepperState.categories) === null || _a === void 0 ? void 0 : _a[stepperState.activeId];
5549
+ return category === undefined ? false : !(category === null || category === void 0 ? void 0 : category.isEnabled);
5550
+ },
5551
+ selectIsActive: id => {
5552
+ return id === stepperState.activeId;
5553
+ },
5554
+ selectPath: () => {
5555
+ return stepperState.path;
5556
+ },
5557
+ selectCategory: id => {
5558
+ return stepperState.categories[id];
5559
+ },
5560
+ validatePage: id => {
5561
+ var _a;
5562
+ stepperDispatch({
5563
+ type: 'update/category',
5564
+ payload: {
5565
+ errors: (_a = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _a === void 0 ? void 0 : _a.errors,
5566
+ id,
5567
+ ajv
5568
+ }
5569
+ });
5570
+ },
5571
+ goToPage: (id, updateCategoryId) => {
5572
+ var _a, _b, _c;
5573
+ ajv.validate(schema, ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.data) || {});
5574
+ if (stepperState.isOnReview !== true) {
5575
+ for (let i = 0; i < id; i++) {
5576
+ stepperDispatch({
5577
+ type: 'update/category',
5578
+ payload: {
5579
+ errors: (_b = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _b === void 0 ? void 0 : _b.errors,
5580
+ id: i,
5581
+ ajv
5582
+ }
5583
+ });
5584
+ }
5585
+ }
5586
+ stepperDispatch({
5587
+ type: 'validate/form',
5588
+ payload: {
5589
+ errors: (_c = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _c === void 0 ? void 0 : _c.errors
5590
+ }
5591
+ });
5592
+ stepperDispatch({
5593
+ type: 'page/to/index',
5594
+ payload: {
5595
+ id
5596
+ }
5597
+ });
5598
+ },
5599
+ toggleShowReviewLink: id => {
5600
+ stepperDispatch({
5601
+ type: 'toggle/category/review-link',
5602
+ payload: {
5603
+ id
5604
+ }
5605
+ });
5606
+ }
5607
+ };
5608
+ }, [stepperDispatch, stepperState, (_a = ctx.core) === null || _a === void 0 ? void 0 : _a.errors]);
5609
+ useEffect(() => {
5610
+ if ((context === null || context === void 0 ? void 0 : context.isProvided) === true) {
5611
+ /* The block is used to cache the state for the tenant web app review editor */
5612
+ stepperDispatch({
5613
+ type: 'update/uischema',
5614
+ payload: {
5615
+ state: createStepperContextInitData(Object.assign(Object.assign({}, StepperProps), {
5616
+ activeId: stepperState === null || stepperState === void 0 ? void 0 : stepperState.activeId
5617
+ }))
5618
+ }
5619
+ });
5620
+ context.goToPage(stepperState.maxReachedStep);
5621
+ context.goToPage(stepperState.activeId);
5622
+ }
5623
+ }, [JSON.stringify(StepperProps.uischema), JSON.stringify(StepperProps.schema)]);
5624
+ return jsx(JsonFormsStepperContext.Provider, {
5625
+ value: context,
5626
+ children: children
5627
+ });
5628
+ };
5631
5629
 
5632
- if (depth > 0 && isArray$1(element)) {
5633
- elementLen = lengthOfArrayLike$3(element);
5634
- targetIndex = flattenIntoArray$1(target, original, element, elementLen, targetIndex, depth - 1) - 1;
5630
+ const GoAInputBaseTableReview = props => {
5631
+ var _a, _b, _c, _d;
5632
+ const {
5633
+ data,
5634
+ uischema,
5635
+ label
5636
+ } = props;
5637
+ const labelToUpdate = convertToSentenceCase(getLabelText(uischema.scope, label || ''));
5638
+ const categoryIndex = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.categoryIndex;
5639
+ const formStepperCtx = useContext(JsonFormsStepperContext);
5640
+ let reviewText = data;
5641
+ const isBoolean = typeof data === 'boolean';
5642
+ if (isBoolean) {
5643
+ const checkboxLabel = ((_c = (_b = uischema.options) === null || _b === void 0 ? void 0 : _b.text) === null || _c === void 0 ? void 0 : _c.trim()) || convertToSentenceCase(getLastSegmentFromPointer(uischema.scope));
5644
+ if (((_d = uischema.options) === null || _d === void 0 ? void 0 : _d.radio) === true) {
5645
+ reviewText = data ? `Yes` : `No`;
5646
+ } else {
5647
+ if (label !== '' || typeof label === 'boolean') {
5648
+ reviewText = data ? `Yes` : `No`;
5635
5649
  } else {
5636
- doesNotExceedSafeInteger(targetIndex + 1);
5637
- target[targetIndex] = element;
5650
+ reviewText = data ? `Yes (${checkboxLabel.trim()})` : `No (${checkboxLabel.trim()})`;
5638
5651
  }
5639
-
5640
- targetIndex++;
5641
5652
  }
5642
- sourceIndex++;
5643
5653
  }
5644
- return targetIndex;
5654
+ return jsxs("tr", {
5655
+ "data-testid": `input-base-table-${label}-row`,
5656
+ children: [jsx(PageReviewNameCol, {
5657
+ children: jsx("strong", {
5658
+ children: labelToUpdate
5659
+ })
5660
+ }), jsx(PageReviewValueCol, {
5661
+ children: reviewText
5662
+ }), jsx(PageReviewActionCol, {
5663
+ children: jsx(GoAButton, {
5664
+ type: "tertiary",
5665
+ testId: `page-review-change-${label}-btn`,
5666
+ onClick: () => {
5667
+ if (formStepperCtx) {
5668
+ formStepperCtx.toggleShowReviewLink(categoryIndex);
5669
+ formStepperCtx.goToPage(categoryIndex);
5670
+ }
5671
+ },
5672
+ children: "Change"
5673
+ })
5674
+ })]
5675
+ });
5645
5676
  };
5677
+ const GoAInputBaseTableReviewControl = withJsonFormsControlProps(GoAInputBaseTableReview);
5646
5678
 
5647
- var flattenIntoArray_1 = flattenIntoArray$1;
5648
-
5649
- var uncurryThis$2 = functionUncurryThis;
5650
- var fails$3 = fails$s;
5651
- var isCallable$4 = isCallable$q;
5652
- var classof$2 = classof$9;
5653
- var getBuiltIn$2 = getBuiltIn$9;
5654
- var inspectSource$1 = inspectSource$3;
5655
-
5656
- var noop = function () { /* empty */ };
5657
- var construct = getBuiltIn$2('Reflect', 'construct');
5658
- var constructorRegExp = /^\s*(?:class|function)\b/;
5659
- var exec$1 = uncurryThis$2(constructorRegExp.exec);
5660
- var INCORRECT_TO_STRING = !constructorRegExp.test(noop);
5661
-
5662
- var isConstructorModern = function isConstructor(argument) {
5663
- if (!isCallable$4(argument)) return false;
5664
- try {
5665
- construct(noop, [], argument);
5666
- return true;
5667
- } catch (error) {
5668
- return false;
5669
- }
5679
+ let _$7 = t => t,
5680
+ _t$7;
5681
+ const renderLayoutElements = (elements, schema, path, enabled, renderers, cells) => {
5682
+ return elements.map((child, index) => jsx("div", {
5683
+ children: jsx(JsonFormsDispatch, {
5684
+ uischema: child,
5685
+ schema: schema,
5686
+ path: path,
5687
+ enabled: enabled,
5688
+ renderers: renderers,
5689
+ cells: cells
5690
+ }, path)
5691
+ }, index));
5670
5692
  };
5671
-
5672
- var isConstructorLegacy = function isConstructor(argument) {
5673
- if (!isCallable$4(argument)) return false;
5674
- switch (classof$2(argument)) {
5675
- case 'AsyncFunction':
5676
- case 'GeneratorFunction':
5677
- case 'AsyncGeneratorFunction': return false;
5678
- }
5679
- try {
5680
- // we can't check .prototype since constructors produced by .bind haven't it
5681
- // `Function#toString` throws on some built-it function in some legacy engines
5682
- // (for example, `DOMQuad` and similar in FF41-)
5683
- return INCORRECT_TO_STRING || !!exec$1(constructorRegExp, inspectSource$1(argument));
5684
- } catch (error) {
5685
- return true;
5686
- }
5693
+ const withAjvProps = Component => function WithAjvProps(props) {
5694
+ const ctx = useJsonForms();
5695
+ const ajv = getAjv({
5696
+ jsonforms: Object.assign({}, ctx)
5697
+ });
5698
+ return jsx(Component, Object.assign({}, props, {
5699
+ ajv: ajv
5700
+ }));
5687
5701
  };
5688
-
5689
- isConstructorLegacy.sham = true;
5690
-
5691
- // `IsConstructor` abstract operation
5692
- // https://tc39.es/ecma262/#sec-isconstructor
5693
- var isConstructor$2 = !construct || fails$3(function () {
5694
- var called;
5695
- return isConstructorModern(isConstructorModern.call)
5696
- || !isConstructorModern(Object)
5697
- || !isConstructorModern(function () { called = true; })
5698
- || called;
5699
- }) ? isConstructorLegacy : isConstructorModern;
5700
-
5701
- var isArray = isArray$4;
5702
- var isConstructor$1 = isConstructor$2;
5703
- var isObject$2 = isObject$e;
5704
- var wellKnownSymbol$5 = wellKnownSymbol$k;
5705
-
5706
- var SPECIES$2 = wellKnownSymbol$5('species');
5707
- var $Array = Array;
5708
-
5709
- // a part of `ArraySpeciesCreate` abstract operation
5710
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
5711
- var arraySpeciesConstructor$1 = function (originalArray) {
5712
- var C;
5713
- if (isArray(originalArray)) {
5714
- C = originalArray.constructor;
5715
- // cross-realm fallback
5716
- if (isConstructor$1(C) && (C === $Array || isArray(C.prototype))) C = undefined;
5717
- else if (isObject$2(C)) {
5718
- C = C[SPECIES$2];
5719
- if (C === null) C = undefined;
5702
+ const LayoutRenderer = ({
5703
+ elements,
5704
+ schema,
5705
+ path,
5706
+ enabled,
5707
+ direction,
5708
+ renderers,
5709
+ cells,
5710
+ visible,
5711
+ width
5712
+ }) => {
5713
+ if (isEmpty(elements)) {
5714
+ return null;
5715
+ } else {
5716
+ if (direction === 'row') {
5717
+ return jsx(Visible, {
5718
+ visible: visible,
5719
+ children: jsx(GoAGrid, {
5720
+ minChildWidth: width || '10ch',
5721
+ children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
5722
+ })
5723
+ });
5724
+ } else {
5725
+ return jsx(Visible, {
5726
+ visible: visible,
5727
+ children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
5728
+ });
5720
5729
  }
5721
- } return C === undefined ? $Array : C;
5730
+ }
5722
5731
  };
5723
-
5724
- var arraySpeciesConstructor = arraySpeciesConstructor$1;
5725
-
5726
- // `ArraySpeciesCreate` abstract operation
5727
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
5728
- var arraySpeciesCreate$1 = function (originalArray, length) {
5729
- return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
5732
+ const ReviewLayoutRenderer = ({
5733
+ elements,
5734
+ schema,
5735
+ path,
5736
+ enabled,
5737
+ direction,
5738
+ renderers,
5739
+ cells,
5740
+ visible,
5741
+ width
5742
+ }) => {
5743
+ if (isEmpty(elements)) {
5744
+ return null;
5745
+ } else {
5746
+ if (direction === 'row') {
5747
+ return jsx(Visible, {
5748
+ visible: visible,
5749
+ children: jsx(ReviewGrid, {
5750
+ children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
5751
+ })
5752
+ });
5753
+ } else {
5754
+ return jsx(Visible, {
5755
+ visible: visible,
5756
+ children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
5757
+ });
5758
+ }
5759
+ }
5730
5760
  };
5761
+ const ReviewGrid = styled.div(_t$7 || (_t$7 = _$7`
5762
+ display: grid;
5763
+ grid-template-columns: repeat(auto-fit, minmax(250px, calc(50% - 8px)));
5764
+ gap: 16px;
5765
+ `));
5731
5766
 
5732
- var $$a = _export;
5733
- var flattenIntoArray = flattenIntoArray_1;
5734
- var toObject$1 = toObject$8;
5735
- var lengthOfArrayLike$2 = lengthOfArrayLike$7;
5736
- var toIntegerOrInfinity = toIntegerOrInfinity$7;
5737
- var arraySpeciesCreate = arraySpeciesCreate$1;
5738
-
5739
- // `Array.prototype.flat` method
5740
- // https://tc39.es/ecma262/#sec-array.prototype.flat
5741
- $$a({ target: 'Array', proto: true }, {
5742
- flat: function flat(/* depthArg = 1 */) {
5743
- var depthArg = arguments.length ? arguments[0] : undefined;
5744
- var O = toObject$1(this);
5745
- var sourceLen = lengthOfArrayLike$2(O);
5746
- var A = arraySpeciesCreate(O, 0);
5747
- A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
5748
- return A;
5767
+ let _$6 = t => t,
5768
+ _t$6,
5769
+ _t2$4,
5770
+ _t3$3,
5771
+ _t4$3,
5772
+ _t5$2,
5773
+ _t6$2,
5774
+ _t7$1,
5775
+ _t8$1,
5776
+ _t9$1,
5777
+ _t10$1,
5778
+ _t11$1,
5779
+ _t12$1,
5780
+ _t13$1,
5781
+ _t14$1,
5782
+ _t15$1,
5783
+ _t16;
5784
+ const ReviewItem = styled.div(_t$6 || (_t$6 = _$6`
5785
+ display: flex;
5786
+ flex-direction: column;
5787
+ border: var(--goa-border-width-s) solid grey;
5788
+ border-radius: var(--goa-border-radius-m);
5789
+ margin: var(--goa-space-2xs);
5790
+ padding: var(--goa-space-xs);
5791
+ div:empty {
5792
+ display: none;
5749
5793
  }
5750
- });
5751
-
5752
- // this method was added to unscopables after implementation
5753
- // in popular engines, so it's moved to a separate module
5754
- var addToUnscopables = addToUnscopables$4;
5794
+ `));
5795
+ const ReviewItemSection = styled.div(_t2$4 || (_t2$4 = _$6`
5796
+ background-color: #f1f1f1;
5797
+ margin-bottom: var(--goa-space-m);
5798
+ padding: var(--goa-space-m);
5799
+ border: 1px solid #dcdcdc;
5800
+ border-radius: 5px;
5755
5801
 
5756
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
5757
- addToUnscopables('flat');
5802
+ .element-style {
5803
+ max-width: 1600px;
5804
+ }
5805
+ `));
5806
+ const ReviewItemHeader = styled.div(_t3$3 || (_t3$3 = _$6`
5807
+ display: flex;
5808
+ align-items: center;
5809
+ justify-content: space-between;
5810
+ margin-bottom: var(--goa-space-xl);
5811
+ `));
5812
+ const ReviewItemTitle = styled.div(_t4$3 || (_t4$3 = _$6`
5813
+ font-size: var(--goa-space-l);
5814
+ line-height: var(--goa-space-xl);
5815
+ font-weight: 300;
5816
+ `));
5817
+ const Anchor = styled.div(_t5$2 || (_t5$2 = _$6`
5818
+ color: #0070c4;
5819
+ text-decoration: underline;
5820
+ outline: none;
5821
+ cursor: pointer;
5758
5822
 
5759
- // eslint-disable-next-line
5760
- const getProperty = (obj, propName) => {
5761
- if (obj[propName] !== undefined) return obj[propName];
5762
- for (const key in obj) {
5763
- if (typeof obj[key] === 'object' && obj[key] !== null) {
5764
- const result = getProperty(obj[key], propName);
5765
- if (result !== undefined) return result;
5766
- }
5823
+ &:focus {
5824
+ outline: 2px solid #0070c4;
5825
+ background-color: #e6f7ff;
5767
5826
  }
5768
- };
5769
- // eslint-disable-next-line
5770
- const pickPropertyValues = (obj, property, endWithType) => {
5771
- let values = [];
5772
- Object.keys(obj).forEach(function (key) {
5773
- var _a;
5774
- if (key === property) {
5775
- values.push(obj[key]);
5776
- } else if (_$c.isObject(obj[key])) {
5777
- // if the object type is equal to end type, we are not going to continue the recursive approach
5778
- if (endWithType && ((_a = obj[key]) === null || _a === void 0 ? void 0 : _a.type) === endWithType) {
5779
- if (property in obj[key]) {
5780
- values.push(obj[key][property]);
5781
- }
5782
- } else {
5783
- values = [...values, ...pickPropertyValues(obj[key], property, endWithType)];
5827
+ `));
5828
+ styled.div(_t6$2 || (_t6$2 = _$6`
5829
+ margin-left: var(--goa-space-m);
5830
+ `));
5831
+ styled.div(_t7$1 || (_t7$1 = _$6`
5832
+ margin-bottom: var(--goa-space-m);
5833
+ `));
5834
+ styled.div(_t8$1 || (_t8$1 = _$6`
5835
+ margin: var(--goa-space-s);
5836
+ width: 100%;
5837
+ `));
5838
+ styled.h3(_t9$1 || (_t9$1 = _$6`
5839
+ text-transform: capitalize;
5840
+ `));
5841
+ const RightAlignmentDiv = styled.div(_t10$1 || (_t10$1 = _$6`
5842
+ @media screen and (max-width: 767px) {
5843
+ margin-bottom: var(--goa-space-l);
5844
+ }
5845
+ @media screen and (min-width: 768px) {
5846
+ display: flex;
5847
+ justify-content: flex-end;
5848
+ margin-bottom: var(--goa-space-l);
5849
+ }
5850
+ `));
5851
+ const FormStepperSummaryH3 = styled.h3(_t11$1 || (_t11$1 = _$6`
5852
+ flex: 1;
5853
+ margin-bottom: var(--goa-space-m);
5854
+ font-size: var(--goa-font-size-7);
5855
+ line-height: var(--goa-line-height-4);
5856
+ font-weight: var(--goa-font-weight-regular);
5857
+ `));
5858
+ const PageRenderPadding = styled.h3(_t12$1 || (_t12$1 = _$6`
5859
+ margin-top: var(--goa-space-2xl);
5860
+ `));
5861
+ const PageBorder = styled.h3(_t13$1 || (_t13$1 = _$6`
5862
+ padding: var(--goa-space-3xl);
5863
+ `));
5864
+ const TableReviewItemSection = styled.div(_t14$1 || (_t14$1 = _$6`
5865
+ .element-style {
5866
+ max-width: 1600px;
5867
+ }
5868
+ `));
5869
+ const TableReviewItem = styled.div(_t15$1 || (_t15$1 = _$6`
5870
+ border: 1px solid #dcdcdc;
5871
+ border-radius: 5px;
5872
+ padding: var(--goa-space-2xl);
5873
+ `));
5874
+ const TableReviewCategoryLabel = styled.h3(_t16 || (_t16 = _$6`
5875
+ color: var(--goa-color-text-secondary) !important;
5876
+ `));
5877
+
5878
+ class ContextProviderClass {
5879
+ addDataByUrl(key, url, processDataFunction, token) {
5880
+ return __awaiter(this, void 0, void 0, function* () {
5881
+ let header = {};
5882
+ const [requestId, axiosWithConfig] = this.getAxiosInterceptorConfig(axios);
5883
+ if (token) {
5884
+ header = Object.assign(Object.assign({}, header), {
5885
+ Authorization: `Bearer ${token}`
5886
+ });
5784
5887
  }
5785
- } else if (_$c.isArray(obj[key])) {
5786
- const nextValues = obj[key].map(function (arrayObj) {
5787
- return pickPropertyValues(arrayObj, property, endWithType);
5888
+ yield axiosWithConfig.get(url, header).then(response => {
5889
+ const processedData = processDataFunction(response.data);
5890
+ this.enumValues.set(key, () => processedData);
5891
+ }).catch(err => {
5892
+ if (err.message.includes('CORS')) {
5893
+ console.warn(err.message);
5894
+ } else {
5895
+ console.warn(`addDataByUrl: ${err.message}`);
5896
+ }
5788
5897
  });
5789
- values = [...values, ...nextValues];
5790
- }
5791
- });
5792
- return values;
5793
- };
5794
-
5795
- const FormStepperReviewer = props => {
5796
- var _a, _b, _c;
5797
- const {
5798
- uischema,
5799
- data,
5800
- schema,
5801
- ajv,
5802
- cells,
5803
- enabled,
5804
- navigationFunc
5805
- } = props;
5806
- const componentProps = (_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) !== null && _b !== void 0 ? _b : {};
5807
- const readOnly = (_c = componentProps === null || componentProps === void 0 ? void 0 : componentProps.readOnly) !== null && _c !== void 0 ? _c : false;
5808
- const categorization = uischema;
5809
- const categories = categorization.elements.filter(category => isVisible(category, data, '', ajv));
5810
- const rescopeMaps = ['#/properties/albertaAddress', '#/properties/canadianAddress', '#/properties/sin'];
5811
- return jsx(ReviewItem, {
5812
- children: categories.map((category, index) => {
5813
- const categoryLabel = category.label || category.i18n || 'Unknown Category';
5814
- const testId = `${categoryLabel}-review-link`;
5815
- return jsxs(ReviewItemSection, {
5816
- children: [jsxs(ReviewItemHeader, {
5817
- children: [jsx(ReviewItemTitle, {
5818
- children: categoryLabel
5819
- }), navigationFunc && jsx(Anchor, {
5820
- onClick: () => {
5821
- navigationFunc(index);
5822
- },
5823
- "data-testid": testId,
5824
- onKeyDown: e => {
5825
- if (!readOnly && (e.key === ' ' || e.key === 'Enter')) {
5826
- e.preventDefault();
5827
- navigationFunc(index);
5828
- }
5829
- },
5830
- children: readOnly ? 'View' : 'Edit'
5831
- })]
5832
- }), jsx(GoAGrid, {
5833
- minChildWidth: "100%",
5834
- children: category.elements.filter(field => {
5835
- var _a, _b;
5836
- // [TODO] we need to double check why we cannot hide the elements at the element level
5837
- const conditionProps = (_a = field.rule) === null || _a === void 0 ? void 0 : _a.condition;
5838
- /* istanbul ignore next */
5839
- if (conditionProps && data) {
5840
- const canHideControlParts = (_b = conditionProps === null || conditionProps === void 0 ? void 0 : conditionProps.scope) === null || _b === void 0 ? void 0 : _b.split('/');
5841
- const canHideControl = canHideControlParts && canHideControlParts[(canHideControlParts === null || canHideControlParts === void 0 ? void 0 : canHideControlParts.length) - 1];
5842
- const isHidden = getProperty(data, canHideControl);
5843
- if (!isHidden) {
5844
- return field;
5845
- }
5846
- } else {
5847
- return field;
5848
- }
5849
- }).map(e => {
5850
- const layout = e;
5851
- if (rescopeMaps.some(scope => {
5852
- var _a;
5853
- return (_a = layout.elements) === null || _a === void 0 ? void 0 : _a.map(el => {
5854
- const element = el;
5855
- return element.scope;
5856
- }).includes(scope);
5857
- })) {
5858
- return layout.elements;
5859
- } else {
5860
- return e;
5861
- }
5862
- }).flat().map((element, index) => {
5863
- return jsx("div", {
5864
- className: "element-style",
5865
- children: jsx(JsonFormsDispatch, {
5866
- "data-testid": `jsonforms-object-list-defined-elements-dispatch`,
5867
- schema: schema,
5868
- uischema: element,
5869
- enabled: enabled,
5870
- renderers: GoAReviewRenderers,
5871
- cells: cells
5872
- })
5873
- }, `form-stepper-category-${index}`);
5874
- })
5875
- })]
5876
- }, index);
5877
- })
5878
- });
5879
- };
5880
- const FormStepperReviewControl = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepperReviewer)));
5881
-
5882
- const isErrorPathIncluded = (errorPaths, path) => {
5883
- return errorPaths.some(ePath => {
5884
- /**
5885
- * case A: errorPaths: [name] path: [name]
5886
- *
5887
- * case B: errorPath: [name] path: [name.firstName]
5888
- * */
5889
- return ePath === path || path.startsWith(ePath + '.');
5890
- });
5891
- };
5892
- function isNumber(value) {
5893
- return value != null && value !== '' && !isNaN(Number(value.toString()));
5894
- }
5895
- const getIncompletePaths = (ajv, scopes) => {
5896
- var _a;
5897
- const requiredErrorPaths = (_a = ajv === null || ajv === void 0 ? void 0 : ajv.errors) === null || _a === void 0 ? void 0 : _a.filter(e => e.keyword === 'required' || e.keyword === 'minLength').map(e => {
5898
- return getControlPath(e);
5899
- });
5900
- const _scopes = scopes.map(scope => toDataPath(scope)).filter(path => requiredErrorPaths && isErrorPathIncluded(requiredErrorPaths, path));
5901
- return _scopes;
5902
- };
5903
- const subErrorInParent = (error, paths) => {
5904
- /*
5905
- Detect is there sub error in an object array.
5906
- For example: error with instance path /roadmap/0/when belongs to /roadmap
5907
- */
5908
- const errorPaths = error.instancePath.split('/');
5909
- if (errorPaths.length < 2) return false;
5910
- // For case /roadmap/0
5911
- if (errorPaths.length > 1 && isNumber(errorPaths[errorPaths.length - 1])) {
5912
- const parentPath = errorPaths.slice(0, errorPaths.length - 1).join('/');
5913
- return paths.includes(parentPath);
5914
- }
5915
- // For case /roadmap/0/when
5916
- if (errorPaths.length > 2 && isNumber(errorPaths[errorPaths.length - 2])) {
5917
- const parentPath = errorPaths.slice(0, errorPaths.length - 2).join('/');
5918
- return paths.includes(parentPath);
5898
+ axiosWithConfig.interceptors.request.eject(requestId);
5899
+ });
5919
5900
  }
5920
- return false;
5921
- };
5922
- const getErrorsInScopes = (errors, scopes) => {
5923
- return errors.filter(e => {
5924
- // transfer scope #properties/value to data path /value
5925
- const dataPaths = scopes.map(s => '/' + toDataPath(s));
5926
- return dataPaths.includes(e.instancePath) || subErrorInParent(e, dataPaths);
5927
- });
5928
- };
5929
-
5930
- const stepperReducer = (state, action) => {
5931
- const {
5932
- activeId,
5933
- categories
5934
- } = state;
5935
- const lastId = categories[categories.length - 1].id;
5936
- switch (action.type) {
5937
- case 'update/uischema':
5938
- {
5939
- return Object.assign({}, action.payload.state);
5940
- }
5941
- case 'page/next':
5942
- {
5943
- state.activeId += 1;
5944
- if (activeId === lastId) {
5945
- state.isOnReview = true;
5946
- state.hasNextButton = false;
5947
- state.hasPrevButton = false;
5948
- } else {
5949
- state.hasNextButton = true;
5950
- state.hasPrevButton = true;
5951
- state.isOnReview = false;
5952
- }
5953
- state.categories[activeId].isVisited = true;
5954
- return Object.assign({}, state);
5955
- }
5956
- case 'page/prev':
5957
- {
5958
- state.categories[activeId].isVisited = true;
5959
- if (activeId > 0) {
5960
- state.activeId -= 1;
5961
- state.hasPrevButton = state.activeId !== 0;
5962
- state.hasNextButton = true;
5963
- state.isOnReview = false;
5964
- }
5965
- return Object.assign({}, state);
5966
- }
5967
- case 'page/to/index':
5968
- {
5901
+ constructor() {
5902
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5903
+ this.enumValues = new Map();
5904
+ this.enumFunctions = new Map();
5905
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5906
+ this.enumSubmitFunctions = new Map();
5907
+ this.addFormContextData = (key, data) => {
5908
+ this.enumValues.set(key, () => data);
5909
+ };
5910
+ this.setup = props => {
5911
+ var _a, _b;
5912
+ this.selfProps = props;
5913
+ if (props.fileManagement) {
5969
5914
  const {
5970
- id
5971
- } = action.payload;
5972
- state.activeId = id;
5973
- if (id > lastId) {
5974
- state.isOnReview = true;
5975
- state.hasNextButton = false;
5976
- state.hasPrevButton = true;
5977
- return Object.assign({}, state);
5978
- } else {
5979
- state.categories[id].isVisited = true;
5980
- state.hasNextButton = id <= lastId;
5981
- state.hasPrevButton = id !== 0;
5982
- state.isOnReview = false;
5983
- state.maxReachedStep = Math.max(state.maxReachedStep, activeId);
5984
- return Object.assign({}, state);
5985
- }
5915
+ fileList,
5916
+ uploadFile,
5917
+ downloadFile,
5918
+ deleteFile
5919
+ } = props.fileManagement;
5920
+ this.enumValues.set('file-list', () => fileList);
5921
+ this.enumFunctions.set('upload-file', () => uploadFile);
5922
+ this.enumFunctions.set('download-file', () => downloadFile);
5923
+ this.enumFunctions.set('delete-file', () => deleteFile);
5986
5924
  }
5987
- case 'update/category':
5988
- {
5925
+ if (props.submit) {
5989
5926
  const {
5990
- id,
5991
- ajv,
5992
- errors
5993
- } = action.payload;
5994
- /*
5995
- ctx.core.errors only includes required errors when the fields are touched. In this case, we still ajv to figure out the required errors at the very beginning.
5996
- */
5997
- const incompletePaths = getIncompletePaths(ajv, state.categories[id].scopes);
5998
- const errorsInCategory = getErrorsInScopes(errors, state.categories[id].scopes || []);
5999
- state.categories[id].isCompleted = (incompletePaths === null || incompletePaths === void 0 ? void 0 : incompletePaths.length) === 0;
6000
- state.categories[id].isValid = errorsInCategory.length === 0;
6001
- state.categories[id].isVisited = true;
6002
- return Object.assign({}, state);
5927
+ submitForm
5928
+ } = props.submit;
5929
+ const submitFunction = submitForm;
5930
+ this.enumSubmitFunctions.set('submit-form', () => submitFunction);
6003
5931
  }
6004
- case 'validate/form':
6005
- {
6006
- const {
6007
- errors
6008
- } = action.payload;
6009
- state.isValid = errors.length === 0;
6010
- return Object.assign({}, state);
5932
+ if (props.data) {
5933
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5934
+ Object.keys(props.data).forEach(item => {
5935
+ this.enumValues.set(item, () => props.data[item]);
5936
+ });
6011
5937
  }
6012
- default:
6013
- return state;
5938
+ if (!props.children) {
5939
+ return null;
5940
+ }
5941
+ if (props.formUrl) {
5942
+ this.baseEnumerator.formUrl = props.formUrl;
5943
+ }
5944
+ this.baseEnumerator.isFormSubmitted = (_a = props.isFormSubmitted) !== null && _a !== void 0 ? _a : false;
5945
+ return jsx(JsonFormContext.Provider, {
5946
+ value: this.baseEnumerator,
5947
+ children: (_b = this.selfProps) === null || _b === void 0 ? void 0 : _b.children
5948
+ });
5949
+ };
5950
+ this.getContextProvider = () => {
5951
+ var _a;
5952
+ return jsx(JsonFormContext.Provider, {
5953
+ value: this.baseEnumerator,
5954
+ children: (_a = this.selfProps) === null || _a === void 0 ? void 0 : _a.children
5955
+ });
5956
+ };
5957
+ this.getFormUrl = () => {
5958
+ var _a;
5959
+ return (_a = this.selfProps) === null || _a === void 0 ? void 0 : _a.formUrl;
5960
+ };
5961
+ this.getAxiosInterceptorConfig = axios => {
5962
+ const requestId = axios.interceptors.request.use(req => {
5963
+ if (req.data === undefined) {
5964
+ throw new Error(`The URL: ${req.url} encountered a CORS error.`);
5965
+ }
5966
+ return req;
5967
+ });
5968
+ return [requestId, axios];
5969
+ };
5970
+ /**
5971
+ * Grabs data stored under a given key
5972
+ *
5973
+ */
5974
+ this.getFormContextData = key => {
5975
+ const dataFunction = this.baseEnumerator.data.get(key);
5976
+ return dataFunction && dataFunction();
5977
+ };
5978
+ /**
5979
+ * Grabs all data
5980
+ *
5981
+ */
5982
+ this.getAllFormContextData = () => {
5983
+ const allData = [];
5984
+ this.baseEnumerator.data.forEach((d, key) => {
5985
+ allData.push({
5986
+ [key]: d()
5987
+ });
5988
+ });
5989
+ return allData;
5990
+ };
5991
+ this.baseEnumerator = {
5992
+ data: this.enumValues,
5993
+ functions: this.enumFunctions,
5994
+ submitFunction: this.enumSubmitFunctions,
5995
+ addFormContextData: this.addFormContextData,
5996
+ getFormContextData: this.getFormContextData,
5997
+ getAllFormContextData: this.getAllFormContextData,
5998
+ formUrl: this.getFormUrl()
5999
+ };
6000
+ this.selfProps = {};
6014
6001
  }
6015
- };
6002
+ }
6003
+ const ContextProviderC = new ContextProviderClass();
6004
+ const ContextProviderFactory = () => new ContextProviderClass().setup;
6005
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6006
+ const JsonFormContext = /*#__PURE__*/createContext(null);
6016
6007
 
6017
- const createStepperContextInitData = props => {
6018
- var _a;
6019
- const {
6020
- uischema,
6021
- data,
6022
- schema,
6023
- ajv,
6024
- t,
6025
- visible,
6026
- path
6027
- } = props;
6028
- const categorization = uischema;
6029
- const valid = ajv.validate(schema, data || {});
6030
- const categories = (_a = categorization.elements) === null || _a === void 0 ? void 0 : _a.map((c, id) => {
6031
- const scopes = pickPropertyValues(c, 'scope', 'ListWithDetail');
6032
- const incompletePaths = getIncompletePaths(ajv, scopes);
6033
- return {
6034
- id,
6035
- label: deriveLabelForUISchemaElement(c, t),
6036
- scopes,
6037
- isVisited: false,
6038
- isCompleted: (incompletePaths === null || incompletePaths === void 0 ? void 0 : incompletePaths.length) === 0,
6039
- isValid: (incompletePaths === null || incompletePaths === void 0 ? void 0 : incompletePaths.length) === 0,
6040
- uischema: c,
6041
- isEnabled: isEnabled(c, data, '', ajv),
6042
- visible
6043
- };
6008
+ const RenderStepElements = props => {
6009
+ return jsx(Visible, {
6010
+ visible: props.visible,
6011
+ "date-testid": `${props.path}-categories-${props.categoryIndex}`,
6012
+ children: props.category.elements.map((uiSchema, index) => {
6013
+ return jsx(JsonFormsDispatch, {
6014
+ schema: props.schema,
6015
+ uischema: uiSchema,
6016
+ renderers: props.renderers,
6017
+ cells: props.cells,
6018
+ path: props.path,
6019
+ visible: props.visible,
6020
+ enabled: props.enabled
6021
+ }, `${props.path}-category-page-${index}`);
6022
+ })
6044
6023
  });
6045
- const activeId = (props === null || props === void 0 ? void 0 : props.activeId) || 0;
6046
- return {
6047
- categories: categories,
6048
- activeId,
6049
- hasNextButton: activeId !== (categories === null || categories === void 0 ? void 0 : categories.length),
6050
- hasPrevButton: activeId > 0 && activeId !== (categories === null || categories === void 0 ? void 0 : categories.length),
6051
- path,
6052
- isOnReview: activeId === (categories === null || categories === void 0 ? void 0 : categories.length),
6053
- isValid: valid === true,
6054
- maxReachedStep: 0
6024
+ };
6025
+
6026
+ var uncurryThis$3 = functionUncurryThisClause;
6027
+ var aCallable$6 = aCallable$9;
6028
+ var NATIVE_BIND = functionBindNative;
6029
+
6030
+ var bind$5 = uncurryThis$3(uncurryThis$3.bind);
6031
+
6032
+ // optional / simple context binding
6033
+ var functionBindContext = function (fn, that) {
6034
+ aCallable$6(fn);
6035
+ return that === undefined ? fn : NATIVE_BIND ? bind$5(fn, that) : function (/* ...args */) {
6036
+ return fn.apply(that, arguments);
6055
6037
  };
6056
6038
  };
6057
- const JsonFormsStepperContext = /*#__PURE__*/createContext(undefined);
6058
- const JsonFormsStepperContextProvider = ({
6059
- children,
6060
- StepperProps
6061
- }) => {
6062
- var _a;
6063
- const ctx = useJsonForms();
6064
- const {
6065
- schema,
6066
- ajv
6067
- } = StepperProps;
6068
- const [stepperState, dispatch] = useReducer(stepperReducer, createStepperContextInitData(StepperProps));
6069
- const stepperDispatch = (StepperProps === null || StepperProps === void 0 ? void 0 : StepperProps.customDispatch) || dispatch;
6070
- const context = useMemo(() => {
6071
- return {
6072
- isProvided: true,
6073
- stepperDispatch,
6074
- selectStepperState: () => {
6075
- return stepperState;
6076
- },
6077
- selectIsDisabled: () => {
6078
- var _a;
6079
- const category = (_a = stepperState.categories) === null || _a === void 0 ? void 0 : _a[stepperState.activeId];
6080
- return category === undefined ? false : !(category === null || category === void 0 ? void 0 : category.isEnabled);
6081
- },
6082
- selectIsActive: id => {
6083
- return id === stepperState.activeId;
6084
- },
6085
- selectPath: () => {
6086
- return stepperState.path;
6087
- },
6088
- selectCategory: id => {
6089
- return stepperState.categories[id];
6090
- },
6091
- validatePage: id => {
6092
- var _a;
6093
- stepperDispatch({
6094
- type: 'update/category',
6095
- payload: {
6096
- errors: (_a = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _a === void 0 ? void 0 : _a.errors,
6097
- id,
6098
- ajv
6099
- }
6100
- });
6101
- },
6102
- goToPage: (id, updateCategoryId) => {
6103
- var _a, _b, _c;
6104
- ajv.validate(schema, ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.data) || {});
6105
- if (stepperState.isOnReview !== true) {
6106
- for (let i = 0; i < id; i++) {
6107
- stepperDispatch({
6108
- type: 'update/category',
6109
- payload: {
6110
- errors: (_b = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _b === void 0 ? void 0 : _b.errors,
6111
- id: i,
6112
- ajv
6113
- }
6114
- });
6115
- }
6116
- }
6117
- stepperDispatch({
6118
- type: 'validate/form',
6119
- payload: {
6120
- errors: (_c = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _c === void 0 ? void 0 : _c.errors
6121
- }
6122
- });
6123
- stepperDispatch({
6124
- type: 'page/to/index',
6125
- payload: {
6126
- id
6127
- }
6128
- });
6039
+
6040
+ var isArray$1 = isArray$4;
6041
+ var lengthOfArrayLike$3 = lengthOfArrayLike$7;
6042
+ var doesNotExceedSafeInteger = doesNotExceedSafeInteger$2;
6043
+ var bind$4 = functionBindContext;
6044
+
6045
+ // `FlattenIntoArray` abstract operation
6046
+ // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
6047
+ var flattenIntoArray$1 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
6048
+ var targetIndex = start;
6049
+ var sourceIndex = 0;
6050
+ var mapFn = mapper ? bind$4(mapper, thisArg) : false;
6051
+ var element, elementLen;
6052
+
6053
+ while (sourceIndex < sourceLen) {
6054
+ if (sourceIndex in source) {
6055
+ element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
6056
+
6057
+ if (depth > 0 && isArray$1(element)) {
6058
+ elementLen = lengthOfArrayLike$3(element);
6059
+ targetIndex = flattenIntoArray$1(target, original, element, elementLen, targetIndex, depth - 1) - 1;
6060
+ } else {
6061
+ doesNotExceedSafeInteger(targetIndex + 1);
6062
+ target[targetIndex] = element;
6129
6063
  }
6130
- };
6131
- }, [stepperDispatch, stepperState, (_a = ctx.core) === null || _a === void 0 ? void 0 : _a.errors]);
6132
- useEffect(() => {
6133
- if ((context === null || context === void 0 ? void 0 : context.isProvided) === true) {
6134
- /* The block is used to cache the state for the tenant web app review editor */
6135
- stepperDispatch({
6136
- type: 'update/uischema',
6137
- payload: {
6138
- state: createStepperContextInitData(Object.assign(Object.assign({}, StepperProps), {
6139
- activeId: stepperState === null || stepperState === void 0 ? void 0 : stepperState.activeId
6140
- }))
6141
- }
6142
- });
6143
- context.goToPage(stepperState.maxReachedStep);
6144
- context.goToPage(stepperState.activeId);
6064
+
6065
+ targetIndex++;
6066
+ }
6067
+ sourceIndex++;
6068
+ }
6069
+ return targetIndex;
6070
+ };
6071
+
6072
+ var flattenIntoArray_1 = flattenIntoArray$1;
6073
+
6074
+ var uncurryThis$2 = functionUncurryThis;
6075
+ var fails$3 = fails$s;
6076
+ var isCallable$4 = isCallable$q;
6077
+ var classof$2 = classof$9;
6078
+ var getBuiltIn$2 = getBuiltIn$9;
6079
+ var inspectSource$1 = inspectSource$3;
6080
+
6081
+ var noop = function () { /* empty */ };
6082
+ var construct = getBuiltIn$2('Reflect', 'construct');
6083
+ var constructorRegExp = /^\s*(?:class|function)\b/;
6084
+ var exec$1 = uncurryThis$2(constructorRegExp.exec);
6085
+ var INCORRECT_TO_STRING = !constructorRegExp.test(noop);
6086
+
6087
+ var isConstructorModern = function isConstructor(argument) {
6088
+ if (!isCallable$4(argument)) return false;
6089
+ try {
6090
+ construct(noop, [], argument);
6091
+ return true;
6092
+ } catch (error) {
6093
+ return false;
6094
+ }
6095
+ };
6096
+
6097
+ var isConstructorLegacy = function isConstructor(argument) {
6098
+ if (!isCallable$4(argument)) return false;
6099
+ switch (classof$2(argument)) {
6100
+ case 'AsyncFunction':
6101
+ case 'GeneratorFunction':
6102
+ case 'AsyncGeneratorFunction': return false;
6103
+ }
6104
+ try {
6105
+ // we can't check .prototype since constructors produced by .bind haven't it
6106
+ // `Function#toString` throws on some built-it function in some legacy engines
6107
+ // (for example, `DOMQuad` and similar in FF41-)
6108
+ return INCORRECT_TO_STRING || !!exec$1(constructorRegExp, inspectSource$1(argument));
6109
+ } catch (error) {
6110
+ return true;
6111
+ }
6112
+ };
6113
+
6114
+ isConstructorLegacy.sham = true;
6115
+
6116
+ // `IsConstructor` abstract operation
6117
+ // https://tc39.es/ecma262/#sec-isconstructor
6118
+ var isConstructor$2 = !construct || fails$3(function () {
6119
+ var called;
6120
+ return isConstructorModern(isConstructorModern.call)
6121
+ || !isConstructorModern(Object)
6122
+ || !isConstructorModern(function () { called = true; })
6123
+ || called;
6124
+ }) ? isConstructorLegacy : isConstructorModern;
6125
+
6126
+ var isArray = isArray$4;
6127
+ var isConstructor$1 = isConstructor$2;
6128
+ var isObject$2 = isObject$e;
6129
+ var wellKnownSymbol$5 = wellKnownSymbol$k;
6130
+
6131
+ var SPECIES$2 = wellKnownSymbol$5('species');
6132
+ var $Array = Array;
6133
+
6134
+ // a part of `ArraySpeciesCreate` abstract operation
6135
+ // https://tc39.es/ecma262/#sec-arrayspeciescreate
6136
+ var arraySpeciesConstructor$1 = function (originalArray) {
6137
+ var C;
6138
+ if (isArray(originalArray)) {
6139
+ C = originalArray.constructor;
6140
+ // cross-realm fallback
6141
+ if (isConstructor$1(C) && (C === $Array || isArray(C.prototype))) C = undefined;
6142
+ else if (isObject$2(C)) {
6143
+ C = C[SPECIES$2];
6144
+ if (C === null) C = undefined;
6145
6145
  }
6146
- }, [JSON.stringify(StepperProps.uischema), JSON.stringify(StepperProps.schema)]);
6147
- return jsx(JsonFormsStepperContext.Provider, {
6148
- value: context,
6149
- children: children
6146
+ } return C === undefined ? $Array : C;
6147
+ };
6148
+
6149
+ var arraySpeciesConstructor = arraySpeciesConstructor$1;
6150
+
6151
+ // `ArraySpeciesCreate` abstract operation
6152
+ // https://tc39.es/ecma262/#sec-arrayspeciescreate
6153
+ var arraySpeciesCreate$1 = function (originalArray, length) {
6154
+ return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
6155
+ };
6156
+
6157
+ var $$a = _export;
6158
+ var flattenIntoArray = flattenIntoArray_1;
6159
+ var toObject$1 = toObject$8;
6160
+ var lengthOfArrayLike$2 = lengthOfArrayLike$7;
6161
+ var toIntegerOrInfinity = toIntegerOrInfinity$7;
6162
+ var arraySpeciesCreate = arraySpeciesCreate$1;
6163
+
6164
+ // `Array.prototype.flat` method
6165
+ // https://tc39.es/ecma262/#sec-array.prototype.flat
6166
+ $$a({ target: 'Array', proto: true }, {
6167
+ flat: function flat(/* depthArg = 1 */) {
6168
+ var depthArg = arguments.length ? arguments[0] : undefined;
6169
+ var O = toObject$1(this);
6170
+ var sourceLen = lengthOfArrayLike$2(O);
6171
+ var A = arraySpeciesCreate(O, 0);
6172
+ A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
6173
+ return A;
6174
+ }
6175
+ });
6176
+
6177
+ // this method was added to unscopables after implementation
6178
+ // in popular engines, so it's moved to a separate module
6179
+ var addToUnscopables = addToUnscopables$4;
6180
+
6181
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
6182
+ addToUnscopables('flat');
6183
+
6184
+ const FormStepperReviewer = props => {
6185
+ var _a, _b, _c;
6186
+ const {
6187
+ uischema,
6188
+ data,
6189
+ schema,
6190
+ ajv,
6191
+ cells,
6192
+ enabled,
6193
+ navigationFunc
6194
+ } = props;
6195
+ const componentProps = (_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) !== null && _b !== void 0 ? _b : {};
6196
+ const readOnly = (_c = componentProps === null || componentProps === void 0 ? void 0 : componentProps.readOnly) !== null && _c !== void 0 ? _c : false;
6197
+ const categorization = uischema;
6198
+ const categories = categorization.elements.filter(category => isVisible(category, data, '', ajv));
6199
+ const rescopeMaps = ['#/properties/albertaAddress', '#/properties/canadianAddress', '#/properties/sin'];
6200
+ return jsx(ReviewItem, {
6201
+ children: categories.map((category, index) => {
6202
+ const categoryLabel = category.label || category.i18n || 'Unknown Category';
6203
+ const testId = `${categoryLabel}-review-link`;
6204
+ return jsxs(ReviewItemSection, {
6205
+ children: [jsxs(ReviewItemHeader, {
6206
+ children: [jsx(ReviewItemTitle, {
6207
+ children: categoryLabel
6208
+ }), navigationFunc && jsx(Anchor, {
6209
+ onClick: () => {
6210
+ navigationFunc(index);
6211
+ },
6212
+ "data-testid": testId,
6213
+ onKeyDown: e => {
6214
+ if (!readOnly && (e.key === ' ' || e.key === 'Enter')) {
6215
+ e.preventDefault();
6216
+ navigationFunc(index);
6217
+ }
6218
+ },
6219
+ children: readOnly ? 'View' : 'Edit'
6220
+ })]
6221
+ }), jsx(GoAGrid, {
6222
+ minChildWidth: "100%",
6223
+ children: category.elements.filter(field => {
6224
+ var _a, _b;
6225
+ // [TODO] we need to double check why we cannot hide the elements at the element level
6226
+ const conditionProps = (_a = field.rule) === null || _a === void 0 ? void 0 : _a.condition;
6227
+ /* istanbul ignore next */
6228
+ if (conditionProps && data) {
6229
+ const canHideControlParts = (_b = conditionProps === null || conditionProps === void 0 ? void 0 : conditionProps.scope) === null || _b === void 0 ? void 0 : _b.split('/');
6230
+ const canHideControl = canHideControlParts && canHideControlParts[(canHideControlParts === null || canHideControlParts === void 0 ? void 0 : canHideControlParts.length) - 1];
6231
+ const isHidden = getProperty(data, canHideControl);
6232
+ if (!isHidden) {
6233
+ return field;
6234
+ }
6235
+ } else {
6236
+ return field;
6237
+ }
6238
+ }).map(e => {
6239
+ const layout = e;
6240
+ if (rescopeMaps.some(scope => {
6241
+ var _a;
6242
+ return (_a = layout.elements) === null || _a === void 0 ? void 0 : _a.map(el => {
6243
+ const element = el;
6244
+ return element.scope;
6245
+ }).includes(scope);
6246
+ })) {
6247
+ return layout.elements;
6248
+ } else {
6249
+ return e;
6250
+ }
6251
+ }).flat().map((element, index) => {
6252
+ return jsx("div", {
6253
+ className: "element-style",
6254
+ children: jsx(JsonFormsDispatch, {
6255
+ "data-testid": `jsonforms-object-list-defined-elements-dispatch`,
6256
+ schema: schema,
6257
+ uischema: element,
6258
+ enabled: enabled,
6259
+ renderers: GoAReviewRenderers,
6260
+ cells: cells
6261
+ })
6262
+ }, `form-stepper-category-${index}`);
6263
+ })
6264
+ })]
6265
+ }, index);
6266
+ })
6150
6267
  });
6151
6268
  };
6269
+ const FormStepperReviewControl = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepperReviewer)));
6152
6270
 
6153
6271
  const summaryLabel = 'Summary';
6154
6272
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -6195,6 +6313,7 @@ const FormStepperView = props => {
6195
6313
  const submitForm = submitFormFunction && submitFormFunction();
6196
6314
  const optionProps = uischema.options || {};
6197
6315
  const [isOpen, setIsOpen] = useState(false);
6316
+ const [staleCategories, setStaleCategories] = React.useState(categories);
6198
6317
  const handleSubmit = () => {
6199
6318
  if (submitForm) {
6200
6319
  submitForm(data);
@@ -6202,6 +6321,9 @@ const FormStepperView = props => {
6202
6321
  setIsOpen(true);
6203
6322
  }
6204
6323
  };
6324
+ useEffect(() => {
6325
+ setStaleCategories(categories);
6326
+ }, [categories]);
6205
6327
  const onCloseModal = () => {
6206
6328
  setIsOpen(false);
6207
6329
  };
@@ -6214,7 +6336,7 @@ const FormStepperView = props => {
6214
6336
  children: jsxs("div", {
6215
6337
  id: `${path || `goa`}-form-stepper`,
6216
6338
  className: "formStepper",
6217
- children: [jsxs(GoAFormStepper, {
6339
+ children: [categories.length === staleCategories.length && jsxs(GoAFormStepper, {
6218
6340
  testId: `form-stepper-headers-${(_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.testId}` || 'form-stepper-test',
6219
6341
  onChange: step => {
6220
6342
  goToPage(step - 1);
@@ -6373,6 +6495,84 @@ const BackButton = ({
6373
6495
  });
6374
6496
  };
6375
6497
 
6498
+ const FormStepperPageReviewer = props => {
6499
+ var _a, _b;
6500
+ const {
6501
+ uischema,
6502
+ data,
6503
+ schema,
6504
+ ajv,
6505
+ cells,
6506
+ enabled,
6507
+ navigationFunc
6508
+ } = props;
6509
+ (_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) !== null && _b !== void 0 ? _b : {};
6510
+ const categorization = uischema;
6511
+ const categories = categorization.elements.filter(category => isVisible(category, data, '', ajv));
6512
+ const rescopeMaps = ['#/properties/albertaAddress', '#/properties/canadianAddress', '#/properties/sin'];
6513
+ return jsxs(TableReviewItem, {
6514
+ children: [jsx("h2", {
6515
+ children: "Review your answers"
6516
+ }), categories.map((category, index) => {
6517
+ const categoryLabel = category.label || category.i18n || 'Unknown Category';
6518
+ return jsxs(Fragment, {
6519
+ children: [jsx(TableReviewCategoryLabel, {
6520
+ children: categoryLabel
6521
+ }), jsx(TableReviewItemSection, {
6522
+ children: category.elements.filter(field => {
6523
+ var _a, _b;
6524
+ // [TODO] we need to double check why we cannot hide the elements at the element level
6525
+ const conditionProps = (_a = field.rule) === null || _a === void 0 ? void 0 : _a.condition;
6526
+ /* istanbul ignore next */
6527
+ if (conditionProps && data) {
6528
+ const canHideControlParts = (_b = conditionProps === null || conditionProps === void 0 ? void 0 : conditionProps.scope) === null || _b === void 0 ? void 0 : _b.split('/');
6529
+ const canHideControl = canHideControlParts && canHideControlParts[(canHideControlParts === null || canHideControlParts === void 0 ? void 0 : canHideControlParts.length) - 1];
6530
+ const isHidden = getProperty(data, canHideControl);
6531
+ if (!isHidden) {
6532
+ return field;
6533
+ }
6534
+ } else {
6535
+ return field;
6536
+ }
6537
+ }).map(e => {
6538
+ const layout = e;
6539
+ if (rescopeMaps.some(scope => {
6540
+ var _a;
6541
+ return (_a = layout.elements) === null || _a === void 0 ? void 0 : _a.map(el => {
6542
+ const element = el;
6543
+ return element.scope;
6544
+ }).includes(scope);
6545
+ })) {
6546
+ return layout.elements;
6547
+ } else {
6548
+ return e;
6549
+ }
6550
+ }).flat().map(element => {
6551
+ return jsx(GoATable, {
6552
+ width: "100%",
6553
+ children: jsx("tbody", {
6554
+ children: jsx(JsonFormsDispatch, {
6555
+ "data-testid": `jsonforms-object-list-defined-elements-dispatch`,
6556
+ schema: schema,
6557
+ uischema: Object.assign(Object.assign({}, element), {
6558
+ options: Object.assign(Object.assign({}, element === null || element === void 0 ? void 0 : element.options), {
6559
+ categoryIndex: index
6560
+ })
6561
+ }),
6562
+ enabled: enabled,
6563
+ renderers: GoABaseTableReviewRenderers,
6564
+ cells: cells
6565
+ })
6566
+ })
6567
+ });
6568
+ })
6569
+ }, index)]
6570
+ });
6571
+ })]
6572
+ });
6573
+ };
6574
+ withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepperPageReviewer)));
6575
+
6376
6576
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6377
6577
  const FormPageStepper = props => {
6378
6578
  const formStepperCtx = useContext(JsonFormsStepperContext);
@@ -6402,7 +6602,8 @@ const FormPagesView = props => {
6402
6602
  const formStepperCtx = useContext(JsonFormsStepperContext);
6403
6603
  const {
6404
6604
  validatePage,
6405
- goToPage
6605
+ goToPage,
6606
+ toggleShowReviewLink
6406
6607
  } = formStepperCtx;
6407
6608
  const {
6408
6609
  categories,
@@ -6432,9 +6633,9 @@ const FormPagesView = props => {
6432
6633
  visible: visible,
6433
6634
  children: jsx("div", {
6434
6635
  id: `${path || `goa`}-form-pages`,
6435
- children: jsx(PageBorder, {
6436
- children: categories === null || categories === void 0 ? void 0 : categories.map((category, index) => {
6437
- const props = {
6636
+ children: jsxs(PageBorder, {
6637
+ children: [categories === null || categories === void 0 ? void 0 : categories.map((category, index) => {
6638
+ const categoryProps = {
6438
6639
  category: category.uischema,
6439
6640
  categoryIndex: category.id,
6440
6641
  visible: category === null || category === void 0 ? void 0 : category.visible,
@@ -6458,28 +6659,46 @@ const FormPagesView = props => {
6458
6659
  }), jsxs(PageRenderPadding, {
6459
6660
  children: [jsxs("h3", {
6460
6661
  children: ["Step ", index + 1, " of ", categories.length]
6461
- }), jsx(RenderStepElements, Object.assign({}, props))]
6662
+ }), jsx(RenderStepElements, Object.assign({}, categoryProps))]
6462
6663
  }), jsx(PageRenderPadding, {
6463
- children: index !== categories.length - 1 ? jsx(GoAButton, {
6464
- type: "submit",
6465
- onClick: () => goToPage(activeId + 1),
6466
- disabled: !(category.isValid && category.isCompleted),
6467
- testId: "pages-save-continue-btn",
6468
- children: "Save and continue"
6469
- }) : jsx(GoAButtonGroup, {
6470
- alignment: "end",
6471
- children: jsx(GoAButton, {
6472
- type: 'primary',
6473
- onClick: handleSubmit,
6474
- disabled: !isValid,
6475
- testId: "pages-submit-btn",
6476
- children: "Submit"
6477
- })
6664
+ children: jsxs(GoAButtonGroup, {
6665
+ alignment: "start",
6666
+ children: [jsx(GoAButton, {
6667
+ type: "submit",
6668
+ onClick: () => goToPage(activeId + 1),
6669
+ disabled: !(category.isValid && category.isCompleted),
6670
+ testId: "pages-save-continue-btn",
6671
+ children: "Save and continue"
6672
+ }), category.showReviewPageLink && jsx(GoAButton, {
6673
+ type: "tertiary",
6674
+ onClick: () => {
6675
+ toggleShowReviewLink(activeId);
6676
+ goToPage(categories.length);
6677
+ },
6678
+ testId: "pages-to-review-page-btn",
6679
+ children: "Back to application overview"
6680
+ })]
6478
6681
  })
6479
6682
  })]
6480
6683
  }, `${category.label}`);
6481
6684
  }
6482
- })
6685
+ }), isOnReview && jsxs("div", {
6686
+ "data-testid": "stepper-pages-review-page",
6687
+ children: [jsx(FormStepperPageReviewer, Object.assign({}, props, {
6688
+ navigationFunc: goToPage
6689
+ })), jsx(PageRenderPadding, {
6690
+ children: jsx(GoAButtonGroup, {
6691
+ alignment: "end",
6692
+ children: jsx(GoAButton, {
6693
+ type: 'primary',
6694
+ onClick: handleSubmit,
6695
+ disabled: !isValid,
6696
+ testId: "pages-submit-btn",
6697
+ children: "Submit"
6698
+ })
6699
+ })
6700
+ })]
6701
+ })]
6483
6702
  })
6484
6703
  })
6485
6704
  }), jsxs(GoAModal, {
@@ -7230,6 +7449,21 @@ function objectListReducer(state, action) {
7230
7449
  }
7231
7450
  }
7232
7451
 
7452
+ function extractNames(obj, names = []) {
7453
+ if (Array.isArray(obj)) {
7454
+ obj.forEach(item => extractNames(item, names));
7455
+ } else if (typeof obj === 'object' && obj !== null) {
7456
+ const typedObj = obj;
7457
+ if (typeof typedObj.label === 'string') {
7458
+ names.push(typedObj.label);
7459
+ } else if (typeof typedObj.scope === 'string') {
7460
+ const parts = typedObj.scope.split('/');
7461
+ names.push(parts[parts.length - 1]);
7462
+ }
7463
+ Object.values(typedObj).forEach(value => extractNames(value, names));
7464
+ }
7465
+ return names;
7466
+ }
7233
7467
  const GenerateRows$1 = (Cell, schema, rowPath, enabled, openDeleteDialog, handleChange, cells, uischema, isInReview, count, data,
7234
7468
  // eslint-disable-next-line
7235
7469
  errors) => {
@@ -7261,6 +7495,7 @@ errors) => {
7261
7495
  rowPath,
7262
7496
  cellPath: rowPath,
7263
7497
  enabled,
7498
+ uischema,
7264
7499
  isInReview,
7265
7500
  openDeleteDialog,
7266
7501
  handleChange,
@@ -7311,7 +7546,7 @@ function capitalizeFirstLetter(str) {
7311
7546
  return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
7312
7547
  }
7313
7548
  const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellComponent(props) {
7314
- var _a, _b;
7549
+ var _a, _b, _c;
7315
7550
  const {
7316
7551
  schema,
7317
7552
  enabled,
@@ -7328,10 +7563,14 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
7328
7563
  } = props;
7329
7564
  const properties = (schema === null || schema === void 0 ? void 0 : schema.items) && 'properties' in schema.items && schema.items.properties || {};
7330
7565
  const required = (_a = schema.items) === null || _a === void 0 ? void 0 : _a.required;
7566
+ let tableKeys = extractNames((_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.detail);
7567
+ if (tableKeys.length === 0) {
7568
+ tableKeys = Object.keys(properties);
7569
+ }
7331
7570
  return jsxs(NonEmptyCellStyle, {
7332
7571
  children: [
7333
7572
  // eslint-disable-next-line
7334
- (_b = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _b === void 0 ? void 0 : _b.map(element => {
7573
+ (_c = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _c === void 0 ? void 0 : _c.map(element => {
7335
7574
  return jsx(JsonFormsDispatch, {
7336
7575
  "data-testid": `jsonforms-object-list-defined-elements-dispatch`,
7337
7576
  schema: schema,
@@ -7345,7 +7584,7 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
7345
7584
  width: "100%",
7346
7585
  children: [jsx("thead", {
7347
7586
  children: jsxs("tr", {
7348
- children: [Object.keys(properties).map((key, index) => {
7587
+ children: [tableKeys.map((key, index) => {
7349
7588
  if (!isInReview) {
7350
7589
  return jsx("th", {
7351
7590
  children: jsxs("p", {
@@ -7421,11 +7660,15 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
7421
7660
  alignContent: 'baseLine',
7422
7661
  paddingTop: '18px'
7423
7662
  },
7424
- children: !isInReview && jsx(GoAIconButton, {
7425
- icon: "trash",
7426
- testId: "trash-icon-button",
7427
- "aria-label": `remove-element-${num}`,
7428
- onClick: () => openDeleteDialog(num)
7663
+ children: jsx("div", {
7664
+ "aria-hidden": "true",
7665
+ children: !isInReview && jsx(GoAIconButton, {
7666
+ icon: "trash",
7667
+ title: "trash button",
7668
+ testId: "trash-icon-button",
7669
+ "aria-label": `remove-element-${num}`,
7670
+ onClick: () => openDeleteDialog(num)
7671
+ })
7429
7672
  })
7430
7673
  })]
7431
7674
  }, i);
@@ -7620,7 +7863,7 @@ const ObjectArrayControl = props => {
7620
7863
  };
7621
7864
  useEffect(() => {
7622
7865
  // eslint-disable-next-line
7623
- const updatedData = Object.fromEntries((parsedData || []).map((item, index) => [index, item]));
7866
+ const updatedData = Array.isArray(parsedData) ? Object.fromEntries(parsedData.map((item, index) => [index, item])) : {};
7624
7867
  const count = Object.keys(updatedData).length;
7625
7868
  const dispatchData = {
7626
7869
  [path]: {
@@ -7953,9 +8196,11 @@ const LeftTab = ({
7953
8196
  children: [jsx(TabName, {
7954
8197
  children: name
7955
8198
  }), enabled ? jsx(Trash, {
8199
+ role: "trash button",
7956
8200
  children: jsx(GoAIconButton, {
7957
8201
  icon: "trash",
7958
- "aria-label": translations.removeAriaLabel,
8202
+ title: 'trash button',
8203
+ testId: "remove the details",
7959
8204
  onClick: () => openDeleteDialog(childPath, rowIndex, name)
7960
8205
  })
7961
8206
  }) : null]
@@ -10915,6 +11160,63 @@ const GoABaseReviewRenderers = [
10915
11160
  tester: HelpContentTester,
10916
11161
  renderer: HelpReviewContent
10917
11162
  }];
11163
+ const GoABaseTableReviewRenderers = [
11164
+ // controls
11165
+ {
11166
+ tester: GoAEnumControlTester,
11167
+ renderer: GoAInputBaseTableReviewControl
11168
+ }, {
11169
+ tester: GoAIntegerControlTester,
11170
+ renderer: GoAInputBaseTableReviewControl
11171
+ }, {
11172
+ tester: GoANumberControlTester,
11173
+ renderer: GoAInputBaseTableReviewControl
11174
+ }, {
11175
+ tester: GoATextControlTester,
11176
+ renderer: GoAInputBaseTableReviewControl
11177
+ }, {
11178
+ tester: GoADateControlTester,
11179
+ renderer: GoAInputBaseTableReviewControl
11180
+ }, {
11181
+ tester: GoADateTimeControlTester,
11182
+ renderer: GoAInputBaseTableReviewControl
11183
+ }, {
11184
+ tester: GoATimeControlTester,
11185
+ renderer: GoAInputBaseTableReviewControl
11186
+ }, {
11187
+ tester: GoARadioGroupControlTester,
11188
+ renderer: GoAInputBaseTableReviewControl
11189
+ }, {
11190
+ tester: GoACheckoutGroupControlTester,
11191
+ renderer: GoAInputBaseTableReviewControl
11192
+ }, {
11193
+ tester: GoABooleanControlTester,
11194
+ renderer: GoAInputBaseTableReviewControl
11195
+ }, {
11196
+ tester: GoABooleanRadioControlTester,
11197
+ renderer: GoAInputBaseTableReviewControl
11198
+ }, {
11199
+ tester: MultiLineTextControlTester,
11200
+ renderer: GoAInputBaseTableReviewControl
11201
+ }, {
11202
+ tester: GoAArrayControlTester,
11203
+ renderer: GoAInputBaseTableReviewControl
11204
+ }, {
11205
+ tester: GoAListWithDetailsTester,
11206
+ renderer: GoAInputBaseTableReviewControl
11207
+ }, {
11208
+ tester: GoAHorizontalLayoutTester,
11209
+ renderer: GoAInputBaseTableReviewControl
11210
+ }, {
11211
+ tester: GoAlVerticalLayoutTester,
11212
+ renderer: GoAInputBaseTableReviewControl
11213
+ }, {
11214
+ tester: GoAGroupReviewLayoutTester,
11215
+ renderer: GoAInputBaseTableReviewControl
11216
+ }, {
11217
+ tester: HelpContentTester,
11218
+ renderer: GoAInputBaseTableReviewControl
11219
+ }];
10918
11220
  const GoAReviewRenderers = [...GoABaseReviewRenderers, {
10919
11221
  tester: CategorizationStepperRendererTester,
10920
11222
  renderer: FormStepperReviewControl
@@ -10955,4 +11257,4 @@ const GoARenderers = [...GoABaseRenderers, {
10955
11257
  }];
10956
11258
  const GoACells = [...InputCells];
10957
11259
 
10958
- export { ADD_DATALIST_ACTION, ADD_NO_ANONYMOUS_ACTION, ADD_REGISTER_DATA_ACTION, ADD_REGISTER_DATA_ERROR, AddressLookUpControl, AddressLookUpControlReview, AddressLookUpTester, ArrayControl, ArrayControlBase, ArrayControlReview, BooleanComponent, BooleanControl, BooleanRadioComponent, BooleanRadioControl, CategorizationPagesRendererTester, CategorizationStepperRendererTester, CheckboxGroup, ContextProviderC, ContextProviderClass, ContextProviderFactory, EnumCheckboxControl, EnumRadioControl, EnumSelect, FileUploader, FileUploaderReview, FileUploaderTester, FormPageStepper, FormPagesView, FormStepper, FormStepperControl, FormStepperPagesControl, FormStepperReviewControl, FormStepperReviewer, FormStepperView, FullNameControl, FullNameDobControl, FullNameDobReviewControl, FullNameDobTester, FullNameReviewControl, FullNameTester, GoAArrayControlRenderer, GoAArrayControlReviewRenderer, GoAArrayControlTester, GoABaseInputReviewComponent, GoABaseRenderers, GoABaseReviewRenderers, GoABooleanControl, GoABooleanControlTester, GoABooleanRadioControl, GoABooleanRadioControlTester, GoACells, GoACheckoutGroupControlTester, GoADateControl, GoADateControlTester, GoADateInput, GoADateTimeControl, GoADateTimeControlTester, GoADateTimeInput, GoAEnumCheckboxGroupControl, GoAEnumControl, GoAEnumControlTester, GoAEnumRadioGroupControl, GoAInputBaseControl, GoAInputDateControl, GoAInputDateTimeControl, GoAInputInteger, GoAInputIntegerControl, GoAInputNumberControl, GoAInputText, GoAInputTextControl, GoAInputTimeControl, GoAIntegerControl, GoAIntegerControlTester, GoAListWithDetailsControlRenderer, GoAListWithDetailsTester, GoANumberControl, GoANumberControlTester, GoANumberInput, GoARadioGroupControlTester, GoARenderers, GoAReviewRenderers, GoATextControl, GoATextControlTester, GoATimeControl, GoATimeControlTester, GoATimeInput, GoInputBaseReview, GoInputBaseReviewControl, JsonFormContext, JsonFormRegisterProvider, JsonFormsRegisterContext, ListWithDetailsControl, MultiLineText, MultiLineTextControl, MultiLineTextControlInput, MultiLineTextControlTester, RadioGroup, categoriesAreValid, createDefaultAjv, enumControl, errMalformedDate, formatSin, isAddressLookup, isFullName, isFullNameDoB, registerReducer, resolveRefs, tryResolveRefs };
11260
+ export { ADD_DATALIST_ACTION, ADD_NO_ANONYMOUS_ACTION, ADD_REGISTER_DATA_ACTION, ADD_REGISTER_DATA_ERROR, AddressLookUpControl, AddressLookUpControlReview, AddressLookUpTester, ArrayControl, ArrayControlBase, ArrayControlReview, BooleanComponent, BooleanControl, BooleanRadioComponent, BooleanRadioControl, CategorizationPagesRendererTester, CategorizationStepperRendererTester, CheckboxGroup, ContextProviderC, ContextProviderClass, ContextProviderFactory, EnumCheckboxControl, EnumRadioControl, EnumSelect, FileUploader, FileUploaderReview, FileUploaderTester, FormPageStepper, FormPagesView, FormStepper, FormStepperControl, FormStepperPagesControl, FormStepperReviewControl, FormStepperReviewer, FormStepperView, FullNameControl, FullNameDobControl, FullNameDobReviewControl, FullNameDobTester, FullNameReviewControl, FullNameTester, GoAArrayControlRenderer, GoAArrayControlReviewRenderer, GoAArrayControlTester, GoABaseInputReviewComponent, GoABaseRenderers, GoABaseReviewRenderers, GoABaseTableReviewRenderers, GoABooleanControl, GoABooleanControlTester, GoABooleanRadioControl, GoABooleanRadioControlTester, GoACells, GoACheckoutGroupControlTester, GoADateControl, GoADateControlTester, GoADateInput, GoADateTimeControl, GoADateTimeControlTester, GoADateTimeInput, GoAEnumCheckboxGroupControl, GoAEnumControl, GoAEnumControlTester, GoAEnumRadioGroupControl, GoAInputBaseControl, GoAInputBaseTableReview, GoAInputBaseTableReviewControl, GoAInputDateControl, GoAInputDateTimeControl, GoAInputInteger, GoAInputIntegerControl, GoAInputNumberControl, GoAInputText, GoAInputTextControl, GoAInputTimeControl, GoAIntegerControl, GoAIntegerControlTester, GoAListWithDetailsControlRenderer, GoAListWithDetailsTester, GoANumberControl, GoANumberControlTester, GoANumberInput, GoARadioGroupControlTester, GoARenderers, GoAReviewRenderers, GoATextControl, GoATextControlTester, GoATimeControl, GoATimeControlTester, GoATimeInput, GoInputBaseReview, GoInputBaseReviewControl, JsonFormContext, JsonFormRegisterProvider, JsonFormsRegisterContext, ListWithDetailsControl, MultiLineText, MultiLineTextControl, MultiLineTextControlInput, MultiLineTextControlTester, RadioGroup, categoriesAreValid, createDefaultAjv, enumControl, errMalformedDate, formatSin, isAddressLookup, isFullName, isFullNameDoB, registerReducer, resolveRefs, tryResolveRefs };