@abgov/jsonforms-components 1.54.4 → 1.55.1

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
@@ -7,7 +7,7 @@ import axios from 'axios';
7
7
  import get$1 from 'lodash/get';
8
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';
9
9
  import { withJsonFormsControlProps, withJsonFormsRendererProps, withJsonFormsEnumProps, withTranslateProps, useJsonForms, JsonFormsDispatch, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
10
- import * as _$b from 'lodash';
10
+ import * as _$c from 'lodash';
11
11
  import { isEqual, isObject as isObject$f } from 'lodash';
12
12
  import merge from 'lodash/merge';
13
13
  import isEmpty from 'lodash/isEmpty';
@@ -3028,16 +3028,16 @@ const onChangeForNumericControl = props => {
3028
3028
  }
3029
3029
  };
3030
3030
 
3031
- let _$a = t => t,
3032
- _t$a,
3031
+ let _$b = t => t,
3032
+ _t$b,
3033
3033
  _t2$7;
3034
- styled.div(_t$a || (_t$a = _$a`
3034
+ styled.div(_t$b || (_t$b = _$b`
3035
3035
  height: 70vh;
3036
3036
  overflow-y: auto;
3037
3037
  padding-left: var(--goa-space-2xs);
3038
3038
  padding-right: var(--goa-space-2xs);
3039
3039
  `));
3040
- const Visible = styled.div(_t2$7 || (_t2$7 = _$a`
3040
+ const Visible = styled.div(_t2$7 || (_t2$7 = _$b`
3041
3041
  display: ${0};
3042
3042
  `), p => p.visible ? 'initial' : 'none');
3043
3043
 
@@ -3797,21 +3797,21 @@ const JsonFormRegisterProvider = ({
3797
3797
  });
3798
3798
  };
3799
3799
 
3800
- let _$9 = t => t,
3801
- _t$9,
3800
+ let _$a = t => t,
3801
+ _t$a,
3802
3802
  _t2$6,
3803
3803
  _t3$5;
3804
- const FormFieldWrapper = styled.div(_t$9 || (_t$9 = _$9`
3804
+ const FormFieldWrapper = styled.div(_t$a || (_t$a = _$a`
3805
3805
  margin-bottom: var(--goa-space-l);
3806
3806
  `));
3807
- const WarningIconDiv = styled.div(_t2$6 || (_t2$6 = _$9`
3807
+ const WarningIconDiv = styled.div(_t2$6 || (_t2$6 = _$a`
3808
3808
  display: inline-flex;
3809
3809
  align-items: flex-start;
3810
3810
  gap: 0.25rem;
3811
3811
  font-size: var(--goa-font-size-2);
3812
3812
  color: var(--goa-color-interactive-error);
3813
3813
  `));
3814
- const RequiredTextLabel = styled.label(_t3$5 || (_t3$5 = _$9`
3814
+ const RequiredTextLabel = styled.label(_t3$5 || (_t3$5 = _$a`
3815
3815
  color: var(--goa-color-greyscale-700);
3816
3816
  font-weight: var(--goa-font-weight-regular);
3817
3817
  font-size: var(--goa-font-size-2);
@@ -3829,12 +3829,12 @@ const GoAInputBaseControl = props => {
3829
3829
  required,
3830
3830
  path,
3831
3831
  isStepperReview,
3832
- skipOnBlurValidation
3832
+ skipInitialValidation
3833
3833
  } = props;
3834
3834
  const InnerComponent = input;
3835
3835
  const labelToUpdate = convertToSentenceCase(getLabelText(uischema.scope, label || ''));
3836
3836
  let modifiedErrors = checkFieldValidity(props);
3837
- const [isVisited, setIsVisited] = useState(skipOnBlurValidation === true);
3837
+ const [isVisited, setIsVisited] = useState(skipInitialValidation === true);
3838
3838
  if (modifiedErrors === 'must be equal to one of the allowed values') {
3839
3839
  modifiedErrors = '';
3840
3840
  }
@@ -4039,12 +4039,12 @@ const SPACE_KEY = ' ';
4039
4039
  const ALT_KEY = 'Alt';
4040
4040
  const SHIFT_KEY = 'Shift';
4041
4041
 
4042
- let _$8 = t => t,
4043
- _t$8,
4042
+ let _$9 = t => t,
4043
+ _t$9,
4044
4044
  _t2$5,
4045
4045
  _t3$4,
4046
4046
  _t4$4;
4047
- const GoADropdownTextbox = styled.div(_t$8 || (_t$8 = _$8`
4047
+ const GoADropdownTextbox = styled.div(_t$9 || (_t$9 = _$9`
4048
4048
  border-radius: var(--goa-space-2xs);
4049
4049
  box-shadow: ${0};
4050
4050
  &:hover {
@@ -4055,11 +4055,11 @@ const GoADropdownTextbox = styled.div(_t$8 || (_t$8 = _$8`
4055
4055
  box-shadow: ${0};
4056
4056
  }
4057
4057
  `), p => p.isOpen ? `0 0 0 3px var(--goa-color-interactive-focus)` : '', p => p.isOpen ? `0 0 0 3px var(--goa-color-interactive-focus) !important` : '');
4058
- const GoADropdownListContainerWrapper = styled.div(_t2$5 || (_t2$5 = _$8`
4058
+ const GoADropdownListContainerWrapper = styled.div(_t2$5 || (_t2$5 = _$9`
4059
4059
  position: relative;
4060
4060
  display: ${0};
4061
4061
  `), p => !(p === null || p === void 0 ? void 0 : p.isOpen) && 'none');
4062
- const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$8`
4062
+ const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$9`
4063
4063
  border: solid 1px var(--goa-color-greyscale-200);
4064
4064
  border-radius: var(--goa-space-2xs);
4065
4065
  background: var(--goa-color-greyscale-white);
@@ -4083,7 +4083,7 @@ const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$8`
4083
4083
  scrollbar-color: #a8a8a8 var(--goa-color-greyscale-100) !important;
4084
4084
  }
4085
4085
  `), p => p.optionListMaxHeight || '272px');
4086
- const GoADropdownListOption = styled.div(_t4$4 || (_t4$4 = _$8`
4086
+ const GoADropdownListOption = styled.div(_t4$4 || (_t4$4 = _$9`
4087
4087
  padding: var(--goa-space-2xs) var(--goa-space-s);
4088
4088
  text-overflow: ellipsis;
4089
4089
  color: ${0} !important;
@@ -5162,8 +5162,8 @@ const BooleanRadioControl = props => jsx(GoAInputBaseControl, Object.assign({},
5162
5162
  const GoABooleanRadioControlTester = rankWith(3, and(isBooleanControl, optionIs('radio', true)));
5163
5163
  const GoABooleanRadioControl = withJsonFormsControlProps(BooleanRadioControl);
5164
5164
 
5165
- let _$7 = t => t,
5166
- _t$7;
5165
+ let _$8 = t => t,
5166
+ _t$8;
5167
5167
  const Checkboxes = ({
5168
5168
  children,
5169
5169
  orientation,
@@ -5175,7 +5175,7 @@ const Checkboxes = ({
5175
5175
  children: children
5176
5176
  });
5177
5177
  };
5178
- const CheckBoxGroupDiv = styled.div(_t$7 || (_t$7 = _$7`
5178
+ const CheckBoxGroupDiv = styled.div(_t$8 || (_t$8 = _$8`
5179
5179
  .horizontal {
5180
5180
  display: flex;
5181
5181
  flex-direction: row;
@@ -5292,12 +5292,12 @@ const GoABaseInputReviewComponent = props => {
5292
5292
  const GoInputBaseReview = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
5293
5293
  input: GoABaseInputReviewComponent,
5294
5294
  isStepperReview: true,
5295
- skipOnBlurValidation: true
5295
+ skipInitialValidation: true
5296
5296
  }));
5297
5297
  const GoInputBaseReviewControl = withJsonFormsControlProps(GoInputBaseReview);
5298
5298
 
5299
- let _$6 = t => t,
5300
- _t$6;
5299
+ let _$7 = t => t,
5300
+ _t$7;
5301
5301
  const renderLayoutElements = (elements, schema, path, enabled, renderers, cells) => {
5302
5302
  return elements.map((child, index) => jsx("div", {
5303
5303
  children: jsx(JsonFormsDispatch, {
@@ -5378,14 +5378,14 @@ const ReviewLayoutRenderer = ({
5378
5378
  }
5379
5379
  }
5380
5380
  };
5381
- const ReviewGrid = styled.div(_t$6 || (_t$6 = _$6`
5381
+ const ReviewGrid = styled.div(_t$7 || (_t$7 = _$7`
5382
5382
  display: grid;
5383
5383
  grid-template-columns: repeat(auto-fit, minmax(250px, calc(50% - 8px)));
5384
5384
  gap: 16px;
5385
5385
  `));
5386
5386
 
5387
- let _$5 = t => t,
5388
- _t$5,
5387
+ let _$6 = t => t,
5388
+ _t$6,
5389
5389
  _t2$4,
5390
5390
  _t3$3,
5391
5391
  _t4$3,
@@ -5395,8 +5395,10 @@ let _$5 = t => t,
5395
5395
  _t8$1,
5396
5396
  _t9$1,
5397
5397
  _t10$1,
5398
- _t11$1;
5399
- const ReviewItem = styled.div(_t$5 || (_t$5 = _$5`
5398
+ _t11$1,
5399
+ _t12$1,
5400
+ _t13$1;
5401
+ const ReviewItem = styled.div(_t$6 || (_t$6 = _$6`
5400
5402
  display: flex;
5401
5403
  flex-direction: column;
5402
5404
  border: var(--goa-border-width-s) solid grey;
@@ -5407,7 +5409,7 @@ const ReviewItem = styled.div(_t$5 || (_t$5 = _$5`
5407
5409
  display: none;
5408
5410
  }
5409
5411
  `));
5410
- const ReviewItemSection = styled.div(_t2$4 || (_t2$4 = _$5`
5412
+ const ReviewItemSection = styled.div(_t2$4 || (_t2$4 = _$6`
5411
5413
  background-color: #f1f1f1;
5412
5414
  margin-bottom: var(--goa-space-m);
5413
5415
  padding: var(--goa-space-m);
@@ -5418,18 +5420,18 @@ const ReviewItemSection = styled.div(_t2$4 || (_t2$4 = _$5`
5418
5420
  max-width: 1600px;
5419
5421
  }
5420
5422
  `));
5421
- const ReviewItemHeader = styled.div(_t3$3 || (_t3$3 = _$5`
5423
+ const ReviewItemHeader = styled.div(_t3$3 || (_t3$3 = _$6`
5422
5424
  display: flex;
5423
5425
  align-items: center;
5424
5426
  justify-content: space-between;
5425
5427
  margin-bottom: var(--goa-space-xl);
5426
5428
  `));
5427
- const ReviewItemTitle = styled.div(_t4$3 || (_t4$3 = _$5`
5429
+ const ReviewItemTitle = styled.div(_t4$3 || (_t4$3 = _$6`
5428
5430
  font-size: var(--goa-space-l);
5429
5431
  line-height: var(--goa-space-xl);
5430
5432
  font-weight: 300;
5431
5433
  `));
5432
- const Anchor = styled.div(_t5$2 || (_t5$2 = _$5`
5434
+ const Anchor = styled.div(_t5$2 || (_t5$2 = _$6`
5433
5435
  color: #0070c4;
5434
5436
  text-decoration: underline;
5435
5437
  outline: none;
@@ -5440,20 +5442,20 @@ const Anchor = styled.div(_t5$2 || (_t5$2 = _$5`
5440
5442
  background-color: #e6f7ff;
5441
5443
  }
5442
5444
  `));
5443
- styled.div(_t6$2 || (_t6$2 = _$5`
5445
+ styled.div(_t6$2 || (_t6$2 = _$6`
5444
5446
  margin-left: var(--goa-space-m);
5445
5447
  `));
5446
- styled.div(_t7$1 || (_t7$1 = _$5`
5448
+ styled.div(_t7$1 || (_t7$1 = _$6`
5447
5449
  margin-bottom: var(--goa-space-m);
5448
5450
  `));
5449
- styled.div(_t8$1 || (_t8$1 = _$5`
5451
+ styled.div(_t8$1 || (_t8$1 = _$6`
5450
5452
  margin: var(--goa-space-s);
5451
5453
  width: 100%;
5452
5454
  `));
5453
- styled.h3(_t9$1 || (_t9$1 = _$5`
5455
+ styled.h3(_t9$1 || (_t9$1 = _$6`
5454
5456
  text-transform: capitalize;
5455
5457
  `));
5456
- const RightAlignmentDiv = styled.div(_t10$1 || (_t10$1 = _$5`
5458
+ const RightAlignmentDiv = styled.div(_t10$1 || (_t10$1 = _$6`
5457
5459
  @media screen and (max-width: 767px) {
5458
5460
  margin-bottom: var(--goa-space-l);
5459
5461
  }
@@ -5463,13 +5465,19 @@ const RightAlignmentDiv = styled.div(_t10$1 || (_t10$1 = _$5`
5463
5465
  margin-bottom: var(--goa-space-l);
5464
5466
  }
5465
5467
  `));
5466
- const FormStepperSummaryH3 = styled.h3(_t11$1 || (_t11$1 = _$5`
5468
+ const FormStepperSummaryH3 = styled.h3(_t11$1 || (_t11$1 = _$6`
5467
5469
  flex: 1;
5468
5470
  margin-bottom: var(--goa-space-m);
5469
5471
  font-size: var(--goa-font-size-7);
5470
5472
  line-height: var(--goa-line-height-4);
5471
5473
  font-weight: var(--goa-font-weight-regular);
5472
5474
  `));
5475
+ const PageRenderPadding = styled.h3(_t12$1 || (_t12$1 = _$6`
5476
+ margin-top: var(--goa-space-2xl);
5477
+ `));
5478
+ const PageBorder = styled.h3(_t13$1 || (_t13$1 = _$6`
5479
+ padding: var(--goa-space-3xl);
5480
+ `));
5473
5481
 
5474
5482
  class ContextProviderClass {
5475
5483
  addDataByUrl(key, url, processDataFunction, token) {
@@ -5794,7 +5802,7 @@ const pickPropertyValues = (obj, property, endWithType) => {
5794
5802
  var _a;
5795
5803
  if (key === property) {
5796
5804
  values.push(obj[key]);
5797
- } else if (_$b.isObject(obj[key])) {
5805
+ } else if (_$c.isObject(obj[key])) {
5798
5806
  // if the object type is equal to end type, we are not going to continue the recursive approach
5799
5807
  if (endWithType && ((_a = obj[key]) === null || _a === void 0 ? void 0 : _a.type) === endWithType) {
5800
5808
  if (property in obj[key]) {
@@ -5803,7 +5811,7 @@ const pickPropertyValues = (obj, property, endWithType) => {
5803
5811
  } else {
5804
5812
  values = [...values, ...pickPropertyValues(obj[key], property, endWithType)];
5805
5813
  }
5806
- } else if (_$b.isArray(obj[key])) {
5814
+ } else if (_$c.isArray(obj[key])) {
5807
5815
  const nextValues = obj[key].map(function (arrayObj) {
5808
5816
  return pickPropertyValues(arrayObj, property, endWithType);
5809
5817
  });
@@ -5915,7 +5923,7 @@ function isNumber(value) {
5915
5923
  }
5916
5924
  const getIncompletePaths = (ajv, scopes) => {
5917
5925
  var _a;
5918
- const requiredErrorPaths = (_a = ajv === null || ajv === void 0 ? void 0 : ajv.errors) === null || _a === void 0 ? void 0 : _a.filter(e => e.keyword === 'required').map(e => {
5926
+ 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 => {
5919
5927
  return getControlPath(e);
5920
5928
  });
5921
5929
  const _scopes = scopes.map(scope => toDataPath(scope)).filter(path => requiredErrorPaths && isErrorPathIncluded(requiredErrorPaths, path));
@@ -6001,6 +6009,7 @@ const stepperReducer = (state, action) => {
6001
6009
  state.hasNextButton = id <= lastId;
6002
6010
  state.hasPrevButton = id !== 0;
6003
6011
  state.isOnReview = false;
6012
+ state.maxReachedStep = Math.max(state.maxReachedStep, activeId);
6004
6013
  return Object.assign({}, state);
6005
6014
  }
6006
6015
  }
@@ -6049,7 +6058,6 @@ const createStepperContextInitData = props => {
6049
6058
  const valid = ajv.validate(schema, data || {});
6050
6059
  const categories = (_a = categorization.elements) === null || _a === void 0 ? void 0 : _a.map((c, id) => {
6051
6060
  const scopes = pickPropertyValues(c, 'scope', 'ListWithDetail');
6052
- // ListWithDetail path might have conflicts with others. The errors in ListWithDetail will still be caught in the ctx.core.errors
6053
6061
  const incompletePaths = getIncompletePaths(ajv, scopes);
6054
6062
  return {
6055
6063
  id,
@@ -6071,7 +6079,8 @@ const createStepperContextInitData = props => {
6071
6079
  hasPrevButton: activeId > 0 && activeId !== (categories === null || categories === void 0 ? void 0 : categories.length),
6072
6080
  path,
6073
6081
  isOnReview: activeId === (categories === null || categories === void 0 ? void 0 : categories.length),
6074
- isValid: valid === true
6082
+ isValid: valid === true,
6083
+ maxReachedStep: 0
6075
6084
  };
6076
6085
  };
6077
6086
  const JsonFormsStepperContext = /*#__PURE__*/createContext(undefined);
@@ -6108,6 +6117,17 @@ const JsonFormsStepperContextProvider = ({
6108
6117
  selectCategory: id => {
6109
6118
  return stepperState.categories[id];
6110
6119
  },
6120
+ validatePage: id => {
6121
+ var _a;
6122
+ stepperDispatch({
6123
+ type: 'update/category',
6124
+ payload: {
6125
+ errors: (_a = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _a === void 0 ? void 0 : _a.errors,
6126
+ id,
6127
+ ajv
6128
+ }
6129
+ });
6130
+ },
6111
6131
  goToPage: (id, updateCategoryId) => {
6112
6132
  var _a, _b, _c;
6113
6133
  ajv.validate(schema, ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.data) || {});
@@ -6140,6 +6160,7 @@ const JsonFormsStepperContextProvider = ({
6140
6160
  }, [stepperDispatch, stepperState, (_a = ctx.core) === null || _a === void 0 ? void 0 : _a.errors]);
6141
6161
  useEffect(() => {
6142
6162
  if ((context === null || context === void 0 ? void 0 : context.isProvided) === true) {
6163
+ /* The block is used to cache the state for the tenant web app review editor */
6143
6164
  stepperDispatch({
6144
6165
  type: 'update/uischema',
6145
6166
  payload: {
@@ -6148,6 +6169,8 @@ const JsonFormsStepperContextProvider = ({
6148
6169
  }))
6149
6170
  }
6150
6171
  });
6172
+ context.goToPage(stepperState.maxReachedStep);
6173
+ context.goToPage(stepperState.activeId);
6151
6174
  }
6152
6175
  }, [JSON.stringify(StepperProps.uischema), JSON.stringify(StepperProps.schema)]);
6153
6176
  return jsx(JsonFormsStepperContext.Provider, {
@@ -6212,9 +6235,11 @@ const FormStepperView = props => {
6212
6235
  const onCloseModal = () => {
6213
6236
  setIsOpen(false);
6214
6237
  };
6215
- return jsx("div", {
6238
+ // eslint-disable-next-line
6239
+ uischema.options;
6240
+ return jsxs("div", {
6216
6241
  "data-testid": "form-stepper-test-wrapper",
6217
- children: jsx(Visible, {
6242
+ children: [jsx(Visible, {
6218
6243
  visible: visible,
6219
6244
  children: jsxs("div", {
6220
6245
  id: `${path || `goa`}-form-stepper`,
@@ -6306,30 +6331,208 @@ const FormStepperView = props => {
6306
6331
  })
6307
6332
  })
6308
6333
  })]
6309
- }), jsxs(GoAModal, {
6310
- testId: "submit-confirmation",
6311
- open: isOpen,
6312
- heading: 'Form Submitted',
6313
- width: "640px",
6314
- actions: jsx(GoAButtonGroup, {
6315
- alignment: "end",
6316
- children: jsx(GoAButton, {
6317
- type: "primary",
6318
- testId: "close-submit-modal",
6319
- onClick: onCloseModal,
6320
- children: "Close"
6321
- })
6322
- }),
6323
- children: [jsx("b", {
6324
- children: "Submit is a test for preview purposes "
6325
- }), "(i.e. no actual form is being submitted)"]
6326
6334
  })]
6327
6335
  })
6328
- })
6336
+ }), jsxs(GoAModal, {
6337
+ testId: "submit-confirmation",
6338
+ open: isOpen,
6339
+ heading: 'Form Submitted',
6340
+ width: "640px",
6341
+ actions: jsx(GoAButtonGroup, {
6342
+ alignment: "end",
6343
+ children: jsx(GoAButton, {
6344
+ type: "primary",
6345
+ testId: "close-submit-modal",
6346
+ onClick: onCloseModal,
6347
+ children: "Close"
6348
+ })
6349
+ }),
6350
+ children: [jsx("b", {
6351
+ children: "Submit is a test for preview purposes "
6352
+ }), "(i.e. no actual form is being submitted)"]
6353
+ })]
6329
6354
  });
6330
6355
  };
6331
6356
  const FormStepperControl = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepper)));
6332
6357
 
6358
+ let _$5 = t => t,
6359
+ _t$5;
6360
+ const BackButtonWrapper = styled.span(_t$5 || (_t$5 = _$5`
6361
+ .back-link::before {
6362
+ content: '';
6363
+ display: inline-block;
6364
+ width: 42px;
6365
+ height: 24px;
6366
+ vertical-align: middle;
6367
+ background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 2 22 22" fill="none" stroke="%230070C4" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg>')
6368
+ center center no-repeat;
6369
+ }
6370
+
6371
+ .back-link:visited::before,
6372
+ .back-link:hover::before {
6373
+ background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 2 22 22" fill="none" stroke="%23004f84" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg>')
6374
+ center center no-repeat;
6375
+ }
6376
+
6377
+ .back-link {
6378
+ margin-top: var(--goa-space-m);
6379
+ }
6380
+ display: inline-block;
6381
+ color: #0070c4;
6382
+ cursor: pointer;
6383
+
6384
+ on .goa-icon {
6385
+ display: inline-block !important;
6386
+ position: relative;
6387
+ top: 3px;
6388
+ right: 2px;
6389
+ color: #0070c4;
6390
+ margin-left: 4px;
6391
+ }
6392
+ `));
6393
+ const BackButton = ({
6394
+ text,
6395
+ testId,
6396
+ link
6397
+ }) => {
6398
+ return jsx(BackButtonWrapper, {
6399
+ "data-testid": "back-button-click",
6400
+ onClick: link,
6401
+ children: jsx("div", {
6402
+ className: "back-link",
6403
+ children: text
6404
+ })
6405
+ });
6406
+ };
6407
+
6408
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6409
+ const FormPageStepper = props => {
6410
+ const formStepperCtx = useContext(JsonFormsStepperContext);
6411
+ /**
6412
+ * StepperCtx can only be provided once to prevent issues from categorization in categorization
6413
+ * */
6414
+ if ((formStepperCtx === null || formStepperCtx === void 0 ? void 0 : formStepperCtx.isProvided) === true) {
6415
+ return jsx(FormPagesView, Object.assign({}, props));
6416
+ }
6417
+ return jsx(JsonFormsStepperContextProvider, {
6418
+ StepperProps: Object.assign({}, props),
6419
+ children: jsx(FormPagesView, Object.assign({}, props))
6420
+ });
6421
+ };
6422
+ const FormPagesView = props => {
6423
+ const {
6424
+ uischema,
6425
+ data,
6426
+ schema,
6427
+ path,
6428
+ cells,
6429
+ renderers,
6430
+ visible,
6431
+ t
6432
+ } = props;
6433
+ const enumerators = useContext(JsonFormContext);
6434
+ const formStepperCtx = useContext(JsonFormsStepperContext);
6435
+ const {
6436
+ validatePage,
6437
+ goToPage
6438
+ } = formStepperCtx;
6439
+ const {
6440
+ categories,
6441
+ isOnReview,
6442
+ isValid,
6443
+ activeId
6444
+ } = formStepperCtx.selectStepperState();
6445
+ const submitFormFunction = enumerators === null || enumerators === void 0 ? void 0 : enumerators.submitFunction.get('submit-form');
6446
+ const submitForm = submitFormFunction && submitFormFunction();
6447
+ const [isOpen, setIsOpen] = useState(false);
6448
+ const handleSubmit = () => {
6449
+ if (submitForm) {
6450
+ submitForm(data);
6451
+ } else {
6452
+ setIsOpen(true);
6453
+ }
6454
+ };
6455
+ const onCloseModal = () => {
6456
+ setIsOpen(false);
6457
+ };
6458
+ useEffect(() => {
6459
+ validatePage(activeId);
6460
+ }, [data]);
6461
+ return jsxs("div", {
6462
+ "data-testid": "form-stepper-test-wrapper",
6463
+ children: [jsx(Visible, {
6464
+ visible: visible,
6465
+ children: jsx("div", {
6466
+ id: `${path || `goa`}-form-pages`,
6467
+ children: jsx(PageBorder, {
6468
+ children: categories === null || categories === void 0 ? void 0 : categories.map((category, index) => {
6469
+ const props = {
6470
+ category: category.uischema,
6471
+ categoryIndex: category.id,
6472
+ visible: category === null || category === void 0 ? void 0 : category.visible,
6473
+ enabled: category === null || category === void 0 ? void 0 : category.isEnabled,
6474
+ path,
6475
+ schema,
6476
+ renderers,
6477
+ cells,
6478
+ data
6479
+ };
6480
+ if (index === activeId && !isOnReview) {
6481
+ return jsxs("div", {
6482
+ "data-testid": `step_${index}-content-pages`,
6483
+ style: {
6484
+ marginTop: '1.5rem'
6485
+ },
6486
+ children: [index > 0 && jsx(BackButton, {
6487
+ testId: "back-button",
6488
+ link: () => goToPage(activeId - 1),
6489
+ text: "Back"
6490
+ }), jsxs(PageRenderPadding, {
6491
+ children: [jsxs("h3", {
6492
+ children: ["Step ", index + 1, " of ", categories.length]
6493
+ }), jsx(RenderStepElements, Object.assign({}, props))]
6494
+ }), jsx(PageRenderPadding, {
6495
+ children: index !== categories.length - 1 ? jsx(GoAButton, {
6496
+ type: "submit",
6497
+ onClick: () => goToPage(activeId + 1),
6498
+ disabled: !(category.isValid && category.isCompleted),
6499
+ testId: "pages-save-continue-btn",
6500
+ children: "Save and continue"
6501
+ }) : jsx(GoAButton, {
6502
+ type: 'primary',
6503
+ onClick: handleSubmit,
6504
+ disabled: !isValid,
6505
+ testId: "pages-submit-btn",
6506
+ children: "Submit"
6507
+ })
6508
+ })]
6509
+ }, `${category.label}`);
6510
+ }
6511
+ })
6512
+ })
6513
+ })
6514
+ }), jsxs(GoAModal, {
6515
+ testId: "submit-confirmation",
6516
+ open: isOpen,
6517
+ heading: 'Form Submitted',
6518
+ width: "640px",
6519
+ actions: jsx(GoAButtonGroup, {
6520
+ alignment: "end",
6521
+ children: jsx(GoAButton, {
6522
+ type: "primary",
6523
+ testId: "close-submit-modal",
6524
+ onClick: onCloseModal,
6525
+ children: "Close"
6526
+ })
6527
+ }),
6528
+ children: [jsx("b", {
6529
+ children: "Submit is a test for preview purposes "
6530
+ }), "(i.e. no actual form is being submitted)"]
6531
+ })]
6532
+ });
6533
+ };
6534
+ const FormStepperPagesControl = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormPageStepper)));
6535
+
6333
6536
  // Ensure that all children (Category) have valid elements or things tend
6334
6537
  // to blow up. If not, the the error control will report the problem.
6335
6538
  const categoriesAreValid = uischema => {
@@ -6345,7 +6548,14 @@ const categoriesAreValid = uischema => {
6345
6548
  }
6346
6549
  return isValid;
6347
6550
  };
6348
- const CategorizationRendererTester = rankWith(2, and(uiTypeIs('Categorization'), categoriesAreValid));
6551
+ const CategorizationStepperRendererTester = rankWith(2, and(uiTypeIs('Categorization'), categoriesAreValid, uischema => {
6552
+ var _a;
6553
+ return ((_a = uischema.options) === null || _a === void 0 ? void 0 : _a.variant) === 'stepper';
6554
+ }));
6555
+ const CategorizationPagesRendererTester = rankWith(2, and(uiTypeIs('Categorization'), categoriesAreValid, uischema => {
6556
+ var _a;
6557
+ return ((_a = uischema.options) === null || _a === void 0 ? void 0 : _a.variant) === 'pages';
6558
+ }));
6349
6559
 
6350
6560
  let _$4 = t => t,
6351
6561
  _t$4;
@@ -10749,7 +10959,10 @@ const GoABaseReviewRenderers = [
10749
10959
  renderer: HelpReviewContent
10750
10960
  }];
10751
10961
  const GoAReviewRenderers = [...GoABaseReviewRenderers, {
10752
- tester: CategorizationRendererTester,
10962
+ tester: CategorizationStepperRendererTester,
10963
+ renderer: FormStepperReviewControl
10964
+ }, {
10965
+ tester: CategorizationPagesRendererTester,
10753
10966
  renderer: FormStepperReviewControl
10754
10967
  }, {
10755
10968
  tester: FileUploaderTester,
@@ -10765,8 +10978,11 @@ const GoAReviewRenderers = [...GoABaseReviewRenderers, {
10765
10978
  renderer: withJsonFormsControlProps(AddressLookUpControlReview)
10766
10979
  }];
10767
10980
  const GoARenderers = [...GoABaseRenderers, {
10768
- tester: CategorizationRendererTester,
10981
+ tester: CategorizationStepperRendererTester,
10769
10982
  renderer: FormStepperControl
10983
+ }, {
10984
+ tester: CategorizationPagesRendererTester,
10985
+ renderer: FormStepperPagesControl
10770
10986
  }, {
10771
10987
  tester: FileUploaderTester,
10772
10988
  renderer: withJsonFormsControlProps(FileUploader)
@@ -10782,4 +10998,4 @@ const GoARenderers = [...GoABaseRenderers, {
10782
10998
  }];
10783
10999
  const GoACells = [...InputCells];
10784
11000
 
10785
- 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, CategorizationRendererTester, CheckboxGroup, ContextProviderC, ContextProviderClass, ContextProviderFactory, EnumCheckboxControl, EnumRadioControl, EnumSelect, FileUploader, FileUploaderReview, FileUploaderTester, FormStepper, FormStepperControl, 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 };
11001
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.54.4",
3
+ "version": "1.55.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
6
6
  "repository": "https://github.com/GovAlta/adsp-monorepo",
@@ -0,0 +1,7 @@
1
+ interface ExternalLinkProps {
2
+ text: string;
3
+ link: () => void;
4
+ testId?: string;
5
+ }
6
+ export declare const BackButton: ({ text, testId, link }: ExternalLinkProps) => JSX.Element;
7
+ export {};
@@ -1,3 +1,4 @@
1
1
  import { RankedTester, UISchemaElement } from '@jsonforms/core';
2
2
  export declare const categoriesAreValid: (uischema: UISchemaElement) => boolean;
3
- export declare const CategorizationRendererTester: RankedTester;
3
+ export declare const CategorizationStepperRendererTester: RankedTester;
4
+ export declare const CategorizationPagesRendererTester: RankedTester;
@@ -0,0 +1,12 @@
1
+ import { GoAButtonType } from '@abgov/react-components-new';
2
+ import { CategorizationStepperLayoutRendererProps } from './types';
3
+ export interface FormPageOptionProps {
4
+ nextButtonLabel?: string;
5
+ nextButtonType?: GoAButtonType;
6
+ previousButtonLabel?: string;
7
+ previousButtonType?: GoAButtonType;
8
+ }
9
+ export declare const FormPageStepper: (props: CategorizationStepperLayoutRendererProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const FormPagesView: (props: CategorizationStepperLayoutRendererProps) => JSX.Element;
11
+ export declare const FormStepperPagesControl: (props: CategorizationStepperLayoutRendererProps & import("@jsonforms/core").OwnPropsOfLayout) => import("react/jsx-runtime").JSX.Element;
12
+ export default FormPageStepper;
@@ -18,6 +18,7 @@ export interface JsonFormsStepperContextProps {
18
18
  selectPath: () => string;
19
19
  selectCategory: (id: number) => CategoryState;
20
20
  goToPage: (id: number, updateCategoryId?: number) => void;
21
+ validatePage: (id: number) => void;
21
22
  isProvided?: boolean;
22
23
  }
23
24
  export declare const JsonFormsStepperContext: import("react").Context<JsonFormsStepperContextProps | undefined>;
@@ -23,5 +23,6 @@ export interface StepperContextDataType {
23
23
  path: string;
24
24
  isOnReview: boolean;
25
25
  isValid: boolean;
26
+ maxReachedStep: number;
26
27
  }
27
28
  export type CategorizationElement = Category | Categorization;
@@ -1,3 +1,4 @@
1
1
  export * from './FormStepperControl';
2
+ export * from './PageStepperControl';
2
3
  export * from './FormStepperTester';
3
4
  export * from './FormStepperReviewControl';
@@ -10,3 +10,5 @@ export declare const ListWithDetail: import("styled-components/dist/types").ISty
10
10
  export declare const ListWithDetailHeading: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
11
11
  export declare const RightAlignmentDiv: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
12
12
  export declare const FormStepperSummaryH3: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
13
+ export declare const PageRenderPadding: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
14
+ export declare const PageBorder: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
@@ -5,6 +5,6 @@ export interface WithInput {
5
5
  noLabel?: boolean;
6
6
  isStepperReview?: boolean;
7
7
  setIsVisited?: () => void;
8
- skipOnBlurValidation?: boolean;
8
+ skipInitialValidation?: boolean;
9
9
  }
10
10
  export declare const GoAInputBaseControl: (props: ControlProps & WithInput) => JSX.Element;