@abgov/jsonforms-components 2.45.1 → 2.46.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,15 +7,15 @@ import axios from 'axios';
7
7
  import get$1 from 'lodash/get';
8
8
  import { isVisible, isEnabled, deriveLabelForUISchemaElement, rankWith, isStringControl, and, optionIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, uiTypeIs, isControl as isControl$1, isEnumControl, isBooleanControl, schemaMatches, getAjv, createDefaultValue, or, isObjectArrayControl, isPrimitiveArrayControl, Paths, toDataPath, Resolve, schemaTypeIs, formatIs, hasType, isCategorization, isLayout } from '@jsonforms/core';
9
9
  import * as _$c from 'lodash';
10
- import ___default, { isEqual, isObject as isObject$g, isEmpty as isEmpty$1 } from 'lodash';
10
+ import ___default, { isEqual, isObject as isObject$h, isEmpty as isEmpty$1 } from 'lodash';
11
11
  import { useJsonForms, withJsonFormsControlProps, withJsonFormsEnumProps, withTranslateProps, JsonFormsDispatch, withJsonFormsAllOfProps, withJsonFormsArrayLayoutProps, withJsonFormsLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
12
+ import Ajv from 'ajv';
12
13
  import merge from 'lodash/merge';
13
14
  import isEmpty from 'lodash/isEmpty';
14
15
  import range from 'lodash/range';
15
16
  import pluralize from 'pluralize';
16
17
  import { evaluateSync, compileSync } from '@mdx-js/mdx';
17
18
  import { Parser } from 'expr-eval-fork';
18
- import Ajv from 'ajv';
19
19
  import addErrors from 'ajv-errors';
20
20
  import addFormats from 'ajv-formats';
21
21
 
@@ -276,18 +276,18 @@ var isCallable$s = typeof documentAll == 'undefined' && documentAll !== undefine
276
276
 
277
277
  var isCallable$r = isCallable$s;
278
278
 
279
- var isObject$f = function (it) {
279
+ var isObject$g = function (it) {
280
280
  return typeof it == 'object' ? it !== null : isCallable$r(it);
281
281
  };
282
282
 
283
- var isObject$e = isObject$f;
283
+ var isObject$f = isObject$g;
284
284
 
285
285
  var $String$5 = String;
286
286
  var $TypeError$k = TypeError;
287
287
 
288
288
  // `Assert: Type(argument) is Object`
289
289
  var anObject$s = function (argument) {
290
- if (isObject$e(argument)) return argument;
290
+ if (isObject$f(argument)) return argument;
291
291
  throw new $TypeError$k($String$5(argument) + ' is not an object');
292
292
  };
293
293
 
@@ -317,11 +317,11 @@ var v8PrototypeDefineBug = DESCRIPTORS$j && fails$r(function () {
317
317
  var objectDefineProperty = {};
318
318
 
319
319
  var global$m = global$r;
320
- var isObject$d = isObject$f;
320
+ var isObject$e = isObject$g;
321
321
 
322
322
  var document$3 = global$m.document;
323
323
  // typeof document.createElement is 'object' in old IE
324
- var EXISTS$1 = isObject$d(document$3) && isObject$d(document$3.createElement);
324
+ var EXISTS$1 = isObject$e(document$3) && isObject$e(document$3.createElement);
325
325
 
326
326
  var documentCreateElement$2 = function (it) {
327
327
  return EXISTS$1 ? document$3.createElement(it) : {};
@@ -409,7 +409,7 @@ var getMethod$7 = function (V, P) {
409
409
 
410
410
  var call$s = functionCall;
411
411
  var isCallable$n = isCallable$s;
412
- var isObject$c = isObject$f;
412
+ var isObject$d = isObject$g;
413
413
 
414
414
  var $TypeError$i = TypeError;
415
415
 
@@ -417,14 +417,14 @@ var $TypeError$i = TypeError;
417
417
  // https://tc39.es/ecma262/#sec-ordinarytoprimitive
418
418
  var ordinaryToPrimitive$1 = function (input, pref) {
419
419
  var fn, val;
420
- if (pref === 'string' && isCallable$n(fn = input.toString) && !isObject$c(val = call$s(fn, input))) return val;
421
- if (isCallable$n(fn = input.valueOf) && !isObject$c(val = call$s(fn, input))) return val;
422
- if (pref !== 'string' && isCallable$n(fn = input.toString) && !isObject$c(val = call$s(fn, input))) return val;
420
+ if (pref === 'string' && isCallable$n(fn = input.toString) && !isObject$d(val = call$s(fn, input))) return val;
421
+ if (isCallable$n(fn = input.valueOf) && !isObject$d(val = call$s(fn, input))) return val;
422
+ if (pref !== 'string' && isCallable$n(fn = input.toString) && !isObject$d(val = call$s(fn, input))) return val;
423
423
  throw new $TypeError$i("Can't convert object to primitive value");
424
424
  };
425
425
 
426
426
  var call$r = functionCall;
427
- var isObject$b = isObject$f;
427
+ var isObject$c = isObject$g;
428
428
  var isSymbol$2 = isSymbol$3;
429
429
  var getMethod$6 = getMethod$7;
430
430
  var ordinaryToPrimitive = ordinaryToPrimitive$1;
@@ -436,13 +436,13 @@ var TO_PRIMITIVE = wellKnownSymbol$l('toPrimitive');
436
436
  // `ToPrimitive` abstract operation
437
437
  // https://tc39.es/ecma262/#sec-toprimitive
438
438
  var toPrimitive$1 = function (input, pref) {
439
- if (!isObject$b(input) || isSymbol$2(input)) return input;
439
+ if (!isObject$c(input) || isSymbol$2(input)) return input;
440
440
  var exoticToPrim = getMethod$6(input, TO_PRIMITIVE);
441
441
  var result;
442
442
  if (exoticToPrim) {
443
443
  if (pref === undefined) pref = 'default';
444
444
  result = call$r(exoticToPrim, input, pref);
445
- if (!isObject$b(result) || isSymbol$2(result)) return result;
445
+ if (!isObject$c(result) || isSymbol$2(result)) return result;
446
446
  throw new $TypeError$h("Can't convert object to primitive value");
447
447
  }
448
448
  if (pref === undefined) pref = 'number';
@@ -804,7 +804,7 @@ var createNonEnumerableProperty$a = DESCRIPTORS$f ? function (object, key, value
804
804
 
805
805
  var NATIVE_WEAK_MAP = weakMapBasicDetection;
806
806
  var global$j = global$r;
807
- var isObject$a = isObject$f;
807
+ var isObject$b = isObject$g;
808
808
  var createNonEnumerableProperty$9 = createNonEnumerableProperty$a;
809
809
  var hasOwn$e = hasOwnProperty_1;
810
810
  var shared$1 = sharedStoreExports;
@@ -823,7 +823,7 @@ var enforce = function (it) {
823
823
  var getterFor = function (TYPE) {
824
824
  return function (it) {
825
825
  var state;
826
- if (!isObject$a(it) || (state = get(it)).type !== TYPE) {
826
+ if (!isObject$b(it) || (state = get(it)).type !== TYPE) {
827
827
  throw new TypeError$2('Incompatible receiver, ' + TYPE + ' required');
828
828
  } return state;
829
829
  };
@@ -1195,7 +1195,7 @@ var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object$1.getPrototypeOf :
1195
1195
 
1196
1196
  var fails$m = fails$w;
1197
1197
  var isCallable$g = isCallable$s;
1198
- var isObject$9 = isObject$f;
1198
+ var isObject$a = isObject$g;
1199
1199
  var getPrototypeOf$2 = objectGetPrototypeOf;
1200
1200
  var defineBuiltIn$7 = defineBuiltIn$9;
1201
1201
  var wellKnownSymbol$j = wellKnownSymbol$m;
@@ -1218,7 +1218,7 @@ if ([].keys) {
1218
1218
  }
1219
1219
  }
1220
1220
 
1221
- var NEW_ITERATOR_PROTOTYPE = !isObject$9(IteratorPrototype$4) || fails$m(function () {
1221
+ var NEW_ITERATOR_PROTOTYPE = !isObject$a(IteratorPrototype$4) || fails$m(function () {
1222
1222
  var test = {};
1223
1223
  // FF44- legacy iterators case
1224
1224
  return IteratorPrototype$4[ITERATOR$7].call(test) !== test;
@@ -1278,10 +1278,10 @@ var functionUncurryThisAccessor = function (object, key, method) {
1278
1278
  } catch (error) { /* empty */ }
1279
1279
  };
1280
1280
 
1281
- var isObject$8 = isObject$f;
1281
+ var isObject$9 = isObject$g;
1282
1282
 
1283
1283
  var isPossiblePrototype$1 = function (argument) {
1284
- return isObject$8(argument) || argument === null;
1284
+ return isObject$9(argument) || argument === null;
1285
1285
  };
1286
1286
 
1287
1287
  var isPossiblePrototype = isPossiblePrototype$1;
@@ -1296,7 +1296,7 @@ var aPossiblePrototype$1 = function (argument) {
1296
1296
 
1297
1297
  /* eslint-disable no-proto -- safe */
1298
1298
  var uncurryThisAccessor$1 = functionUncurryThisAccessor;
1299
- var isObject$7 = isObject$f;
1299
+ var isObject$8 = isObject$g;
1300
1300
  var requireObjectCoercible$b = requireObjectCoercible$e;
1301
1301
  var aPossiblePrototype = aPossiblePrototype$1;
1302
1302
 
@@ -1316,7 +1316,7 @@ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? functio
1316
1316
  return function setPrototypeOf(O, proto) {
1317
1317
  requireObjectCoercible$b(O);
1318
1318
  aPossiblePrototype(proto);
1319
- if (!isObject$7(O)) return O;
1319
+ if (!isObject$8(O)) return O;
1320
1320
  if (CORRECT_SETTER) setter(O, proto);
1321
1321
  else O.__proto__ = proto;
1322
1322
  return O;
@@ -1696,7 +1696,7 @@ var toString$j = function (argument) {
1696
1696
  return $String$1(argument);
1697
1697
  };
1698
1698
 
1699
- var isObject$6 = isObject$f;
1699
+ var isObject$7 = isObject$g;
1700
1700
  var classof$7 = classofRaw$2;
1701
1701
  var wellKnownSymbol$d = wellKnownSymbol$m;
1702
1702
 
@@ -1706,7 +1706,7 @@ var MATCH$2 = wellKnownSymbol$d('match');
1706
1706
  // https://tc39.es/ecma262/#sec-isregexp
1707
1707
  var isRegexp = function (it) {
1708
1708
  var isRegExp;
1709
- return isObject$6(it) && ((isRegExp = it[MATCH$2]) !== undefined ? !!isRegExp : classof$7(it) === 'RegExp');
1709
+ return isObject$7(it) && ((isRegExp = it[MATCH$2]) !== undefined ? !!isRegExp : classof$7(it) === 'RegExp');
1710
1710
  };
1711
1711
 
1712
1712
  var isRegExp$1 = isRegexp;
@@ -1788,7 +1788,7 @@ var proxyAccessor$2 = function (Target, Source, key) {
1788
1788
  };
1789
1789
 
1790
1790
  var isCallable$d = isCallable$s;
1791
- var isObject$5 = isObject$f;
1791
+ var isObject$6 = isObject$g;
1792
1792
  var setPrototypeOf$2 = objectSetPrototypeOf;
1793
1793
 
1794
1794
  // makes subclassing work correct for wrapped built-ins
@@ -1800,7 +1800,7 @@ var inheritIfRequired$2 = function ($this, dummy, Wrapper) {
1800
1800
  // we haven't completely correct pre-ES6 way for getting `new.target`, so use this
1801
1801
  isCallable$d(NewTarget = dummy.constructor) &&
1802
1802
  NewTarget !== Wrapper &&
1803
- isObject$5(NewTargetPrototype = NewTarget.prototype) &&
1803
+ isObject$6(NewTargetPrototype = NewTarget.prototype) &&
1804
1804
  NewTargetPrototype !== Wrapper.prototype
1805
1805
  ) setPrototypeOf$2($this, NewTargetPrototype);
1806
1806
  return $this;
@@ -1812,13 +1812,13 @@ var normalizeStringArgument$1 = function (argument, $default) {
1812
1812
  return argument === undefined ? arguments.length < 2 ? '' : $default : toString$h(argument);
1813
1813
  };
1814
1814
 
1815
- var isObject$4 = isObject$f;
1815
+ var isObject$5 = isObject$g;
1816
1816
  var createNonEnumerableProperty$5 = createNonEnumerableProperty$a;
1817
1817
 
1818
1818
  // `InstallErrorCause` abstract operation
1819
1819
  // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
1820
1820
  var installErrorCause$1 = function (O, options) {
1821
- if (isObject$4(options) && 'cause' in options) {
1821
+ if (isObject$5(options) && 'cause' in options) {
1822
1822
  createNonEnumerableProperty$5(O, 'cause', options.cause);
1823
1823
  }
1824
1824
  };
@@ -4278,7 +4278,7 @@ var setToStringTag = setToStringTag$4;
4278
4278
  var setSpecies$1 = setSpecies$2;
4279
4279
  var aCallable$9 = aCallable$j;
4280
4280
  var isCallable$3 = isCallable$s;
4281
- var isObject$3 = isObject$f;
4281
+ var isObject$4 = isObject$g;
4282
4282
  var anInstance = anInstance$2;
4283
4283
  var speciesConstructor$1 = speciesConstructor$2;
4284
4284
  var task = task$1.set;
@@ -4320,7 +4320,7 @@ var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
4320
4320
  // helpers
4321
4321
  var isThenable = function (it) {
4322
4322
  var then;
4323
- return isObject$3(it) && isCallable$3(then = it.then) ? then : false;
4323
+ return isObject$4(it) && isCallable$3(then = it.then) ? then : false;
4324
4324
  };
4325
4325
 
4326
4326
  var callReaction = function (reaction, state) {
@@ -4710,12 +4710,12 @@ $$n({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR$1 }, {
4710
4710
  });
4711
4711
 
4712
4712
  var anObject$8 = anObject$s;
4713
- var isObject$2 = isObject$f;
4713
+ var isObject$3 = isObject$g;
4714
4714
  var newPromiseCapability = newPromiseCapability$2;
4715
4715
 
4716
4716
  var promiseResolve$1 = function (C, x) {
4717
4717
  anObject$8(C);
4718
- if (isObject$2(x) && x.constructor === C) return x;
4718
+ if (isObject$3(x) && x.constructor === C) return x;
4719
4719
  var promiseCapability = newPromiseCapability.f(C);
4720
4720
  var resolve = promiseCapability.resolve;
4721
4721
  resolve(x);
@@ -5212,14 +5212,14 @@ const RequiredTextLabel = styled.label(_t3$5 || (_t3$5 = _$a`
5212
5212
  line-height: var(--goa-line-height-1);
5213
5213
  font-style: normal;
5214
5214
  `));
5215
- const PageReviewNameCol = styled.td(_t4$5 || (_t4$5 = _$a`
5215
+ styled.td(_t4$5 || (_t4$5 = _$a`
5216
5216
  width: 40%;
5217
5217
  padding-top: var(--goa-space-s);
5218
5218
  padding-bottom: var(--goa-space-s);
5219
5219
  padding-right: var(--goa-space-m);
5220
5220
  vertical-align: top;
5221
5221
  `));
5222
- const PageReviewValueCol = styled.td(_t5$4 || (_t5$4 = _$a`
5222
+ styled.td(_t5$4 || (_t5$4 = _$a`
5223
5223
  width: 40%;
5224
5224
  text-align: left;
5225
5225
  vertical-align: top;
@@ -5463,7 +5463,7 @@ var getBuiltIn$1 = getBuiltIn$b;
5463
5463
  var uncurryThis$8 = functionUncurryThis;
5464
5464
  var call$6 = functionCall;
5465
5465
  var isCallable$1 = isCallable$s;
5466
- var isObject$1 = isObject$f;
5466
+ var isObject$2 = isObject$g;
5467
5467
  var isArray$2 = isArray$5;
5468
5468
  var hasOwn$1 = hasOwnProperty_1;
5469
5469
  var toString$8 = toString$j;
@@ -5510,7 +5510,7 @@ var internalize = function (holder, name, reviver, node) {
5510
5510
  var unmodified = node && val === node.value;
5511
5511
  var context = unmodified && typeof node.source == 'string' ? { source: node.source } : {};
5512
5512
  var elementRecordsLen, keys, len, i, P;
5513
- if (isObject$1(val)) {
5513
+ if (isObject$2(val)) {
5514
5514
  var nodeIsArray = isArray$2(val);
5515
5515
  var nodes = unmodified ? node.nodes : nodeIsArray ? [] : {};
5516
5516
  if (nodeIsArray) {
@@ -6326,7 +6326,8 @@ const stepperReducer = (state, action) => {
6326
6326
  hasNextButton: !isOnReview,
6327
6327
  hasPrevButton: newActive !== 0,
6328
6328
  maxReachedStep: Math.max(state.maxReachedStep, activeId),
6329
- targetScope
6329
+ targetScope,
6330
+ validationTrigger: (state.validationTrigger || 0) + 1
6330
6331
  });
6331
6332
  }
6332
6333
  case 'update/category':
@@ -6433,7 +6434,8 @@ const createStepperContextInitData = props => {
6433
6434
  path,
6434
6435
  isOnReview: activeId === (categories == null ? void 0 : categories.length),
6435
6436
  isValid: valid === true,
6436
- maxReachedStep: 0
6437
+ maxReachedStep: 0,
6438
+ validationTrigger: 0
6437
6439
  };
6438
6440
  };
6439
6441
  const JsonFormsStepperContext = /*#__PURE__*/createContext(undefined);
@@ -6441,7 +6443,7 @@ const JsonFormsStepperContextProvider = ({
6441
6443
  children,
6442
6444
  StepperProps
6443
6445
  }) => {
6444
- var _uischema$options3, _ctx$core2, _ctx$core6;
6446
+ var _uischema$options3, _ctx$core2, _ctx$core3;
6445
6447
  const ctx = useJsonForms();
6446
6448
  /* istanbul ignore next */
6447
6449
  const {
@@ -6512,28 +6514,6 @@ const JsonFormsStepperContextProvider = ({
6512
6514
  },
6513
6515
  validatePage: doValidatePage,
6514
6516
  goToPage: (id, targetScope) => {
6515
- var _ctx$core3, _ctx$core5;
6516
- ajv.validate(schema, ((_ctx$core3 = ctx.core) == null ? void 0 : _ctx$core3.data) || {});
6517
- // Only update the current category
6518
- if (!stepperState.isOnReview && id < stepperState.categories.length) {
6519
- var _ctx$core4;
6520
- stepperDispatch({
6521
- type: 'update/category',
6522
- payload: {
6523
- errors: ctx == null || (_ctx$core4 = ctx.core) == null ? void 0 : _ctx$core4.errors,
6524
- id,
6525
- ajv,
6526
- schema,
6527
- data
6528
- }
6529
- });
6530
- }
6531
- stepperDispatch({
6532
- type: 'validate/form',
6533
- payload: {
6534
- errors: ctx == null || (_ctx$core5 = ctx.core) == null ? void 0 : _ctx$core5.errors
6535
- }
6536
- });
6537
6517
  stepperDispatch({
6538
6518
  type: 'page/to/index',
6539
6519
  payload: {
@@ -6552,7 +6532,7 @@ const JsonFormsStepperContextProvider = ({
6552
6532
  }
6553
6533
  };
6554
6534
  //eslint-disable-next-line
6555
- }, [stepperDispatch, stepperState, (_ctx$core6 = ctx.core) == null ? void 0 : _ctx$core6.errors, ajv, schema, data]);
6535
+ }, [stepperDispatch, stepperState, (_ctx$core3 = ctx.core) == null ? void 0 : _ctx$core3.errors, ajv, schema, data]);
6556
6536
  /* istanbul ignore next */
6557
6537
  useEffect(() => {
6558
6538
  const handleBeforeUnload = () => {
@@ -6591,6 +6571,143 @@ const JsonFormsStepperContextProvider = ({
6591
6571
  });
6592
6572
  };
6593
6573
 
6574
+ var $$9 = _export;
6575
+ var iterate$1 = iterate$a;
6576
+ var aCallable$2 = aCallable$j;
6577
+ var anObject$4 = anObject$s;
6578
+ var getIteratorDirect$2 = getIteratorDirect$a;
6579
+
6580
+ // `Iterator.prototype.every` method
6581
+ // https://github.com/tc39/proposal-iterator-helpers
6582
+ $$9({ target: 'Iterator', proto: true, real: true }, {
6583
+ every: function every(predicate) {
6584
+ anObject$4(this);
6585
+ aCallable$2(predicate);
6586
+ var record = getIteratorDirect$2(this);
6587
+ var counter = 0;
6588
+ return !iterate$1(record, function (value, stop) {
6589
+ if (!predicate(value, counter++)) return stop();
6590
+ }, { IS_RECORD: true, INTERRUPTED: true }).stopped;
6591
+ }
6592
+ });
6593
+
6594
+ const isObject$1 = v => v !== null && typeof v === 'object' && !Array.isArray(v);
6595
+ const splitPath = path => path.replace(/^#\/properties\//, '').replace(/\//g, '.').split('.').filter(Boolean);
6596
+ const getDataAt = (rootData, pathSegs) => {
6597
+ let cur = rootData;
6598
+ for (const seg of pathSegs) {
6599
+ if (cur == null) return undefined;
6600
+ if (Array.isArray(cur) && /^\d+$/.test(seg)) {
6601
+ cur = cur[Number(seg)];
6602
+ } else {
6603
+ cur = cur[seg];
6604
+ }
6605
+ }
6606
+ return cur;
6607
+ };
6608
+ const compileAndTest = (ajv, schema, data) => {
6609
+ var _validate$errors;
6610
+ const validate = ajv.compile(schema);
6611
+ const ok = validate(data);
6612
+ return {
6613
+ valid: ok,
6614
+ errors: (_validate$errors = validate.errors) != null ? _validate$errors : undefined
6615
+ };
6616
+ };
6617
+ const pickBranch = (ajv, branches, data, strategy) => {
6618
+ const results = branches.map(s => compileAndTest(ajv, s, data));
6619
+ const validIdx = results.map((r, i) => r.valid ? i : -1).filter(i => i >= 0);
6620
+ if (validIdx.length > 0) {
6621
+ if (strategy === 'union') return validIdx.map(i => branches[i]);
6622
+ if (strategy === 'intersection') return validIdx.map(i => branches[i]);
6623
+ // bestMatch
6624
+ return [branches[validIdx[0]]];
6625
+ }
6626
+ if (strategy === 'bestMatch') {
6627
+ let best = 0;
6628
+ let bestCount = Number.POSITIVE_INFINITY;
6629
+ results.forEach((r, i) => {
6630
+ var _r$errors$length, _r$errors;
6631
+ const c = (_r$errors$length = (_r$errors = r.errors) == null ? void 0 : _r$errors.length) != null ? _r$errors$length : 9999;
6632
+ if (c < bestCount) {
6633
+ bestCount = c;
6634
+ best = i;
6635
+ }
6636
+ });
6637
+ return [branches[best]];
6638
+ }
6639
+ return branches;
6640
+ };
6641
+ const mergeSets = (a, b) => {
6642
+ b.forEach(x => a.add(x));
6643
+ };
6644
+ const intersectSets = sets => {
6645
+ if (sets.length === 0) return new Set();
6646
+ const [first, ...rest] = sets;
6647
+ const out = new Set();
6648
+ first.forEach(x => {
6649
+ if (rest.every(s => s.has(x))) out.add(x);
6650
+ });
6651
+ return out;
6652
+ };
6653
+ const collectRequired = (ajv, schema, rootSchema, rootData, basePath, strategy) => {
6654
+ const requiredPaths = new Set();
6655
+ if (!schema || typeof schema !== 'object') return requiredPaths;
6656
+ const dataHere = basePath ? getDataAt(rootData, splitPath(basePath)) : rootData;
6657
+ if (schema.if && (schema.then || schema.else)) {
6658
+ const ifResult = compileAndTest(ajv, schema.if, dataHere);
6659
+ const branch = ifResult.valid ? schema.then : schema.else;
6660
+ if (branch) {
6661
+ mergeSets(requiredPaths, collectRequired(ajv, branch, rootSchema, rootData, basePath, strategy));
6662
+ }
6663
+ }
6664
+ if (Array.isArray(schema.allOf)) {
6665
+ schema.allOf.forEach(sub => {
6666
+ mergeSets(requiredPaths, collectRequired(ajv, sub, rootSchema, rootData, basePath, strategy));
6667
+ });
6668
+ }
6669
+ const altKey = Array.isArray(schema.oneOf) ? 'oneOf' : Array.isArray(schema.anyOf) ? 'anyOf' : null;
6670
+ if (altKey) {
6671
+ const branches = schema[altKey];
6672
+ const chosen = pickBranch(ajv, branches, dataHere, strategy);
6673
+ if (strategy === 'intersection') {
6674
+ const sets = chosen.map(sub => collectRequired(ajv, sub, rootSchema, rootData, basePath, strategy));
6675
+ return intersectSets([requiredPaths, ...sets]);
6676
+ }
6677
+ chosen.forEach(sub => {
6678
+ mergeSets(requiredPaths, collectRequired(ajv, sub, rootSchema, rootData, basePath, strategy));
6679
+ });
6680
+ }
6681
+ if (Array.isArray(schema.required) && isObject$1(schema.properties)) {
6682
+ for (const key of schema.required) {
6683
+ requiredPaths.add(basePath ? `${basePath}.${key}` : key);
6684
+ }
6685
+ }
6686
+ if (isObject$1(schema.properties)) {
6687
+ for (const [key, subSchema] of Object.entries(schema.properties)) {
6688
+ const nextPath = basePath ? `${basePath}.${key}` : key;
6689
+ mergeSets(requiredPaths, collectRequired(ajv, subSchema, rootSchema, rootData, nextPath, strategy));
6690
+ }
6691
+ }
6692
+ if (schema.type === 'array' && schema.items) {
6693
+ const nextPath = basePath ? `${basePath}.0` : '0';
6694
+ mergeSets(requiredPaths, collectRequired(ajv, schema.items, rootSchema, rootData, nextPath, strategy));
6695
+ }
6696
+ return requiredPaths;
6697
+ };
6698
+ const isRequiredBySchema = (rootSchema, rootData, path, options = {}) => {
6699
+ var _options$ajv, _options$strategy;
6700
+ if (!path) return false;
6701
+ const ajv = (_options$ajv = options.ajv) != null ? _options$ajv : new Ajv({
6702
+ allErrors: true,
6703
+ strict: false
6704
+ });
6705
+ const strategy = (_options$strategy = options.strategy) != null ? _options$strategy : 'bestMatch';
6706
+ const reqSet = collectRequired(ajv, rootSchema, rootSchema, rootData, '', strategy);
6707
+ const dotPath = splitPath(path).join('.');
6708
+ return reqSet.has(dotPath);
6709
+ };
6710
+
6594
6711
  const GoAInputBaseControl = props => {
6595
6712
  var _stepperState$categor, _uischema$options$com, _uischema$options, _uischema$options2, _uischema$options3;
6596
6713
  const {
@@ -6613,6 +6730,10 @@ const GoAInputBaseControl = props => {
6613
6730
  const currentCategory = stepperState == null || (_stepperState$categor = stepperState.categories) == null ? void 0 : _stepperState$categor[stepperState == null ? void 0 : stepperState.activeId];
6614
6731
  const showReviewLink = currentCategory == null ? void 0 : currentCategory.showReviewPageLink;
6615
6732
  const [isVisited, setIsVisited] = useState(skipInitialValidation === true);
6733
+ const {
6734
+ core
6735
+ } = useJsonForms();
6736
+ const rootData = core == null ? void 0 : core.data;
6616
6737
  useEffect(() => {
6617
6738
  if (showReviewLink === true && !isStepperReview) {
6618
6739
  setIsVisited(true);
@@ -6651,6 +6772,9 @@ const GoAInputBaseControl = props => {
6651
6772
  if (modifiedErrors === 'must be equal to one of the allowed values') {
6652
6773
  modifiedErrors = '';
6653
6774
  }
6775
+ const requiredNow = required || isRequiredBySchema(props.rootSchema, rootData, props.path, {
6776
+ strategy: 'bestMatch'
6777
+ });
6654
6778
  return jsx(JsonFormRegisterProvider, {
6655
6779
  defaultRegisters: undefined,
6656
6780
  children: jsx(Visible, {
@@ -6658,7 +6782,7 @@ const GoAInputBaseControl = props => {
6658
6782
  children: jsx(FormFieldWrapper, {
6659
6783
  ref: controlRef,
6660
6784
  children: jsx(GoabFormItem, {
6661
- requirement: (_uischema$options$com = uischema == null || (_uischema$options = uischema.options) == null || (_uischema$options = _uischema$options.componentProps) == null ? void 0 : _uischema$options.requirement) != null ? _uischema$options$com : required || getRequiredIfThen(props).length > 0 ? 'required' : undefined,
6785
+ requirement: (_uischema$options$com = uischema == null || (_uischema$options = uischema.options) == null || (_uischema$options = _uischema$options.componentProps) == null ? void 0 : _uischema$options.requirement) != null ? _uischema$options$com : requiredNow ? 'required' : undefined,
6662
6786
  error: isVisited === true ? modifiedErrors : undefined,
6663
6787
  testId: isStepperReview === true ? `review-base-${path}` : path,
6664
6788
  label: (props == null ? void 0 : props.noLabel) === true ? '' : labelToUpdate,
@@ -6676,7 +6800,7 @@ const GoAInputBaseControl = props => {
6676
6800
  });
6677
6801
  };
6678
6802
 
6679
- var $$9 = _export;
6803
+ var $$8 = _export;
6680
6804
  var DESCRIPTORS = descriptors;
6681
6805
  var global$2 = global$r;
6682
6806
  var uncurryThis$5 = functionUncurryThis;
@@ -6728,14 +6852,14 @@ if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototy
6728
6852
  }
6729
6853
  });
6730
6854
 
6731
- $$9({ global: true, constructor: true, forced: true }, {
6855
+ $$8({ global: true, constructor: true, forced: true }, {
6732
6856
  Symbol: SymbolWrapper
6733
6857
  });
6734
6858
  }
6735
6859
 
6736
6860
  var call$3 = functionCall;
6737
6861
  var fixRegExpWellKnownSymbolLogic$1 = fixRegexpWellKnownSymbolLogic;
6738
- var anObject$4 = anObject$s;
6862
+ var anObject$3 = anObject$s;
6739
6863
  var isNullOrUndefined$1 = isNullOrUndefined$7;
6740
6864
  var toLength$3 = toLength$7;
6741
6865
  var toString$6 = toString$j;
@@ -6757,7 +6881,7 @@ fixRegExpWellKnownSymbolLogic$1('match', function (MATCH, nativeMatch, maybeCall
6757
6881
  // `RegExp.prototype[@@match]` method
6758
6882
  // https://tc39.es/ecma262/#sec-regexp.prototype-@@match
6759
6883
  function (string) {
6760
- var rx = anObject$4(this);
6884
+ var rx = anObject$3(this);
6761
6885
  var S = toString$6(string);
6762
6886
  var res = maybeCallNative(nativeMatch, rx, S);
6763
6887
 
@@ -6826,13 +6950,13 @@ var stringTrimForced = function (METHOD_NAME) {
6826
6950
  });
6827
6951
  };
6828
6952
 
6829
- var $$8 = _export;
6953
+ var $$7 = _export;
6830
6954
  var $trim = stringTrim.trim;
6831
6955
  var forcedStringTrimMethod = stringTrimForced;
6832
6956
 
6833
6957
  // `String.prototype.trim` method
6834
6958
  // https://tc39.es/ecma262/#sec-string.prototype.trim
6835
- $$8({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
6959
+ $$7({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
6836
6960
  trim: function trim() {
6837
6961
  return $trim(this);
6838
6962
  }
@@ -7436,13 +7560,13 @@ var userAgent = engineUserAgent;
7436
7560
 
7437
7561
  var stringPadWebkitBug = /Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent);
7438
7562
 
7439
- var $$7 = _export;
7563
+ var $$6 = _export;
7440
7564
  var $padStart = stringPad.start;
7441
7565
  var WEBKIT_BUG = stringPadWebkitBug;
7442
7566
 
7443
7567
  // `String.prototype.padStart` method
7444
7568
  // https://tc39.es/ecma262/#sec-string.prototype.padstart
7445
- $$7({ target: 'String', proto: true, forced: WEBKIT_BUG }, {
7569
+ $$6({ target: 'String', proto: true, forced: WEBKIT_BUG }, {
7446
7570
  padStart: function padStart(maxLength /* , fillString = ' ' */) {
7447
7571
  return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
7448
7572
  }
@@ -8437,7 +8561,7 @@ const GoAInputBaseTableReviewControl = withJsonFormsControlProps(GoAInputBaseTab
8437
8561
  var call$2 = functionCall;
8438
8562
  var uncurryThis$2 = functionUncurryThis;
8439
8563
  var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
8440
- var anObject$3 = anObject$s;
8564
+ var anObject$2 = anObject$s;
8441
8565
  var isNullOrUndefined = isNullOrUndefined$7;
8442
8566
  var requireObjectCoercible$1 = requireObjectCoercible$e;
8443
8567
  var speciesConstructor = speciesConstructor$2;
@@ -8497,7 +8621,7 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa
8497
8621
  // NOTE: This cannot be properly polyfilled in engines that don't support
8498
8622
  // the 'y' flag.
8499
8623
  function (string, limit) {
8500
- var rx = anObject$3(this);
8624
+ var rx = anObject$2(this);
8501
8625
  var S = toString$2(string);
8502
8626
 
8503
8627
  if (!BUGGY) {
@@ -9085,12 +9209,13 @@ const ContextProviderFactory = () => new ContextProviderClass().setup;
9085
9209
  const JsonFormContext = /*#__PURE__*/createContext(null);
9086
9210
 
9087
9211
  const RenderStepElements = props => {
9212
+ const memoizedSchema = useMemo(() => Object.assign({}, props.schema), [props.schema, props.validationTrigger]);
9088
9213
  return jsx(Visible, {
9089
9214
  visible: props.visible,
9090
- "date-testid": `${props.path}-categories-${props.categoryIndex}`,
9215
+ "data-testid": `${props.path}-categories-${props.categoryIndex}`,
9091
9216
  children: props.category.elements.map((uiSchema, index) => {
9092
9217
  return jsx(JsonFormsDispatch, {
9093
- schema: props.schema,
9218
+ schema: memoizedSchema,
9094
9219
  uischema: uiSchema,
9095
9220
  renderers: props.renderers,
9096
9221
  cells: props.cells,
@@ -9138,7 +9263,7 @@ var flattenIntoArray_1 = flattenIntoArray$2;
9138
9263
 
9139
9264
  var isArray = isArray$5;
9140
9265
  var isConstructor = isConstructor$2;
9141
- var isObject = isObject$f;
9266
+ var isObject = isObject$g;
9142
9267
  var wellKnownSymbol = wellKnownSymbol$m;
9143
9268
 
9144
9269
  var SPECIES = wellKnownSymbol('species');
@@ -9167,7 +9292,7 @@ var arraySpeciesCreate$2 = function (originalArray, length) {
9167
9292
  return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
9168
9293
  };
9169
9294
 
9170
- var $$6 = _export;
9295
+ var $$5 = _export;
9171
9296
  var flattenIntoArray$1 = flattenIntoArray_1;
9172
9297
  var toObject$1 = toObject$9;
9173
9298
  var lengthOfArrayLike$1 = lengthOfArrayLike$9;
@@ -9176,7 +9301,7 @@ var arraySpeciesCreate$1 = arraySpeciesCreate$2;
9176
9301
 
9177
9302
  // `Array.prototype.flat` method
9178
9303
  // https://tc39.es/ecma262/#sec-array.prototype.flat
9179
- $$6({ target: 'Array', proto: true }, {
9304
+ $$5({ target: 'Array', proto: true }, {
9180
9305
  flat: function flat(/* depthArg = 1 */) {
9181
9306
  var depthArg = arguments.length ? arguments[0] : undefined;
9182
9307
  var O = toObject$1(this);
@@ -9194,28 +9319,8 @@ var addToUnscopables$1 = addToUnscopables$5;
9194
9319
  // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
9195
9320
  addToUnscopables$1('flat');
9196
9321
 
9197
- var $$5 = _export;
9198
- var iterate$1 = iterate$a;
9199
- var aCallable$2 = aCallable$j;
9200
- var anObject$2 = anObject$s;
9201
- var getIteratorDirect$2 = getIteratorDirect$a;
9202
-
9203
- // `Iterator.prototype.every` method
9204
- // https://github.com/tc39/proposal-iterator-helpers
9205
- $$5({ target: 'Iterator', proto: true, real: true }, {
9206
- every: function every(predicate) {
9207
- anObject$2(this);
9208
- aCallable$2(predicate);
9209
- var record = getIteratorDirect$2(this);
9210
- var counter = 0;
9211
- return !iterate$1(record, function (value, stop) {
9212
- if (!predicate(value, counter++)) return stop();
9213
- }, { IS_RECORD: true, INTERRUPTED: true }).stopped;
9214
- }
9215
- });
9216
-
9217
9322
  const isPropertiesMatch = (obj, props, isExactMatch) => {
9218
- if (isObject$g(obj)) {
9323
+ if (isObject$h(obj)) {
9219
9324
  const keys = Object.keys(obj);
9220
9325
  if (isExactMatch) {
9221
9326
  return props.every(attr => keys.includes(attr)) && keys.length === props.length;
@@ -9235,27 +9340,24 @@ const isFullName = createSchemaMatchTester(['firstName', 'middleName', 'lastName
9235
9340
  const FullNameTester = rankWith(4, isFullName);
9236
9341
 
9237
9342
  const FullNameControlReview = props => {
9238
- var _props$uischema, _props$data, _props$data2, _props$data3, _props$data4;
9343
+ var _props$uischema;
9239
9344
  const context = useContext(JsonFormsStepperContext);
9240
9345
  const stepId = (_props$uischema = props.uischema) == null || (_props$uischema = _props$uischema.options) == null ? void 0 : _props$uischema.stepId;
9241
9346
  const {
9242
9347
  label,
9243
9348
  errors,
9244
9349
  required,
9245
- uischema
9350
+ uischema,
9351
+ data,
9352
+ id
9246
9353
  } = props;
9247
- const renderRow = (label, value, testId) => jsx("tr", {
9354
+ const renderRow = (fieldLabel, value, testId) => jsx("tr", {
9248
9355
  children: jsxs(PageReviewContainer, {
9249
9356
  colSpan: 3,
9250
- children: [jsxs(ReviewHeader, {
9251
- children: [jsx(ReviewLabel, {
9252
- children: label
9253
- }), jsx(GoabButton, {
9254
- type: "tertiary",
9255
- size: "compact",
9256
- onClick: () => context == null ? void 0 : context.goToPage(stepId, uischema.scope),
9257
- children: "Change"
9258
- })]
9357
+ children: [jsx(ReviewHeader, {
9358
+ children: jsx(ReviewLabel, {
9359
+ children: fieldLabel
9360
+ })
9259
9361
  }), jsx(ReviewValue, {
9260
9362
  children: jsx("div", {
9261
9363
  "data-testid": testId,
@@ -9263,15 +9365,23 @@ const FullNameControlReview = props => {
9263
9365
  })
9264
9366
  })]
9265
9367
  })
9266
- });
9368
+ }, testId);
9267
9369
  return jsxs(Fragment, {
9268
9370
  children: [jsx("tr", {
9269
9371
  "data-testid": "full-name-header",
9270
9372
  children: jsxs(PageReviewContainer, {
9271
9373
  colSpan: 3,
9272
- children: [jsxs(ReviewLabel, {
9273
- children: [label, required && jsx(RequiredTextLabel, {
9274
- children: " (required)"
9374
+ children: [jsxs(ReviewHeader, {
9375
+ children: [jsxs(ReviewLabel, {
9376
+ children: [label, required && jsx(RequiredTextLabel, {
9377
+ children: " (required)"
9378
+ })]
9379
+ }), stepId !== undefined && jsx(GoabButton, {
9380
+ type: "tertiary",
9381
+ size: "compact",
9382
+ onClick: () => context == null ? void 0 : context.goToPage(stepId, uischema.scope),
9383
+ testId: "full-name-change-btn",
9384
+ children: "Change"
9275
9385
  })]
9276
9386
  }), errors && jsxs(WarningIconDiv, {
9277
9387
  children: [jsx(GoabIcon, {
@@ -9280,7 +9390,7 @@ const FullNameControlReview = props => {
9280
9390
  }), errors != null && errors.includes('is a required property') ? `${label} is required` : errors]
9281
9391
  })]
9282
9392
  })
9283
- }), renderRow('First name', (_props$data = props.data) == null ? void 0 : _props$data.firstName, `firstName-control-${props.id}`), ((_props$data2 = props.data) == null ? void 0 : _props$data2.middleName) && renderRow('Middle name', (_props$data3 = props.data) == null ? void 0 : _props$data3.middleName, `middleName-control-${props.id}`), renderRow('Last name', (_props$data4 = props.data) == null ? void 0 : _props$data4.lastName, `lastName-control-${props.id}`)]
9393
+ }), renderRow('First name', data == null ? void 0 : data.firstName, `firstName-control-${id}`), (data == null ? void 0 : data.middleName) && renderRow('Middle name', data == null ? void 0 : data.middleName, `middleName-control-${id}`), renderRow('Last name', data == null ? void 0 : data.lastName, `lastName-control-${id}`)]
9284
9394
  });
9285
9395
  };
9286
9396
  const GoAInputBaseFullNameControlReview = withJsonFormsAllOfProps(FullNameControlReview);
@@ -9293,32 +9403,53 @@ const FullNameDobReviewControl = props => {
9293
9403
  const {
9294
9404
  data,
9295
9405
  id,
9296
- uischema
9406
+ uischema,
9407
+ label,
9408
+ required,
9409
+ errors
9297
9410
  } = props;
9298
9411
  const context = useContext(JsonFormsStepperContext);
9299
9412
  const stepId = uischema == null || (_uischema$options = uischema.options) == null ? void 0 : _uischema$options.stepId;
9300
- const renderRow = (label, value, testId) => jsxs("tr", {
9301
- children: [jsx(PageReviewNameCol, {
9302
- children: jsx("strong", {
9303
- children: label
9304
- })
9305
- }), jsx(PageReviewValueCol, {
9306
- children: jsx("div", {
9307
- "data-testid": testId,
9308
- children: value
9309
- })
9310
- }), jsx("td", {
9311
- className: "goa-table-width-limit",
9312
- children: jsx(GoabButton, {
9313
- type: "tertiary",
9314
- size: "compact",
9315
- onClick: () => context == null ? void 0 : context.goToPage(stepId, uischema.scope),
9316
- children: "Change"
9317
- })
9318
- })]
9319
- });
9413
+ const renderRow = (fieldLabel, value, testId) => jsx("tr", {
9414
+ children: jsxs(PageReviewContainer, {
9415
+ colSpan: 3,
9416
+ children: [jsx(ReviewHeader, {
9417
+ children: jsx(ReviewLabel, {
9418
+ children: fieldLabel
9419
+ })
9420
+ }), jsx(ReviewValue, {
9421
+ children: jsx("div", {
9422
+ "data-testid": testId,
9423
+ children: value
9424
+ })
9425
+ })]
9426
+ })
9427
+ }, testId);
9320
9428
  return jsxs(Fragment, {
9321
- children: [renderRow('First name', data == null ? void 0 : data.firstName, `firstName-control-${id}`), (data == null ? void 0 : data.middleName) && renderRow('Middle name', data == null ? void 0 : data.middleName, `middleName-control-${id}`), renderRow('Last name', data == null ? void 0 : data.lastName, `lastName-control-${id}`), renderRow('Date of birth', data == null ? void 0 : data.dateOfBirth, `dob-control-${id}`)]
9429
+ children: [jsx("tr", {
9430
+ "data-testid": "fullname-dob-header",
9431
+ children: jsxs(PageReviewContainer, {
9432
+ colSpan: 3,
9433
+ children: [jsxs(ReviewHeader, {
9434
+ children: [jsxs(ReviewLabel, {
9435
+ children: [label, required && jsx(RequiredTextLabel, {
9436
+ children: " (required)"
9437
+ })]
9438
+ }), stepId !== undefined && jsx(GoabButton, {
9439
+ type: "tertiary",
9440
+ size: "compact",
9441
+ onClick: () => context == null ? void 0 : context.goToPage(stepId, uischema.scope),
9442
+ testId: "fullname-dob-change-btn",
9443
+ children: "Change"
9444
+ })]
9445
+ }), errors && jsxs(WarningIconDiv, {
9446
+ children: [jsx(GoabIcon, {
9447
+ type: "warning",
9448
+ size: "small"
9449
+ }), errors != null && errors.includes('is a required property') ? `${label} is required` : errors]
9450
+ })]
9451
+ })
9452
+ }), renderRow('First name', data == null ? void 0 : data.firstName, `firstName-control-${id}`), (data == null ? void 0 : data.middleName) && renderRow('Middle name', data == null ? void 0 : data.middleName, `middleName-control-${id}`), renderRow('Last name', data == null ? void 0 : data.lastName, `lastName-control-${id}`), renderRow('Date of birth', data == null ? void 0 : data.dateOfBirth, `dob-control-${id}`)]
9322
9453
  });
9323
9454
  };
9324
9455
  const GoAInputBaseFullNameDobControlReview = withJsonFormsAllOfProps(FullNameDobReviewControl);
@@ -11672,10 +11803,11 @@ const AddressLoopUpControlTableReview = props => {
11672
11803
  data,
11673
11804
  schema,
11674
11805
  uischema,
11675
- path
11806
+ path,
11807
+ label,
11808
+ required
11676
11809
  } = props;
11677
11810
  const jsonForms = useJsonForms();
11678
- // eslint-disable-next-line
11679
11811
  const stepId = (_uischema$options = uischema.options) == null ? void 0 : _uischema$options.stepId;
11680
11812
  const formStepperCtx = useContext(JsonFormsStepperContext);
11681
11813
  const isAlbertaAddress = (schema == null || (_schema$properties2 = schema.properties) == null || (_schema$properties2 = _schema$properties2.subdivisionCode) == null ? void 0 : _schema$properties2.const) === 'AB';
@@ -11752,7 +11884,9 @@ const AddressLoopUpControlTableReview = props => {
11752
11884
  var _schema$required;
11753
11885
  return schema == null || (_schema$required = schema.required) == null ? void 0 : _schema$required.includes(propName);
11754
11886
  };
11755
- const renderRow = (label, value, propName, showButton = true) => {
11887
+ // Build the target scope for the address control
11888
+ const targetScope = (uischema == null ? void 0 : uischema.scope) || (path ? `#/properties/${path}` : undefined);
11889
+ const renderRow = (label, value, propName, showButton = false) => {
11756
11890
  var _error, _error2;
11757
11891
  let error = getError(propName);
11758
11892
  const required = isRequired(propName);
@@ -11767,10 +11901,11 @@ const AddressLoopUpControlTableReview = props => {
11767
11901
  children: [label, required && jsx(RequiredTextLabel, {
11768
11902
  children: " (required)"
11769
11903
  })]
11770
- }), showButton && jsx(GoabButton, {
11904
+ }), showButton && stepId !== undefined && jsx(GoabButton, {
11771
11905
  type: "tertiary",
11772
11906
  size: "compact",
11773
- onClick: () => formStepperCtx == null ? void 0 : formStepperCtx.goToPage(stepId, uischema.scope),
11907
+ onClick: () => formStepperCtx == null ? void 0 : formStepperCtx.goToPage(stepId, targetScope),
11908
+ testId: "address-change-btn",
11774
11909
  children: "Change"
11775
11910
  })]
11776
11911
  }), jsxs(ReviewValue, {
@@ -11782,7 +11917,7 @@ const AddressLoopUpControlTableReview = props => {
11782
11917
  })]
11783
11918
  })]
11784
11919
  })
11785
- });
11920
+ }, propName);
11786
11921
  };
11787
11922
  return jsxs(Fragment, {
11788
11923
  children: [jsx("tr", {
@@ -11793,7 +11928,7 @@ const AddressLoopUpControlTableReview = props => {
11793
11928
  children: `${isAlbertaAddress ? 'Alberta' : 'Canada'} postal address`
11794
11929
  })
11795
11930
  })
11796
- }), renderRow('Address line 1', data == null ? void 0 : data.addressLine1, 'addressLine1'), (data == null ? void 0 : data.addressLine2) && renderRow('Address line 2', data.addressLine2, 'addressLine2'), renderRow('City', data == null ? void 0 : data.municipality, 'municipality'), renderRow('Postal Code', data == null ? void 0 : data.postalCode, 'postalCode'), renderRow('Province', provinceLabel, 'subdivisionCode'), renderRow('Country', 'Canada', 'country', false)]
11931
+ }), renderRow('Address line 1', data == null ? void 0 : data.addressLine1, 'addressLine1', true), (data == null ? void 0 : data.addressLine2) && renderRow('Address line 2', data.addressLine2, 'addressLine2', false), renderRow('City', data == null ? void 0 : data.municipality, 'municipality', false), renderRow('Postal Code', data == null ? void 0 : data.postalCode, 'postalCode', false), renderRow('Province', provinceLabel, 'subdivisionCode', false), renderRow('Country', 'Canada', 'country', false)]
11797
11932
  });
11798
11933
  };
11799
11934
 
@@ -12637,7 +12772,8 @@ const FormStepperView = props => {
12637
12772
  hasNextButton,
12638
12773
  hasPrevButton,
12639
12774
  isOnReview,
12640
- isValid
12775
+ isValid,
12776
+ validationTrigger
12641
12777
  } = formStepperCtx.selectStepperState();
12642
12778
  const {
12643
12779
  selectIsDisabled,
@@ -12698,7 +12834,8 @@ const FormStepperView = props => {
12698
12834
  schema,
12699
12835
  renderers,
12700
12836
  cells,
12701
- data
12837
+ data,
12838
+ validationTrigger
12702
12839
  };
12703
12840
  return jsx("div", {
12704
12841
  "data-testid": `step_${index}-content`,
@@ -13174,7 +13311,8 @@ const RenderPages = props => {
13174
13311
  categories,
13175
13312
  isOnReview,
13176
13313
  isValid,
13177
- activeId
13314
+ activeId,
13315
+ validationTrigger
13178
13316
  } = formStepperCtx.selectStepperState();
13179
13317
  const hideSubmit = (_props$categoryProps$ = (_props$categoryProps$2 = props.categoryProps.uischema.options) == null ? void 0 : _props$categoryProps$2.hideSubmit) != null ? _props$categoryProps$ : false;
13180
13318
  const toAppOverviewLabel = (_props$categoryProps$3 = (_props$categoryProps$4 = props.categoryProps.uischema.options) == null ? void 0 : _props$categoryProps$4.toAppOverviewLabel) != null ? _props$categoryProps$3 : 'Back to application overview';
@@ -13227,12 +13365,15 @@ const RenderPages = props => {
13227
13365
  schema,
13228
13366
  renderers,
13229
13367
  cells,
13230
- data
13368
+ data,
13369
+ validationTrigger
13231
13370
  };
13232
- if (index === activeId && !isOnReview) {
13233
- const currentStep = index + 1 - categories.filter(c => !c.visible && c.id < index).length;
13234
- const totalSteps = categories.filter(c => c.visible).length;
13235
- return jsxs("div", {
13371
+ const currentStep = index + 1 - categories.filter(c => !c.visible && c.id < index).length;
13372
+ const totalSteps = categories.filter(c => c.visible).length;
13373
+ const isActive = index === activeId && !isOnReview;
13374
+ return jsx(Visible, {
13375
+ visible: isActive,
13376
+ children: jsxs("div", {
13236
13377
  "data-testid": `step_${index}-content-pages`,
13237
13378
  style: {
13238
13379
  marginTop: '1.5rem'
@@ -13289,8 +13430,8 @@ const RenderPages = props => {
13289
13430
  })]
13290
13431
  })
13291
13432
  })]
13292
- }, `${category.label}`);
13293
- }
13433
+ })
13434
+ }, `page-${category.id}`);
13294
13435
  }), isOnReview && jsxs("div", {
13295
13436
  "data-testid": "stepper-pages-review-page",
13296
13437
  children: [jsx(FormStepperPageReviewer, Object.assign({}, props.categoryProps, {
@@ -14047,10 +14188,12 @@ const AddressLookUpControl = props => {
14047
14188
  } = props;
14048
14189
  const isAlbertaAddress = (schema == null || (_schema$properties = schema.properties) == null || (_schema$properties = _schema$properties.subdivisionCode) == null ? void 0 : _schema$properties.const) === 'AB';
14049
14190
  const formCtx = useContext(JsonFormContext);
14191
+ const formStepperCtx = useContext(JsonFormsStepperContext);
14050
14192
  const formHost = formCtx == null ? void 0 : formCtx.formUrl;
14051
14193
  const formUrl = `${formHost}/${ADDRESS_PATH}`;
14052
14194
  const autocompletion = (uischema == null || (_uischema$options = uischema.options) == null ? void 0 : _uischema$options.autocomplete) !== false;
14053
14195
  const [open, setOpen] = useState(false);
14196
+ const addressContainerRef = useRef(null);
14054
14197
  const label = typeof (uischema == null ? void 0 : uischema.label) === 'string' && uischema.label ? uischema.label : '';
14055
14198
  let defaultAddress = {};
14056
14199
  if (isAlbertaAddress) {
@@ -14178,74 +14321,102 @@ const AddressLookUpControl = props => {
14178
14321
  }
14179
14322
  }
14180
14323
  }, [activeIndex]);
14324
+ // Handle focus when navigated from review page
14325
+ useEffect(() => {
14326
+ const stepperState = formStepperCtx == null || formStepperCtx.selectStepperState == null ? void 0 : formStepperCtx.selectStepperState();
14327
+ if (stepperState != null && stepperState.targetScope && uischema != null && uischema.scope && stepperState.targetScope === uischema.scope && addressContainerRef.current) {
14328
+ const addressInput = addressContainerRef.current.querySelector('goa-input[name="addressLine1"]');
14329
+ if (addressInput) {
14330
+ addressContainerRef.current.scrollIntoView({
14331
+ behavior: 'smooth',
14332
+ block: 'center'
14333
+ });
14334
+ setTimeout(() => {
14335
+ if (typeof addressInput.focus === 'function') {
14336
+ addressInput.focus();
14337
+ }
14338
+ const shadowRoot = addressInput.shadowRoot;
14339
+ if (shadowRoot) {
14340
+ const actualInput = shadowRoot.querySelector('input');
14341
+ if (actualInput instanceof HTMLElement) {
14342
+ actualInput.focus();
14343
+ }
14344
+ }
14345
+ }, 300);
14346
+ }
14347
+ }
14348
+ }, [formStepperCtx, uischema == null ? void 0 : uischema.scope]);
14181
14349
  const readOnly = (_uischema$options$com = uischema == null || (_uischema$options2 = uischema.options) == null || (_uischema$options2 = _uischema$options2.componentProps) == null ? void 0 : _uischema$options2.readOnly) != null ? _uischema$options$com : false;
14182
- return jsxs(Visible, {
14350
+ return jsx(Visible, {
14183
14351
  visible: visible,
14184
- children: [renderHelp(), jsx("h3", {
14185
- children: label
14186
- }), jsx(GoabFormItem, {
14187
- requirement: 'required',
14188
- label: 'Street address or P.O. box',
14189
- error: (_errors$addressLine = errors == null ? void 0 : errors['addressLine1']) != null ? _errors$addressLine : '',
14190
- "data-testId": "form-address-line1",
14191
- children: jsxs(SearchBox, {
14192
- children: [jsxs("div", {
14193
- className: "input-container",
14194
- children: [jsx(GoabInput, {
14195
- leadingIcon: autocompletion && enabled ? 'search' : undefined,
14196
- id: "goaInput",
14197
- name: "addressLine1",
14198
- testId: "address-form-address1",
14199
- readonly: readOnly,
14200
- disabled: !enabled,
14201
- ariaLabel: 'address-form-address1',
14202
- placeholder: "Start typing the first line of your address, required.",
14203
- value: (address == null ? void 0 : address.addressLine1) || '',
14204
- onChange: detail => handleDropdownChange(detail.value),
14205
- onBlur: detail => handleRequiredFieldBlur(detail.name),
14206
- width: "100%",
14207
- onKeyPress: detail => {
14208
- if (open) {
14209
- const newIndex = handleAddressKeyDown(detail.key, detail.value, activeIndex, suggestions, val => handleInputChange('addressLine1', val), suggestion => handleSuggestionClick(suggestion));
14210
- setActiveIndex(newIndex);
14352
+ children: jsxs("div", {
14353
+ ref: addressContainerRef,
14354
+ children: [renderHelp(), jsx("h3", {
14355
+ children: label
14356
+ }), jsx(GoabFormItem, {
14357
+ requirement: 'required',
14358
+ label: 'Street address or P.O. box',
14359
+ error: (_errors$addressLine = errors == null ? void 0 : errors['addressLine1']) != null ? _errors$addressLine : '',
14360
+ "data-testId": "form-address-line1",
14361
+ children: jsxs(SearchBox, {
14362
+ children: [jsxs("div", {
14363
+ className: "input-container",
14364
+ children: [jsx(GoabInput, {
14365
+ leadingIcon: autocompletion && enabled ? 'search' : undefined,
14366
+ id: "goaInput",
14367
+ name: "addressLine1",
14368
+ testId: "address-form-address1",
14369
+ readonly: readOnly,
14370
+ disabled: !enabled,
14371
+ ariaLabel: 'address-form-address1',
14372
+ placeholder: "Start typing the first line of your address, required.",
14373
+ value: (address == null ? void 0 : address.addressLine1) || '',
14374
+ onChange: detail => handleDropdownChange(detail.value),
14375
+ onBlur: detail => handleRequiredFieldBlur(detail.name),
14376
+ width: "100%",
14377
+ onKeyPress: detail => {
14378
+ if (open) {
14379
+ const newIndex = handleAddressKeyDown(detail.key, detail.value, activeIndex, suggestions, val => handleInputChange('addressLine1', val), suggestion => handleSuggestionClick(suggestion));
14380
+ setActiveIndex(newIndex);
14381
+ }
14211
14382
  }
14212
- }
14213
- }), loading && jsx("div", {
14214
- className: "input-spinner",
14215
- children: jsx(GoabSpinner, {
14216
- type: "infinite",
14217
- size: "small"
14218
- })
14383
+ }), loading && jsx("div", {
14384
+ className: "input-spinner",
14385
+ children: jsx(GoabSpinner, {
14386
+ type: "infinite",
14387
+ size: "small"
14388
+ })
14389
+ })]
14390
+ }), !loading && suggestions && autocompletion && jsx("ul", {
14391
+ ref: dropdownRef,
14392
+ className: "suggestions",
14393
+ children: suggestions && autocompletion && open && suggestions.map((suggestion, index) => jsx(ListItem, {
14394
+ "data-index": index,
14395
+ onMouseDown: e => {
14396
+ e.preventDefault();
14397
+ e.stopPropagation();
14398
+ },
14399
+ onClick: () => {
14400
+ handleSuggestionClick(suggestion);
14401
+ },
14402
+ selected: activeIndex,
14403
+ index: index,
14404
+ "data-testId": `listItem-${index}`,
14405
+ children: `${suggestion.Text} ${suggestion.Description}`
14406
+ }, index))
14219
14407
  })]
14220
- }), !loading && suggestions && autocompletion && jsx("ul", {
14221
- ref: dropdownRef,
14222
- className: "suggestions",
14223
- children: suggestions && autocompletion && open && suggestions.map((suggestion, index) => jsx(ListItem, {
14224
- "data-index": index,
14225
- onMouseDown: e => {
14226
- e.preventDefault();
14227
- e.stopPropagation();
14228
- },
14229
- onClick: () => {
14230
- handleSuggestionClick(suggestion);
14231
- },
14232
- selected: activeIndex,
14233
- index: index,
14234
- "data-testId": `listItem-${index}`,
14235
- children: `${suggestion.Text} ${suggestion.Description}`
14236
- }, index))
14237
- })]
14238
- })
14239
- }), jsx("br", {}), jsx(AddressInputs, {
14240
- address: address,
14241
- errors: errors,
14242
- readOnly: readOnly,
14243
- enabled: enabled,
14244
- handleInputChange: handleInputChange,
14245
- isAlbertaAddress: isAlbertaAddress,
14246
- handleOnBlur: handleRequiredFieldBlur,
14247
- requiredFields: requiredFields
14248
- })]
14408
+ })
14409
+ }), jsx("br", {}), jsx(AddressInputs, {
14410
+ address: address,
14411
+ errors: errors,
14412
+ readOnly: readOnly,
14413
+ enabled: enabled,
14414
+ handleInputChange: handleInputChange,
14415
+ isAlbertaAddress: isAlbertaAddress,
14416
+ handleOnBlur: handleRequiredFieldBlur,
14417
+ requiredFields: requiredFields
14418
+ })]
14419
+ })
14249
14420
  });
14250
14421
  };
14251
14422
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.45.1",
3
+ "version": "2.46.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",
@@ -10,5 +10,6 @@ export interface StepProps {
10
10
  renderers: JsonFormsRendererRegistryEntry[] | undefined;
11
11
  cells: JsonFormsCellRendererRegistryEntry[] | undefined;
12
12
  data: Record<string, unknown>;
13
+ validationTrigger?: number;
13
14
  }
14
15
  export declare const RenderStepElements: (props: StepProps) => JSX.Element;
@@ -26,5 +26,6 @@ export interface StepperContextDataType {
26
26
  isValid: boolean;
27
27
  maxReachedStep: number;
28
28
  targetScope?: string;
29
+ validationTrigger?: number;
29
30
  }
30
31
  export type CategorizationElement = Category | Categorization;
@@ -0,0 +1,10 @@
1
+ import type { JsonSchema7 } from '@jsonforms/core';
2
+ import Ajv from 'ajv';
3
+ type RequiredStrategy = 'bestMatch' | 'union' | 'intersection';
4
+ type Options = {
5
+ /** anyOf/oneOf required */
6
+ strategy?: RequiredStrategy;
7
+ ajv?: Ajv;
8
+ };
9
+ export declare const isRequiredBySchema: (rootSchema: JsonSchema7, rootData: any, path?: string, options?: Options) => boolean;
10
+ export {};