@abgov/jsonforms-components 2.70.0 → 2.70.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -4,17 +4,17 @@ import Ajv from 'ajv';
4
4
  import styled from 'styled-components';
5
5
  import axios from 'axios';
6
6
  import get$1 from 'lodash/get';
7
- import { isVisible, isEnabled, deriveLabelForUISchemaElement, rankWith, isStringControl, and, optionIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, uiTypeIs, isControl as isControl$1, isEnumControl, or, isOneOfEnumControl, isBooleanControl, createDefaultValue, Paths, Resolve, toDataPath, schemaTypeIs, formatIs, getAjv, schemaMatches, isObjectArrayControl, isPrimitiveArrayControl, composePaths, hasType, isCategorization, isLayout, INIT, UPDATE_CORE } from '@jsonforms/core';
7
+ import { toDataPath, INIT, UPDATE_CORE, isVisible, isEnabled, deriveLabelForUISchemaElement, rankWith, isStringControl, and, optionIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, uiTypeIs, isControl as isControl$1, isEnumControl, or, isOneOfEnumControl, isBooleanControl, createDefaultValue, Paths, Resolve, schemaTypeIs, formatIs, getAjv, schemaMatches, isObjectArrayControl, isPrimitiveArrayControl, composePaths, hasType, isCategorization, isLayout } from '@jsonforms/core';
8
8
  import * as _$c from 'lodash';
9
9
  import ___default, { isEmpty, isObject as isObject$i } from 'lodash';
10
10
  import { useJsonForms, withJsonFormsControlProps, withJsonFormsEnumProps, withTranslateProps, JsonFormsDispatch, withJsonFormsAllOfProps, withJsonFormsArrayLayoutProps, withJsonFormsLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
11
11
  import dompurify from 'dompurify';
12
12
  import * as xss from 'xss';
13
13
  import merge from 'lodash/merge';
14
+ import { GoabRadioGroup as GoabRadioGroup$1, GoabRadioItem as GoabRadioItem$1, GoabTable as GoabTable$1, GoabGrid as GoabGrid$1, GoabContainer as GoabContainer$1 } from '@abgov/react-components';
14
15
  import isEmpty$1 from 'lodash/isEmpty';
15
16
  import range from 'lodash/range';
16
17
  import pluralize from 'pluralize';
17
- import { GoabTable as GoabTable$1, GoabGrid as GoabGrid$1, GoabContainer as GoabContainer$1 } from '@abgov/react-components';
18
18
  import { compileSync } from '@mdx-js/mdx';
19
19
  import ReactMarkdown from 'react-markdown';
20
20
  import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
@@ -7272,10 +7272,6 @@ const getAddressLookupFieldLabel = fieldName => {
7272
7272
  return ADDRESS_LOOKUP_LABELS[fieldName] || fieldName;
7273
7273
  };
7274
7274
 
7275
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7276
- function getValueAtPath(obj, path) {
7277
- return path.split('.').reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
7278
- }
7279
7275
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7280
7276
  function hasMeaningfulValue(val) {
7281
7277
  if (val === undefined || val === null) return false;
@@ -7347,43 +7343,36 @@ function anyRequiredFieldEmpty(scopes, data, required, schema) {
7347
7343
  }
7348
7344
  return false;
7349
7345
  }
7350
- // Resolve a single schema scope against the provided data and determine whether
7351
- // it already holds a meaningful value. Used to derive the initial "visited"
7352
- // state of a step from populated form data.
7353
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7354
- function hasValueAtScope(data, scope) {
7355
- const path = normalizeSchemaPath(scope);
7356
- if (!path) return false;
7357
- return hasMeaningfulValue(getValueAtPath(data, path));
7358
- }
7359
7346
  function getStepStatus(opts) {
7360
7347
  const {
7361
7348
  scopes,
7362
7349
  errors,
7363
7350
  schema,
7364
7351
  data,
7365
- visited
7352
+ visited,
7353
+ autoPopulatedScopes = []
7366
7354
  } = opts;
7367
7355
  const normalizedScopes = scopes.map(normalizeSchemaPath).filter(Boolean);
7368
- // A step with no required fields has nothing that must be filled in, so once
7369
- // the user has visited it (e.g. navigated back to the application overview
7370
- // page) it is trivially Completed, regardless of whether its optional
7371
- // fields hold any data.
7372
7356
  const requiredForScopes = getRequiredForScopes(scopes, schema);
7373
7357
  const stepHasRequiredFields = isScopeRequired(normalizedScopes, requiredForScopes);
7374
- // NotStarted is data-driven: if any scoped field has a defined value the step has been started.
7375
- // For non-standard scopes that cannot be normalised, fall back to the visited flag so those
7376
- // steps are never stuck in NotStarted when the form is pre-populated or already visited.
7377
- const stepHasData = normalizedScopes.length > 0 ? normalizedScopes.some(path => hasMeaningfulValue(get$1(data || {}, path))) : visited != null ? visited : false;
7378
- if (!stepHasRequiredFields && (visited || stepHasData)) {
7358
+ // A step is "started" when the user has visited it OR it already holds user-entered data.
7359
+ // Auto-populated values (system-filled from the user profile) are excluded, so:
7360
+ // - a page the user has never opened is NotStarted even when auto-populated, and
7361
+ // - a saved form the user actually filled still shows its status when resumed.
7362
+ const autoPopulatedSet = new Set(autoPopulatedScopes.map(normalizeSchemaPath).filter(Boolean));
7363
+ const userDataScopes = normalizedScopes.filter(path => !autoPopulatedSet.has(path));
7364
+ const stepHasUserData = userDataScopes.length > 0 ? userDataScopes.some(path => hasMeaningfulValue(get$1(data || {}, path))) : false;
7365
+ const started = (visited != null ? visited : false) || stepHasUserData;
7366
+ if (!started) {
7379
7367
  return {
7380
- status: StepStatus.COMPLETED,
7368
+ status: StepStatus.NOT_STARTED,
7381
7369
  hasRequiredFields: stepHasRequiredFields
7382
7370
  };
7383
7371
  }
7384
- if (!stepHasData) {
7372
+ // A started step with no required fields has nothing left to fill in, so it is trivially Completed.
7373
+ if (!stepHasRequiredFields) {
7385
7374
  return {
7386
- status: StepStatus.NOT_STARTED,
7375
+ status: StepStatus.COMPLETED,
7387
7376
  hasRequiredFields: stepHasRequiredFields
7388
7377
  };
7389
7378
  }
@@ -7680,6 +7669,418 @@ const stepperReducer = (state, action) => {
7680
7669
  }
7681
7670
  };
7682
7671
 
7672
+ var isArray$1 = isArray$5;
7673
+ var lengthOfArrayLike$5 = lengthOfArrayLike$c;
7674
+ var doesNotExceedSafeInteger$1 = doesNotExceedSafeInteger$3;
7675
+ var bind$3 = functionBindContext;
7676
+
7677
+ // `FlattenIntoArray` abstract operation
7678
+ // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
7679
+ var flattenIntoArray$2 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
7680
+ var targetIndex = start;
7681
+ var sourceIndex = 0;
7682
+ var mapFn = mapper ? bind$3(mapper, thisArg) : false;
7683
+ var element, elementLen;
7684
+
7685
+ while (sourceIndex < sourceLen) {
7686
+ if (sourceIndex in source) {
7687
+ element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
7688
+
7689
+ if (depth > 0 && isArray$1(element)) {
7690
+ elementLen = lengthOfArrayLike$5(element);
7691
+ targetIndex = flattenIntoArray$2(target, original, element, elementLen, targetIndex, depth - 1) - 1;
7692
+ } else {
7693
+ doesNotExceedSafeInteger$1(targetIndex + 1);
7694
+ target[targetIndex] = element;
7695
+ }
7696
+
7697
+ targetIndex++;
7698
+ }
7699
+ sourceIndex++;
7700
+ }
7701
+ return targetIndex;
7702
+ };
7703
+
7704
+ var flattenIntoArray_1 = flattenIntoArray$2;
7705
+
7706
+ var isArray = isArray$5;
7707
+ var isConstructor$1 = isConstructor$3;
7708
+ var isObject$1 = isObject$h;
7709
+ var wellKnownSymbol$2 = wellKnownSymbol$o;
7710
+
7711
+ var SPECIES = wellKnownSymbol$2('species');
7712
+ var $Array$1 = Array;
7713
+
7714
+ // a part of `ArraySpeciesCreate` abstract operation
7715
+ // https://tc39.es/ecma262/#sec-arrayspeciescreate
7716
+ var arraySpeciesConstructor$1 = function (originalArray) {
7717
+ var C;
7718
+ if (isArray(originalArray)) {
7719
+ C = originalArray.constructor;
7720
+ // cross-realm fallback
7721
+ if (isConstructor$1(C) && (C === $Array$1 || isArray(C.prototype))) C = undefined;
7722
+ else if (isObject$1(C)) {
7723
+ C = C[SPECIES];
7724
+ if (C === null) C = undefined;
7725
+ }
7726
+ } return C === undefined ? $Array$1 : C;
7727
+ };
7728
+
7729
+ var arraySpeciesConstructor = arraySpeciesConstructor$1;
7730
+
7731
+ // `ArraySpeciesCreate` abstract operation
7732
+ // https://tc39.es/ecma262/#sec-arrayspeciescreate
7733
+ var arraySpeciesCreate$2 = function (originalArray, length) {
7734
+ return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
7735
+ };
7736
+
7737
+ var $$c = _export;
7738
+ var flattenIntoArray$1 = flattenIntoArray_1;
7739
+ var aCallable$2 = aCallable$k;
7740
+ var toObject$4 = toObject$c;
7741
+ var lengthOfArrayLike$4 = lengthOfArrayLike$c;
7742
+ var arraySpeciesCreate$1 = arraySpeciesCreate$2;
7743
+
7744
+ // `Array.prototype.flatMap` method
7745
+ // https://tc39.es/ecma262/#sec-array.prototype.flatmap
7746
+ $$c({ target: 'Array', proto: true }, {
7747
+ flatMap: function flatMap(callbackfn /* , thisArg */) {
7748
+ var O = toObject$4(this);
7749
+ var sourceLen = lengthOfArrayLike$4(O);
7750
+ var A;
7751
+ aCallable$2(callbackfn);
7752
+ A = arraySpeciesCreate$1(O, 0);
7753
+ A.length = flattenIntoArray$1(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
7754
+ return A;
7755
+ }
7756
+ });
7757
+
7758
+ // this method was added to unscopables after implementation
7759
+ // in popular engines, so it's moved to a separate module
7760
+ var addToUnscopables$1 = addToUnscopables$5;
7761
+
7762
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
7763
+ addToUnscopables$1('flatMap');
7764
+
7765
+ var call$6 = functionCall;
7766
+ var uncurryThis$b = functionUncurryThis;
7767
+ var fixRegExpWellKnownSymbolLogic$1 = fixRegexpWellKnownSymbolLogic;
7768
+ var anObject$4 = anObject$t;
7769
+ var isNullOrUndefined$1 = isNullOrUndefined$7;
7770
+ var requireObjectCoercible$4 = requireObjectCoercible$e;
7771
+ var speciesConstructor = speciesConstructor$2;
7772
+ var advanceStringIndex$1 = advanceStringIndex$3;
7773
+ var toLength$3 = toLength$7;
7774
+ var toString$a = toString$n;
7775
+ var getMethod$1 = getMethod$7;
7776
+ var regExpExec$1 = regexpExecAbstract;
7777
+ var stickyHelpers = regexpStickyHelpers;
7778
+ var fails$3 = fails$y;
7779
+
7780
+ var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
7781
+ var MAX_UINT32 = 0xFFFFFFFF;
7782
+ var min$1 = Math.min;
7783
+ var push$5 = uncurryThis$b([].push);
7784
+ var stringSlice$4 = uncurryThis$b(''.slice);
7785
+
7786
+ // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
7787
+ // Weex JS has frozen built-in prototypes, so use try / catch wrapper
7788
+ var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails$3(function () {
7789
+ // eslint-disable-next-line regexp/no-empty-group -- required for testing
7790
+ var re = /(?:)/;
7791
+ var originalExec = re.exec;
7792
+ re.exec = function () { return originalExec.apply(this, arguments); };
7793
+ var result = 'ab'.split(re);
7794
+ return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
7795
+ });
7796
+
7797
+ var BUGGY = 'abbc'.split(/(b)*/)[1] === 'c' ||
7798
+ // eslint-disable-next-line regexp/no-empty-group -- required for testing
7799
+ 'test'.split(/(?:)/, -1).length !== 4 ||
7800
+ 'ab'.split(/(?:ab)*/).length !== 2 ||
7801
+ '.'.split(/(.?)(.?)/).length !== 4 ||
7802
+ // eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing
7803
+ '.'.split(/()()/).length > 1 ||
7804
+ ''.split(/.?/).length;
7805
+
7806
+ // @@split logic
7807
+ fixRegExpWellKnownSymbolLogic$1('split', function (SPLIT, nativeSplit, maybeCallNative) {
7808
+ var internalSplit = '0'.split(undefined, 0).length ? function (separator, limit) {
7809
+ return separator === undefined && limit === 0 ? [] : call$6(nativeSplit, this, separator, limit);
7810
+ } : nativeSplit;
7811
+
7812
+ return [
7813
+ // `String.prototype.split` method
7814
+ // https://tc39.es/ecma262/#sec-string.prototype.split
7815
+ function split(separator, limit) {
7816
+ var O = requireObjectCoercible$4(this);
7817
+ var splitter = isNullOrUndefined$1(separator) ? undefined : getMethod$1(separator, SPLIT);
7818
+ return splitter
7819
+ ? call$6(splitter, separator, O, limit)
7820
+ : call$6(internalSplit, toString$a(O), separator, limit);
7821
+ },
7822
+ // `RegExp.prototype[@@split]` method
7823
+ // https://tc39.es/ecma262/#sec-regexp.prototype-@@split
7824
+ //
7825
+ // NOTE: This cannot be properly polyfilled in engines that don't support
7826
+ // the 'y' flag.
7827
+ function (string, limit) {
7828
+ var rx = anObject$4(this);
7829
+ var S = toString$a(string);
7830
+
7831
+ if (!BUGGY) {
7832
+ var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit);
7833
+ if (res.done) return res.value;
7834
+ }
7835
+
7836
+ var C = speciesConstructor(rx, RegExp);
7837
+ var unicodeMatching = rx.unicode;
7838
+ var flags = (rx.ignoreCase ? 'i' : '') +
7839
+ (rx.multiline ? 'm' : '') +
7840
+ (rx.unicode ? 'u' : '') +
7841
+ (UNSUPPORTED_Y ? 'g' : 'y');
7842
+ // ^(? + rx + ) is needed, in combination with some S slicing, to
7843
+ // simulate the 'y' flag.
7844
+ var splitter = new C(UNSUPPORTED_Y ? '^(?:' + rx.source + ')' : rx, flags);
7845
+ var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
7846
+ if (lim === 0) return [];
7847
+ if (S.length === 0) return regExpExec$1(splitter, S) === null ? [S] : [];
7848
+ var p = 0;
7849
+ var q = 0;
7850
+ var A = [];
7851
+ while (q < S.length) {
7852
+ splitter.lastIndex = UNSUPPORTED_Y ? 0 : q;
7853
+ var z = regExpExec$1(splitter, UNSUPPORTED_Y ? stringSlice$4(S, q) : S);
7854
+ var e;
7855
+ if (
7856
+ z === null ||
7857
+ (e = min$1(toLength$3(splitter.lastIndex + (UNSUPPORTED_Y ? q : 0)), S.length)) === p
7858
+ ) {
7859
+ q = advanceStringIndex$1(S, q, unicodeMatching);
7860
+ } else {
7861
+ push$5(A, stringSlice$4(S, p, q));
7862
+ if (A.length === lim) return A;
7863
+ for (var i = 1; i <= z.length - 1; i++) {
7864
+ push$5(A, z[i]);
7865
+ if (A.length === lim) return A;
7866
+ }
7867
+ q = p = e;
7868
+ }
7869
+ }
7870
+ push$5(A, stringSlice$4(S, p));
7871
+ return A;
7872
+ }
7873
+ ];
7874
+ }, BUGGY || !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
7875
+
7876
+ var call$5 = functionCall;
7877
+ var anObject$3 = anObject$t;
7878
+ var getIteratorDirect$1 = getIteratorDirect$a;
7879
+ var getIteratorMethod$2 = getIteratorMethod$5;
7880
+
7881
+ var getIteratorFlattenable$1 = function (obj, stringHandling) {
7882
+ if (!stringHandling || typeof obj !== 'string') anObject$3(obj);
7883
+ var method = getIteratorMethod$2(obj);
7884
+ return getIteratorDirect$1(anObject$3(method !== undefined ? call$5(method, obj) : obj));
7885
+ };
7886
+
7887
+ var $$b = _export;
7888
+ var call$4 = functionCall;
7889
+ var aCallable$1 = aCallable$k;
7890
+ var anObject$2 = anObject$t;
7891
+ var getIteratorDirect = getIteratorDirect$a;
7892
+ var getIteratorFlattenable = getIteratorFlattenable$1;
7893
+ var createIteratorProxy = iteratorCreateProxy;
7894
+ var iteratorClose = iteratorClose$6;
7895
+ var IS_PURE$1 = isPure;
7896
+
7897
+ var IteratorProxy = createIteratorProxy(function () {
7898
+ var iterator = this.iterator;
7899
+ var mapper = this.mapper;
7900
+ var result, inner;
7901
+
7902
+ while (true) {
7903
+ if (inner = this.inner) try {
7904
+ result = anObject$2(call$4(inner.next, inner.iterator));
7905
+ if (!result.done) return result.value;
7906
+ this.inner = null;
7907
+ } catch (error) { iteratorClose(iterator, 'throw', error); }
7908
+
7909
+ result = anObject$2(call$4(this.next, iterator));
7910
+
7911
+ if (this.done = !!result.done) return;
7912
+
7913
+ try {
7914
+ this.inner = getIteratorFlattenable(mapper(result.value, this.counter++), false);
7915
+ } catch (error) { iteratorClose(iterator, 'throw', error); }
7916
+ }
7917
+ });
7918
+
7919
+ // `Iterator.prototype.flatMap` method
7920
+ // https://github.com/tc39/proposal-iterator-helpers
7921
+ $$b({ target: 'Iterator', proto: true, real: true, forced: IS_PURE$1 }, {
7922
+ flatMap: function flatMap(mapper) {
7923
+ anObject$2(this);
7924
+ aCallable$1(mapper);
7925
+ return new IteratorProxy(getIteratorDirect(this), {
7926
+ mapper: mapper,
7927
+ inner: null
7928
+ });
7929
+ }
7930
+ });
7931
+
7932
+ const AUTO_POPULATE_SOURCES = ['firstName', 'lastName', 'email'];
7933
+ const getNameParts = user => {
7934
+ const parts = ((user == null ? void 0 : user.name) || '').trim().split(/\s+/).filter(Boolean);
7935
+ return {
7936
+ firstName: parts[0] || '',
7937
+ lastName: parts.length > 1 ? parts[parts.length - 1] : ''
7938
+ };
7939
+ };
7940
+ /**
7941
+ * @deprecated Field names no longer control auto-population. Use the
7942
+ * UI-schema `options.autoPopulate` directive.
7943
+ */
7944
+ const USER_FIELD_DEFINITIONS = {
7945
+ fullName: {
7946
+ schema: {
7947
+ type: 'string'
7948
+ },
7949
+ getValue: user => user == null ? void 0 : user.name
7950
+ },
7951
+ name: {
7952
+ schema: {
7953
+ type: 'string'
7954
+ },
7955
+ getValue: user => user == null ? void 0 : user.name
7956
+ },
7957
+ firstName: {
7958
+ schema: {
7959
+ type: 'string'
7960
+ },
7961
+ getValue: user => getNameParts(user).firstName
7962
+ },
7963
+ givenName: {
7964
+ schema: {
7965
+ type: 'string'
7966
+ },
7967
+ getValue: user => getNameParts(user).firstName
7968
+ },
7969
+ lastName: {
7970
+ schema: {
7971
+ type: 'string'
7972
+ },
7973
+ getValue: user => getNameParts(user).lastName
7974
+ },
7975
+ familyName: {
7976
+ schema: {
7977
+ type: 'string'
7978
+ },
7979
+ getValue: user => getNameParts(user).lastName
7980
+ },
7981
+ surname: {
7982
+ schema: {
7983
+ type: 'string'
7984
+ },
7985
+ getValue: user => getNameParts(user).lastName
7986
+ },
7987
+ email: {
7988
+ schema: {
7989
+ type: 'string',
7990
+ format: 'email'
7991
+ },
7992
+ getValue: user => (user == null ? void 0 : user.email) || ''
7993
+ },
7994
+ emailAddress: {
7995
+ schema: {
7996
+ type: 'string',
7997
+ format: 'email'
7998
+ },
7999
+ getValue: user => (user == null ? void 0 : user.email) || ''
8000
+ },
8001
+ primaryEmail: {
8002
+ schema: {
8003
+ type: 'string',
8004
+ format: 'email'
8005
+ },
8006
+ getValue: user => (user == null ? void 0 : user.email) || ''
8007
+ }
8008
+ };
8009
+ const AUTO_POPULATE_ACTION_TYPES = new Set([INIT, UPDATE_CORE]);
8010
+ const isEmptyAutoPopulateTarget = value => value === undefined || value === null || value === '';
8011
+ const shouldAutoPopulate = actionType => AUTO_POPULATE_ACTION_TYPES.has(actionType);
8012
+ const isAutoPopulateSource = value => typeof value === 'string' && AUTO_POPULATE_SOURCES.includes(value);
8013
+ const autoPopulateValue = (user, props) => {
8014
+ var _props$uischema;
8015
+ const source = (_props$uischema = props.uischema) == null || (_props$uischema = _props$uischema.options) == null ? void 0 : _props$uischema.autoPopulate;
8016
+ if (!isAutoPopulateSource(source)) {
8017
+ return undefined;
8018
+ }
8019
+ const name = getNameParts(user);
8020
+ const values = {
8021
+ firstName: name.firstName,
8022
+ lastName: name.lastName,
8023
+ email: (user == null ? void 0 : user.email) || ''
8024
+ };
8025
+ return values[source];
8026
+ };
8027
+ const getAutoPopulateControls = element => {
8028
+ var _element$options, _element$elements;
8029
+ if (!element) {
8030
+ return [];
8031
+ }
8032
+ const controls = element.type === 'Control' && (_element$options = element.options) != null && _element$options.autoPopulate ? [element] : [];
8033
+ const children = (_element$elements = element.elements) != null ? _element$elements : [];
8034
+ return [...controls, ...children.flatMap(getAutoPopulateControls)];
8035
+ };
8036
+ const getAutoPopulatedData = (uischema, user) => {
8037
+ if (!user) {
8038
+ return [];
8039
+ }
8040
+ return getAutoPopulateControls(uischema).map(control => ({
8041
+ path: toDataPath(control.scope),
8042
+ value: autoPopulateValue(user, {
8043
+ uischema: control
8044
+ })
8045
+ })).filter(({
8046
+ path,
8047
+ value
8048
+ }) => Boolean(path) && value !== undefined && value !== null);
8049
+ };
8050
+ const mergeAutoPopulatedData = (data, autoPopulatedData) => {
8051
+ if (autoPopulatedData.length === 0) {
8052
+ return data;
8053
+ }
8054
+ const defaults = autoPopulatedData.reduce((values, {
8055
+ path,
8056
+ value
8057
+ }) => _$c.set(values, path, value), {});
8058
+ const normalizedData = _$c.cloneDeep(data != null ? data : {});
8059
+ autoPopulatedData.forEach(({
8060
+ path,
8061
+ value
8062
+ }) => {
8063
+ if (isEmptyAutoPopulateTarget(_$c.get(normalizedData, path)) && value !== undefined && value !== null) {
8064
+ _$c.unset(normalizedData, path);
8065
+ }
8066
+ });
8067
+ return _$c.defaultsDeep({}, normalizedData, defaults);
8068
+ };
8069
+ const createAutoPopulateMiddleware = (uischema, user) => (state, action, defaultReducer) => {
8070
+ const newState = defaultReducer(state, action);
8071
+ if (!shouldAutoPopulate(action.type)) {
8072
+ return newState;
8073
+ }
8074
+ return Object.assign({}, newState, {
8075
+ data: mergeAutoPopulatedData(newState.data, getAutoPopulatedData(uischema, user))
8076
+ });
8077
+ };
8078
+ /**
8079
+ * Retained for compatibility with consumers of the previous data-schema
8080
+ * autocomplete API. Auto-population is now configured in the UI schema.
8081
+ */
8082
+ const autoPopulatePropertiesMonaco = [];
8083
+
7683
8084
  const createStepperContextInitData = props => {
7684
8085
  var _uischema$options, _uischema$options2, _categorization$eleme;
7685
8086
  const {
@@ -7702,9 +8103,12 @@ const createStepperContextInitData = props => {
7702
8103
  const categories = (_categorization$eleme = categorization.elements) == null ? void 0 : _categorization$eleme.map((c, id) => {
7703
8104
  var _deriveLabelForUISche;
7704
8105
  const scopes = pickPropertyValues(c, 'scope', 'ListWithDetail');
7705
- // Treat a step as visited when its scoped fields already contain data so
7706
- // that getStepStatus returns the real data-driven status on initial mount initially.
7707
- let visited = scopes.some(scope => hasValueAtScope(data, scope));
8106
+ // A step is not visited on initial mount, so its status is driven by whether it already holds
8107
+ // user-entered data. Auto-populated fields (system-filled from the user profile) are excluded
8108
+ // so an unopened page with only auto-populated values stays NotStarted, while a resumed form
8109
+ // the user actually filled still shows its saved status.
8110
+ let visited = false;
8111
+ const autoPopulatedScopes = getAutoPopulateControls(c).map(control => control.scope);
7708
8112
  const {
7709
8113
  status,
7710
8114
  hasRequiredFields
@@ -7713,7 +8117,8 @@ const createStepperContextInitData = props => {
7713
8117
  data,
7714
8118
  errors: filteredErrors != null ? filteredErrors : [],
7715
8119
  schema,
7716
- visited
8120
+ visited,
8121
+ autoPopulatedScopes
7717
8122
  });
7718
8123
  //If the step has all conditional fields, set visited to true so that the step status will be
7719
8124
  //completed to enable form to be saved.
@@ -8056,14 +8461,14 @@ const GoAInputBaseControl = props => {
8056
8461
  });
8057
8462
  };
8058
8463
 
8059
- var $$c = _export;
8464
+ var $$a = _export;
8060
8465
  var DESCRIPTORS$4 = descriptors;
8061
8466
  var global$4 = global$t;
8062
- var uncurryThis$b = functionUncurryThis;
8467
+ var uncurryThis$a = functionUncurryThis;
8063
8468
  var hasOwn$2 = hasOwnProperty_1;
8064
8469
  var isCallable$1 = isCallable$t;
8065
8470
  var isPrototypeOf = objectIsPrototypeOf;
8066
- var toString$a = toString$n;
8471
+ var toString$9 = toString$n;
8067
8472
  var defineBuiltInAccessor$3 = defineBuiltInAccessor$7;
8068
8473
  var copyConstructorProperties = copyConstructorProperties$3;
8069
8474
 
@@ -8077,7 +8482,7 @@ if (DESCRIPTORS$4 && isCallable$1(NativeSymbol) && (!('description' in SymbolPro
8077
8482
  var EmptyStringDescriptionStore = {};
8078
8483
  // wrap Symbol constructor for correct work with undefined description
8079
8484
  var SymbolWrapper = function Symbol() {
8080
- var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString$a(arguments[0]);
8485
+ var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString$9(arguments[0]);
8081
8486
  var result = isPrototypeOf(SymbolPrototype, this)
8082
8487
  ? new NativeSymbol(description)
8083
8488
  // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
@@ -8091,11 +8496,11 @@ if (DESCRIPTORS$4 && isCallable$1(NativeSymbol) && (!('description' in SymbolPro
8091
8496
  SymbolPrototype.constructor = SymbolWrapper;
8092
8497
 
8093
8498
  var NATIVE_SYMBOL = String(NativeSymbol('description detection')) === 'Symbol(description detection)';
8094
- var thisSymbolValue = uncurryThis$b(SymbolPrototype.valueOf);
8095
- var symbolDescriptiveString = uncurryThis$b(SymbolPrototype.toString);
8499
+ var thisSymbolValue = uncurryThis$a(SymbolPrototype.valueOf);
8500
+ var symbolDescriptiveString = uncurryThis$a(SymbolPrototype.toString);
8096
8501
  var regexp = /^Symbol\((.*)\)[^)]+$/;
8097
- var replace$3 = uncurryThis$b(''.replace);
8098
- var stringSlice$4 = uncurryThis$b(''.slice);
8502
+ var replace$3 = uncurryThis$a(''.replace);
8503
+ var stringSlice$3 = uncurryThis$a(''.slice);
8099
8504
 
8100
8505
  defineBuiltInAccessor$3(SymbolPrototype, 'description', {
8101
8506
  configurable: true,
@@ -8103,57 +8508,57 @@ if (DESCRIPTORS$4 && isCallable$1(NativeSymbol) && (!('description' in SymbolPro
8103
8508
  var symbol = thisSymbolValue(this);
8104
8509
  if (hasOwn$2(EmptyStringDescriptionStore, symbol)) return '';
8105
8510
  var string = symbolDescriptiveString(symbol);
8106
- var desc = NATIVE_SYMBOL ? stringSlice$4(string, 7, -1) : replace$3(string, regexp, '$1');
8511
+ var desc = NATIVE_SYMBOL ? stringSlice$3(string, 7, -1) : replace$3(string, regexp, '$1');
8107
8512
  return desc === '' ? undefined : desc;
8108
8513
  }
8109
8514
  });
8110
8515
 
8111
- $$c({ global: true, constructor: true, forced: true }, {
8516
+ $$a({ global: true, constructor: true, forced: true }, {
8112
8517
  Symbol: SymbolWrapper
8113
8518
  });
8114
8519
  }
8115
8520
 
8116
- var call$6 = functionCall;
8117
- var fixRegExpWellKnownSymbolLogic$1 = fixRegexpWellKnownSymbolLogic;
8118
- var anObject$4 = anObject$t;
8119
- var isNullOrUndefined$1 = isNullOrUndefined$7;
8120
- var toLength$3 = toLength$7;
8121
- var toString$9 = toString$n;
8122
- var requireObjectCoercible$4 = requireObjectCoercible$e;
8123
- var getMethod$1 = getMethod$7;
8124
- var advanceStringIndex$1 = advanceStringIndex$3;
8125
- var regExpExec$1 = regexpExecAbstract;
8521
+ var call$3 = functionCall;
8522
+ var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
8523
+ var anObject$1 = anObject$t;
8524
+ var isNullOrUndefined = isNullOrUndefined$7;
8525
+ var toLength$2 = toLength$7;
8526
+ var toString$8 = toString$n;
8527
+ var requireObjectCoercible$3 = requireObjectCoercible$e;
8528
+ var getMethod = getMethod$7;
8529
+ var advanceStringIndex = advanceStringIndex$3;
8530
+ var regExpExec = regexpExecAbstract;
8126
8531
 
8127
8532
  // @@match logic
8128
- fixRegExpWellKnownSymbolLogic$1('match', function (MATCH, nativeMatch, maybeCallNative) {
8533
+ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) {
8129
8534
  return [
8130
8535
  // `String.prototype.match` method
8131
8536
  // https://tc39.es/ecma262/#sec-string.prototype.match
8132
8537
  function match(regexp) {
8133
- var O = requireObjectCoercible$4(this);
8134
- var matcher = isNullOrUndefined$1(regexp) ? undefined : getMethod$1(regexp, MATCH);
8135
- return matcher ? call$6(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString$9(O));
8538
+ var O = requireObjectCoercible$3(this);
8539
+ var matcher = isNullOrUndefined(regexp) ? undefined : getMethod(regexp, MATCH);
8540
+ return matcher ? call$3(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString$8(O));
8136
8541
  },
8137
8542
  // `RegExp.prototype[@@match]` method
8138
8543
  // https://tc39.es/ecma262/#sec-regexp.prototype-@@match
8139
8544
  function (string) {
8140
- var rx = anObject$4(this);
8141
- var S = toString$9(string);
8545
+ var rx = anObject$1(this);
8546
+ var S = toString$8(string);
8142
8547
  var res = maybeCallNative(nativeMatch, rx, S);
8143
8548
 
8144
8549
  if (res.done) return res.value;
8145
8550
 
8146
- if (!rx.global) return regExpExec$1(rx, S);
8551
+ if (!rx.global) return regExpExec(rx, S);
8147
8552
 
8148
8553
  var fullUnicode = rx.unicode;
8149
8554
  rx.lastIndex = 0;
8150
8555
  var A = [];
8151
8556
  var n = 0;
8152
8557
  var result;
8153
- while ((result = regExpExec$1(rx, S)) !== null) {
8154
- var matchStr = toString$9(result[0]);
8558
+ while ((result = regExpExec(rx, S)) !== null) {
8559
+ var matchStr = toString$8(result[0]);
8155
8560
  A[n] = matchStr;
8156
- if (matchStr === '') rx.lastIndex = advanceStringIndex$1(S, toLength$3(rx.lastIndex), fullUnicode);
8561
+ if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength$2(rx.lastIndex), fullUnicode);
8157
8562
  n++;
8158
8563
  }
8159
8564
  return n === 0 ? null : A;
@@ -8489,15 +8894,15 @@ function _objectWithoutPropertiesLoose(r, e) {
8489
8894
  }
8490
8895
 
8491
8896
  var toIntegerOrInfinity$1 = toIntegerOrInfinity$9;
8492
- var toString$8 = toString$n;
8493
- var requireObjectCoercible$3 = requireObjectCoercible$e;
8897
+ var toString$7 = toString$n;
8898
+ var requireObjectCoercible$2 = requireObjectCoercible$e;
8494
8899
 
8495
8900
  var $RangeError$1 = RangeError;
8496
8901
 
8497
8902
  // `String.prototype.repeat` method implementation
8498
8903
  // https://tc39.es/ecma262/#sec-string.prototype.repeat
8499
8904
  var stringRepeat = function repeat(count) {
8500
- var str = toString$8(requireObjectCoercible$3(this));
8905
+ var str = toString$7(requireObjectCoercible$2(this));
8501
8906
  var result = '';
8502
8907
  var n = toIntegerOrInfinity$1(count);
8503
8908
  if (n < 0 || n === Infinity) throw new $RangeError$1('Wrong number of repetitions');
@@ -8506,28 +8911,28 @@ var stringRepeat = function repeat(count) {
8506
8911
  };
8507
8912
 
8508
8913
  // https://github.com/tc39/proposal-string-pad-start-end
8509
- var uncurryThis$a = functionUncurryThis;
8510
- var toLength$2 = toLength$7;
8511
- var toString$7 = toString$n;
8914
+ var uncurryThis$9 = functionUncurryThis;
8915
+ var toLength$1 = toLength$7;
8916
+ var toString$6 = toString$n;
8512
8917
  var $repeat = stringRepeat;
8513
- var requireObjectCoercible$2 = requireObjectCoercible$e;
8918
+ var requireObjectCoercible$1 = requireObjectCoercible$e;
8514
8919
 
8515
- var repeat = uncurryThis$a($repeat);
8516
- var stringSlice$3 = uncurryThis$a(''.slice);
8920
+ var repeat = uncurryThis$9($repeat);
8921
+ var stringSlice$2 = uncurryThis$9(''.slice);
8517
8922
  var ceil = Math.ceil;
8518
8923
 
8519
8924
  // `String.prototype.{ padStart, padEnd }` methods implementation
8520
8925
  var createMethod = function (IS_END) {
8521
8926
  return function ($this, maxLength, fillString) {
8522
- var S = toString$7(requireObjectCoercible$2($this));
8523
- var intMaxLength = toLength$2(maxLength);
8927
+ var S = toString$6(requireObjectCoercible$1($this));
8928
+ var intMaxLength = toLength$1(maxLength);
8524
8929
  var stringLength = S.length;
8525
- var fillStr = fillString === undefined ? ' ' : toString$7(fillString);
8930
+ var fillStr = fillString === undefined ? ' ' : toString$6(fillString);
8526
8931
  var fillLen, stringFiller;
8527
8932
  if (intMaxLength <= stringLength || fillStr === '') return S;
8528
8933
  fillLen = intMaxLength - stringLength;
8529
8934
  stringFiller = repeat(fillStr, ceil(fillLen / fillStr.length));
8530
- if (stringFiller.length > fillLen) stringFiller = stringSlice$3(stringFiller, 0, fillLen);
8935
+ if (stringFiller.length > fillLen) stringFiller = stringSlice$2(stringFiller, 0, fillLen);
8531
8936
  return IS_END ? S + stringFiller : stringFiller + S;
8532
8937
  };
8533
8938
  };
@@ -8542,13 +8947,13 @@ var userAgent$2 = engineUserAgent;
8542
8947
 
8543
8948
  var stringPadWebkitBug = /Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent$2);
8544
8949
 
8545
- var $$b = _export;
8950
+ var $$9 = _export;
8546
8951
  var $padStart = stringPad.start;
8547
8952
  var WEBKIT_BUG = stringPadWebkitBug;
8548
8953
 
8549
8954
  // `String.prototype.padStart` method
8550
8955
  // https://tc39.es/ecma262/#sec-string.prototype.padstart
8551
- $$b({ target: 'String', proto: true, forced: WEBKIT_BUG }, {
8956
+ $$9({ target: 'String', proto: true, forced: WEBKIT_BUG }, {
8552
8957
  padStart: function padStart(maxLength /* , fillString = ' ' */) {
8553
8958
  return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
8554
8959
  }
@@ -9194,7 +9599,6 @@ const RadioGroup = props => {
9194
9599
  uischema,
9195
9600
  path,
9196
9601
  handleChange,
9197
- options,
9198
9602
  config,
9199
9603
  label,
9200
9604
  isVisited,
@@ -9211,8 +9615,12 @@ const RadioGroup = props => {
9211
9615
  value: String(value),
9212
9616
  label: String(value)
9213
9617
  }));
9214
- const appliedUiSchemaOptions = merge({}, config, props.uischema.options, options);
9215
- return jsx(GoabRadioGroup, Object.assign({
9618
+ // Merge only UI-schema level options (config + uischema.options). The enum data
9619
+ // `options` array must NOT be merged here: lodash.merge folds its indices in as
9620
+ // numeric keys (0, 1, 2, ...), which then get spread onto <goa-radio-group> below
9621
+ // and trigger React's "Invalid attribute name: `3`" warning (CS ticket).
9622
+ const appliedUiSchemaOptions = merge({}, config, props.uischema.options);
9623
+ return jsx(GoabRadioGroup$1, Object.assign({
9216
9624
  error: isVisited && errors.length > 0,
9217
9625
  name: `${path || appliedUiSchemaOptions.label}`,
9218
9626
  testId: `${path || id || label}-radio-group`,
@@ -9221,7 +9629,7 @@ const RadioGroup = props => {
9221
9629
  }, appliedUiSchemaOptions, {
9222
9630
  onChange: detail => handleChange(path, detail.value)
9223
9631
  }, uischema == null || (_uischema$options = uischema.options) == null ? void 0 : _uischema$options.componentProps, {
9224
- children: items.map((item, index) => jsx(GoabRadioItem, {
9632
+ children: items.map((item, index) => jsx(GoabRadioItem$1, {
9225
9633
  name: item.value,
9226
9634
  value: item.value,
9227
9635
  label: item.label
@@ -9400,13 +9808,15 @@ const CheckboxGroup = props => {
9400
9808
  uischema,
9401
9809
  path,
9402
9810
  handleChange,
9403
- options,
9404
9811
  config,
9405
9812
  label,
9406
9813
  enabled
9407
9814
  } = props;
9408
9815
  const enumOptions = getEnumOptions(schema);
9409
- const appliedUiSchemaOptions = merge({}, config, props.uischema.options, options);
9816
+ // Merge only UI-schema level options. The enum data `options` array must NOT be merged
9817
+ // here: lodash.merge folds its indices in as numeric keys (0, 1, 2, ...) that then get
9818
+ // spread onto <goa-checkbox> below and trigger React's "Invalid attribute name" warning.
9819
+ const appliedUiSchemaOptions = merge({}, config, props.uischema.options);
9410
9820
  return jsx(Checkboxes, {
9411
9821
  orientation: (_uischema$options = uischema.options) != null && _uischema$options.orientation ? (_uischema$options2 = uischema.options) == null ? void 0 : _uischema$options2.orientation : 'vertical',
9412
9822
  testId: `${label || id}-jsonforms-checkboxes`,
@@ -9512,130 +9922,37 @@ const GoABaseInputReviewComponent = props => {
9512
9922
  }
9513
9923
  }
9514
9924
  if (isTime) {
9515
- reviewText = reviewText && to12HourFormat(reviewText);
9516
- }
9517
- if (isDateTime) {
9518
- reviewText = reviewText && UTCToFullLocalTime(reviewText);
9519
- }
9520
- if (Array.isArray(data) && data.length > 0) {
9521
- reviewText = jsx("ul", {
9522
- children: data.map((checkbox, index) => {
9523
- const checkboxLabel = getFallbackCheckboxLabel();
9524
- return jsx("li", {
9525
- children: checkbox.trim() || checkboxLabel
9526
- }, index);
9527
- })
9528
- });
9529
- }
9530
- return jsxs("div", {
9531
- style: {
9532
- fontWeight: '400',
9533
- textWrap: 'wrap',
9534
- wordBreak: 'break-word'
9535
- },
9536
- "data-testid": `review-control-${id}`,
9537
- children: [reviewText, renderRequiredLabel(), renderWarningMessage()]
9538
- });
9539
- };
9540
- const GoInputBaseReview = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
9541
- input: GoABaseInputReviewComponent,
9542
- isStepperReview: true,
9543
- skipInitialValidation: true
9544
- }));
9545
- const GoAInputBaseReviewControl = withJsonFormsControlProps(GoInputBaseReview);
9546
-
9547
- var isArray$1 = isArray$5;
9548
- var lengthOfArrayLike$5 = lengthOfArrayLike$c;
9549
- var doesNotExceedSafeInteger$1 = doesNotExceedSafeInteger$3;
9550
- var bind$3 = functionBindContext;
9551
-
9552
- // `FlattenIntoArray` abstract operation
9553
- // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
9554
- var flattenIntoArray$2 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
9555
- var targetIndex = start;
9556
- var sourceIndex = 0;
9557
- var mapFn = mapper ? bind$3(mapper, thisArg) : false;
9558
- var element, elementLen;
9559
-
9560
- while (sourceIndex < sourceLen) {
9561
- if (sourceIndex in source) {
9562
- element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
9563
-
9564
- if (depth > 0 && isArray$1(element)) {
9565
- elementLen = lengthOfArrayLike$5(element);
9566
- targetIndex = flattenIntoArray$2(target, original, element, elementLen, targetIndex, depth - 1) - 1;
9567
- } else {
9568
- doesNotExceedSafeInteger$1(targetIndex + 1);
9569
- target[targetIndex] = element;
9570
- }
9571
-
9572
- targetIndex++;
9573
- }
9574
- sourceIndex++;
9575
- }
9576
- return targetIndex;
9577
- };
9578
-
9579
- var flattenIntoArray_1 = flattenIntoArray$2;
9580
-
9581
- var isArray = isArray$5;
9582
- var isConstructor$1 = isConstructor$3;
9583
- var isObject$1 = isObject$h;
9584
- var wellKnownSymbol$2 = wellKnownSymbol$o;
9585
-
9586
- var SPECIES = wellKnownSymbol$2('species');
9587
- var $Array$1 = Array;
9588
-
9589
- // a part of `ArraySpeciesCreate` abstract operation
9590
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
9591
- var arraySpeciesConstructor$1 = function (originalArray) {
9592
- var C;
9593
- if (isArray(originalArray)) {
9594
- C = originalArray.constructor;
9595
- // cross-realm fallback
9596
- if (isConstructor$1(C) && (C === $Array$1 || isArray(C.prototype))) C = undefined;
9597
- else if (isObject$1(C)) {
9598
- C = C[SPECIES];
9599
- if (C === null) C = undefined;
9600
- }
9601
- } return C === undefined ? $Array$1 : C;
9602
- };
9603
-
9604
- var arraySpeciesConstructor = arraySpeciesConstructor$1;
9605
-
9606
- // `ArraySpeciesCreate` abstract operation
9607
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
9608
- var arraySpeciesCreate$2 = function (originalArray, length) {
9609
- return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
9610
- };
9611
-
9612
- var $$a = _export;
9613
- var flattenIntoArray$1 = flattenIntoArray_1;
9614
- var aCallable$2 = aCallable$k;
9615
- var toObject$4 = toObject$c;
9616
- var lengthOfArrayLike$4 = lengthOfArrayLike$c;
9617
- var arraySpeciesCreate$1 = arraySpeciesCreate$2;
9618
-
9619
- // `Array.prototype.flatMap` method
9620
- // https://tc39.es/ecma262/#sec-array.prototype.flatmap
9621
- $$a({ target: 'Array', proto: true }, {
9622
- flatMap: function flatMap(callbackfn /* , thisArg */) {
9623
- var O = toObject$4(this);
9624
- var sourceLen = lengthOfArrayLike$4(O);
9625
- var A;
9626
- aCallable$2(callbackfn);
9627
- A = arraySpeciesCreate$1(O, 0);
9628
- A.length = flattenIntoArray$1(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
9629
- return A;
9925
+ reviewText = reviewText && to12HourFormat(reviewText);
9630
9926
  }
9631
- });
9632
-
9633
- // this method was added to unscopables after implementation
9634
- // in popular engines, so it's moved to a separate module
9635
- var addToUnscopables$1 = addToUnscopables$5;
9636
-
9637
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
9638
- addToUnscopables$1('flatMap');
9927
+ if (isDateTime) {
9928
+ reviewText = reviewText && UTCToFullLocalTime(reviewText);
9929
+ }
9930
+ if (Array.isArray(data) && data.length > 0) {
9931
+ reviewText = jsx("ul", {
9932
+ children: data.map((checkbox, index) => {
9933
+ const checkboxLabel = getFallbackCheckboxLabel();
9934
+ return jsx("li", {
9935
+ children: checkbox.trim() || checkboxLabel
9936
+ }, index);
9937
+ })
9938
+ });
9939
+ }
9940
+ return jsxs("div", {
9941
+ style: {
9942
+ fontWeight: '400',
9943
+ textWrap: 'wrap',
9944
+ wordBreak: 'break-word'
9945
+ },
9946
+ "data-testid": `review-control-${id}`,
9947
+ children: [reviewText, renderRequiredLabel(), renderWarningMessage()]
9948
+ });
9949
+ };
9950
+ const GoInputBaseReview = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
9951
+ input: GoABaseInputReviewComponent,
9952
+ isStepperReview: true,
9953
+ skipInitialValidation: true
9954
+ }));
9955
+ const GoAInputBaseReviewControl = withJsonFormsControlProps(GoInputBaseReview);
9639
9956
 
9640
9957
  var tryToString = tryToString$5;
9641
9958
 
@@ -9645,7 +9962,7 @@ var deletePropertyOrThrow$2 = function (O, P) {
9645
9962
  if (!delete O[P]) throw new $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O));
9646
9963
  };
9647
9964
 
9648
- var $$9 = _export;
9965
+ var $$8 = _export;
9649
9966
  var toObject$3 = toObject$c;
9650
9967
  var lengthOfArrayLike$3 = lengthOfArrayLike$c;
9651
9968
  var setArrayLength = arraySetLength;
@@ -9669,7 +9986,7 @@ var FORCED$2 = INCORRECT_RESULT || !properErrorOnNonWritableLength();
9669
9986
 
9670
9987
  // `Array.prototype.unshift` method
9671
9988
  // https://tc39.es/ecma262/#sec-array.prototype.unshift
9672
- $$9({ target: 'Array', proto: true, arity: 1, forced: FORCED$2 }, {
9989
+ $$8({ target: 'Array', proto: true, arity: 1, forced: FORCED$2 }, {
9673
9990
  // eslint-disable-next-line no-unused-vars -- required for `.length`
9674
9991
  unshift: function unshift(item) {
9675
9992
  var O = toObject$3(this);
@@ -9690,62 +10007,6 @@ $$9({ target: 'Array', proto: true, arity: 1, forced: FORCED$2 }, {
9690
10007
  }
9691
10008
  });
9692
10009
 
9693
- var call$5 = functionCall;
9694
- var anObject$3 = anObject$t;
9695
- var getIteratorDirect$1 = getIteratorDirect$a;
9696
- var getIteratorMethod$2 = getIteratorMethod$5;
9697
-
9698
- var getIteratorFlattenable$1 = function (obj, stringHandling) {
9699
- if (!stringHandling || typeof obj !== 'string') anObject$3(obj);
9700
- var method = getIteratorMethod$2(obj);
9701
- return getIteratorDirect$1(anObject$3(method !== undefined ? call$5(method, obj) : obj));
9702
- };
9703
-
9704
- var $$8 = _export;
9705
- var call$4 = functionCall;
9706
- var aCallable$1 = aCallable$k;
9707
- var anObject$2 = anObject$t;
9708
- var getIteratorDirect = getIteratorDirect$a;
9709
- var getIteratorFlattenable = getIteratorFlattenable$1;
9710
- var createIteratorProxy = iteratorCreateProxy;
9711
- var iteratorClose = iteratorClose$6;
9712
- var IS_PURE$1 = isPure;
9713
-
9714
- var IteratorProxy = createIteratorProxy(function () {
9715
- var iterator = this.iterator;
9716
- var mapper = this.mapper;
9717
- var result, inner;
9718
-
9719
- while (true) {
9720
- if (inner = this.inner) try {
9721
- result = anObject$2(call$4(inner.next, inner.iterator));
9722
- if (!result.done) return result.value;
9723
- this.inner = null;
9724
- } catch (error) { iteratorClose(iterator, 'throw', error); }
9725
-
9726
- result = anObject$2(call$4(this.next, iterator));
9727
-
9728
- if (this.done = !!result.done) return;
9729
-
9730
- try {
9731
- this.inner = getIteratorFlattenable(mapper(result.value, this.counter++), false);
9732
- } catch (error) { iteratorClose(iterator, 'throw', error); }
9733
- }
9734
- });
9735
-
9736
- // `Iterator.prototype.flatMap` method
9737
- // https://github.com/tc39/proposal-iterator-helpers
9738
- $$8({ target: 'Iterator', proto: true, real: true, forced: IS_PURE$1 }, {
9739
- flatMap: function flatMap(mapper) {
9740
- anObject$2(this);
9741
- aCallable$1(mapper);
9742
- return new IteratorProxy(getIteratorDirect(this), {
9743
- mapper: mapper,
9744
- inner: null
9745
- });
9746
- }
9747
- });
9748
-
9749
10010
  let _$8 = t => t,
9750
10011
  _t$9,
9751
10012
  _t2$4,
@@ -11377,181 +11638,70 @@ const GoAInputBaseTableReview = props => {
11377
11638
  if (required && isNilOrEmptyValue(data, true)) {
11378
11639
  // clean-code-ignore: 2.18
11379
11640
  activeError = `${labelToUpdate} is required`;
11380
- }
11381
- const isRegisterBackedEnumFalsePositive = (uischema == null || (_uischema$options4 = uischema.options) == null ? void 0 : _uischema$options4.register) !== undefined && !isNilOrEmptyValue(data, true) && typeof activeError === 'string' && activeError.toLowerCase().includes('must be equal to one of the allowed values');
11382
- if (isRegisterBackedEnumFalsePositive) {
11383
- activeError = undefined;
11384
- }
11385
- if (activeError && /\sis required$/i.test(activeError)) {
11386
- activeError = `${labelToUpdate} is required`;
11387
- }
11388
- // For required boolean fields (e.g. anyOf: [{enum: [true]}]), suppress the raw AJV
11389
- // "must be equal to one of the allowed values" error and show a friendly message instead.
11390
- if ((schema == null ? void 0 : schema.type) === 'boolean' && activeError && activeError.toLowerCase().includes('must be equal')) {
11391
- activeError = data === false ? `${labelToUpdate} is required` : undefined;
11392
- }
11393
- // If a required checkbox is unchecked, show only the validation message in
11394
- // review mode (not a contradictory "No (...)" value line).
11395
- let isBooleanRequiredError = false;
11396
- if ((schema == null ? void 0 : schema.type) === 'boolean' && data === false && activeError && /\sis required$/i.test(activeError)) {
11397
- reviewText = '';
11398
- isBooleanRequiredError = true;
11399
- }
11400
- // eslint-disable-next-line
11401
- const stepId = (_uischema$options5 = uischema.options) == null ? void 0 : _uischema$options5.stepId;
11402
- function handleChangeClick() {
11403
- context == null || context.goToPage(stepId, uischema.scope);
11404
- reviewCtx == null || reviewCtx.onChangeDispatch(stepId, uischema.scope);
11405
- }
11406
- const showInlineValue = reviewText === null || reviewText === undefined || typeof reviewText === 'string' || typeof reviewText === 'number' || /*#__PURE__*/React.isValidElement(reviewText) || Array.isArray(reviewText) && reviewText.length === 0;
11407
- const isValueEmpty = !isBooleanRequiredError && (reviewText === null || reviewText === undefined || reviewText === '' || Array.isArray(reviewText) && reviewText.length === 0);
11408
- return jsx("tr", {
11409
- "data-testid": `input-base-table-${label}-row`,
11410
- children: jsxs(PageReviewContainer, {
11411
- colSpan: 3,
11412
- children: [jsxs(ReviewHeader, {
11413
- children: [jsxs(ReviewLabel, {
11414
- children: [labelToUpdate, required && jsx(RequiredTextLabel, {
11415
- children: " (required)"
11416
- })]
11417
- }), stepId !== undefined && !((_uischema$options6 = uischema.options) != null && (_uischema$options6 = _uischema$options6.componentProps) != null && _uischema$options6.readOnly) && jsx(GoabButton, {
11418
- type: "tertiary",
11419
- onClick: handleChangeClick,
11420
- children: "Change"
11421
- })]
11422
- }), jsxs(ReviewValue, {
11423
- children: [showInlineValue ? jsx("div", {
11424
- "data-testid": `review-value-${label}`,
11425
- children: isValueEmpty ? jsx(NoneGivenText, {
11426
- children: "(none given)"
11427
- }) : reviewText != null ? reviewText : ''
11428
- }) : jsx(JsonFormsDispatch, {
11429
- "data-testid": `jsonforms-object-list-defined-elements-dispatch`,
11430
- schema: schema,
11431
- uischema: uischema,
11432
- enabled: enabled,
11433
- renderers: jsonForms.renderers,
11434
- cells: cells
11435
- }), activeError && jsx(GoabFormItem, {
11436
- error: activeError,
11437
- label: ""
11438
- })]
11439
- })]
11440
- })
11441
- });
11442
- };
11443
- const GoAInputBaseTableReviewControl = withJsonFormsControlProps(GoAInputBaseTableReview);
11444
-
11445
- var call$3 = functionCall;
11446
- var uncurryThis$9 = functionUncurryThis;
11447
- var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
11448
- var anObject$1 = anObject$t;
11449
- var isNullOrUndefined = isNullOrUndefined$7;
11450
- var requireObjectCoercible$1 = requireObjectCoercible$e;
11451
- var speciesConstructor = speciesConstructor$2;
11452
- var advanceStringIndex = advanceStringIndex$3;
11453
- var toLength$1 = toLength$7;
11454
- var toString$6 = toString$n;
11455
- var getMethod = getMethod$7;
11456
- var regExpExec = regexpExecAbstract;
11457
- var stickyHelpers = regexpStickyHelpers;
11458
- var fails$3 = fails$y;
11459
-
11460
- var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
11461
- var MAX_UINT32 = 0xFFFFFFFF;
11462
- var min$1 = Math.min;
11463
- var push$5 = uncurryThis$9([].push);
11464
- var stringSlice$2 = uncurryThis$9(''.slice);
11465
-
11466
- // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
11467
- // Weex JS has frozen built-in prototypes, so use try / catch wrapper
11468
- var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails$3(function () {
11469
- // eslint-disable-next-line regexp/no-empty-group -- required for testing
11470
- var re = /(?:)/;
11471
- var originalExec = re.exec;
11472
- re.exec = function () { return originalExec.apply(this, arguments); };
11473
- var result = 'ab'.split(re);
11474
- return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
11475
- });
11476
-
11477
- var BUGGY = 'abbc'.split(/(b)*/)[1] === 'c' ||
11478
- // eslint-disable-next-line regexp/no-empty-group -- required for testing
11479
- 'test'.split(/(?:)/, -1).length !== 4 ||
11480
- 'ab'.split(/(?:ab)*/).length !== 2 ||
11481
- '.'.split(/(.?)(.?)/).length !== 4 ||
11482
- // eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing
11483
- '.'.split(/()()/).length > 1 ||
11484
- ''.split(/.?/).length;
11485
-
11486
- // @@split logic
11487
- fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) {
11488
- var internalSplit = '0'.split(undefined, 0).length ? function (separator, limit) {
11489
- return separator === undefined && limit === 0 ? [] : call$3(nativeSplit, this, separator, limit);
11490
- } : nativeSplit;
11491
-
11492
- return [
11493
- // `String.prototype.split` method
11494
- // https://tc39.es/ecma262/#sec-string.prototype.split
11495
- function split(separator, limit) {
11496
- var O = requireObjectCoercible$1(this);
11497
- var splitter = isNullOrUndefined(separator) ? undefined : getMethod(separator, SPLIT);
11498
- return splitter
11499
- ? call$3(splitter, separator, O, limit)
11500
- : call$3(internalSplit, toString$6(O), separator, limit);
11501
- },
11502
- // `RegExp.prototype[@@split]` method
11503
- // https://tc39.es/ecma262/#sec-regexp.prototype-@@split
11504
- //
11505
- // NOTE: This cannot be properly polyfilled in engines that don't support
11506
- // the 'y' flag.
11507
- function (string, limit) {
11508
- var rx = anObject$1(this);
11509
- var S = toString$6(string);
11510
-
11511
- if (!BUGGY) {
11512
- var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit);
11513
- if (res.done) return res.value;
11514
- }
11515
-
11516
- var C = speciesConstructor(rx, RegExp);
11517
- var unicodeMatching = rx.unicode;
11518
- var flags = (rx.ignoreCase ? 'i' : '') +
11519
- (rx.multiline ? 'm' : '') +
11520
- (rx.unicode ? 'u' : '') +
11521
- (UNSUPPORTED_Y ? 'g' : 'y');
11522
- // ^(? + rx + ) is needed, in combination with some S slicing, to
11523
- // simulate the 'y' flag.
11524
- var splitter = new C(UNSUPPORTED_Y ? '^(?:' + rx.source + ')' : rx, flags);
11525
- var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
11526
- if (lim === 0) return [];
11527
- if (S.length === 0) return regExpExec(splitter, S) === null ? [S] : [];
11528
- var p = 0;
11529
- var q = 0;
11530
- var A = [];
11531
- while (q < S.length) {
11532
- splitter.lastIndex = UNSUPPORTED_Y ? 0 : q;
11533
- var z = regExpExec(splitter, UNSUPPORTED_Y ? stringSlice$2(S, q) : S);
11534
- var e;
11535
- if (
11536
- z === null ||
11537
- (e = min$1(toLength$1(splitter.lastIndex + (UNSUPPORTED_Y ? q : 0)), S.length)) === p
11538
- ) {
11539
- q = advanceStringIndex(S, q, unicodeMatching);
11540
- } else {
11541
- push$5(A, stringSlice$2(S, p, q));
11542
- if (A.length === lim) return A;
11543
- for (var i = 1; i <= z.length - 1; i++) {
11544
- push$5(A, z[i]);
11545
- if (A.length === lim) return A;
11546
- }
11547
- q = p = e;
11548
- }
11549
- }
11550
- push$5(A, stringSlice$2(S, p));
11551
- return A;
11552
- }
11553
- ];
11554
- }, BUGGY || !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
11641
+ }
11642
+ const isRegisterBackedEnumFalsePositive = (uischema == null || (_uischema$options4 = uischema.options) == null ? void 0 : _uischema$options4.register) !== undefined && !isNilOrEmptyValue(data, true) && typeof activeError === 'string' && activeError.toLowerCase().includes('must be equal to one of the allowed values');
11643
+ if (isRegisterBackedEnumFalsePositive) {
11644
+ activeError = undefined;
11645
+ }
11646
+ if (activeError && /\sis required$/i.test(activeError)) {
11647
+ activeError = `${labelToUpdate} is required`;
11648
+ }
11649
+ // For required boolean fields (e.g. anyOf: [{enum: [true]}]), suppress the raw AJV
11650
+ // "must be equal to one of the allowed values" error and show a friendly message instead.
11651
+ if ((schema == null ? void 0 : schema.type) === 'boolean' && activeError && activeError.toLowerCase().includes('must be equal')) {
11652
+ activeError = data === false ? `${labelToUpdate} is required` : undefined;
11653
+ }
11654
+ // If a required checkbox is unchecked, show only the validation message in
11655
+ // review mode (not a contradictory "No (...)" value line).
11656
+ let isBooleanRequiredError = false;
11657
+ if ((schema == null ? void 0 : schema.type) === 'boolean' && data === false && activeError && /\sis required$/i.test(activeError)) {
11658
+ reviewText = '';
11659
+ isBooleanRequiredError = true;
11660
+ }
11661
+ // eslint-disable-next-line
11662
+ const stepId = (_uischema$options5 = uischema.options) == null ? void 0 : _uischema$options5.stepId;
11663
+ function handleChangeClick() {
11664
+ context == null || context.goToPage(stepId, uischema.scope);
11665
+ reviewCtx == null || reviewCtx.onChangeDispatch(stepId, uischema.scope);
11666
+ }
11667
+ const showInlineValue = reviewText === null || reviewText === undefined || typeof reviewText === 'string' || typeof reviewText === 'number' || /*#__PURE__*/React.isValidElement(reviewText) || Array.isArray(reviewText) && reviewText.length === 0;
11668
+ const isValueEmpty = !isBooleanRequiredError && (reviewText === null || reviewText === undefined || reviewText === '' || Array.isArray(reviewText) && reviewText.length === 0);
11669
+ return jsx("tr", {
11670
+ "data-testid": `input-base-table-${label}-row`,
11671
+ children: jsxs(PageReviewContainer, {
11672
+ colSpan: 3,
11673
+ children: [jsxs(ReviewHeader, {
11674
+ children: [jsxs(ReviewLabel, {
11675
+ children: [labelToUpdate, required && jsx(RequiredTextLabel, {
11676
+ children: " (required)"
11677
+ })]
11678
+ }), stepId !== undefined && !((_uischema$options6 = uischema.options) != null && (_uischema$options6 = _uischema$options6.componentProps) != null && _uischema$options6.readOnly) && jsx(GoabButton, {
11679
+ type: "tertiary",
11680
+ onClick: handleChangeClick,
11681
+ children: "Change"
11682
+ })]
11683
+ }), jsxs(ReviewValue, {
11684
+ children: [showInlineValue ? jsx("div", {
11685
+ "data-testid": `review-value-${label}`,
11686
+ children: isValueEmpty ? jsx(NoneGivenText, {
11687
+ children: "(none given)"
11688
+ }) : reviewText != null ? reviewText : ''
11689
+ }) : jsx(JsonFormsDispatch, {
11690
+ "data-testid": `jsonforms-object-list-defined-elements-dispatch`,
11691
+ schema: schema,
11692
+ uischema: uischema,
11693
+ enabled: enabled,
11694
+ renderers: jsonForms.renderers,
11695
+ cells: cells
11696
+ }), activeError && jsx(GoabFormItem, {
11697
+ error: activeError,
11698
+ label: ""
11699
+ })]
11700
+ })]
11701
+ })
11702
+ });
11703
+ };
11704
+ const GoAInputBaseTableReviewControl = withJsonFormsControlProps(GoAInputBaseTableReview);
11555
11705
 
11556
11706
  const defaultLabel = 'Email address';
11557
11707
  const GoAEmailInput = props => {
@@ -15340,7 +15490,7 @@ const ApplicationStatus = ({
15340
15490
  icon: false
15341
15491
  });
15342
15492
  const mainHeading = 'Application Progress';
15343
- const progressPercentageAccurate = 100 * completed / totalGroups;
15493
+ const progressPercentageAccurate = totalGroups > 0 ? 100 * completed / totalGroups : 0;
15344
15494
  return jsxs(CompletionStatus, {
15345
15495
  children: [jsxs(CompletionTextHeader, {
15346
15496
  children: [mainHeading, jsx(BadgeWrapper, {
@@ -15367,6 +15517,26 @@ const ApplicationStatus = ({
15367
15517
  });
15368
15518
  };
15369
15519
 
15520
+ var PageStatus;
15521
+ (function (PageStatus) {
15522
+ PageStatus["Complete"] = "Completed";
15523
+ PageStatus["Inprogress"] = "In progress";
15524
+ PageStatus["NotStarted"] = "Not started";
15525
+ })(PageStatus || (PageStatus = {}));
15526
+ const getCategoryStatus = category => {
15527
+ return category.isVisited ? category.isCompleted && category.isValid ? PageStatus.Complete : PageStatus.Inprogress : PageStatus.NotStarted;
15528
+ };
15529
+ const getCategoryStatusBadge = category => {
15530
+ const status = getCategoryStatus(category);
15531
+ const badgeType = status === PageStatus.Complete ? 'success' : 'information';
15532
+ return jsx(GoabBadge, {
15533
+ type: badgeType,
15534
+ content: status,
15535
+ ariaLabel: status,
15536
+ icon: false
15537
+ });
15538
+ };
15539
+
15370
15540
  const getCategorySections = categories => {
15371
15541
  const sectionMap = new Map();
15372
15542
  categories.forEach(category => {
@@ -15401,26 +15571,6 @@ const SectionHeaderRow = ({
15401
15571
  });
15402
15572
  };
15403
15573
 
15404
- var PageStatus;
15405
- (function (PageStatus) {
15406
- PageStatus["Complete"] = "Completed";
15407
- PageStatus["Inprogress"] = "In progress";
15408
- PageStatus["NotStarted"] = "Not started";
15409
- })(PageStatus || (PageStatus = {}));
15410
- const getCategoryStatus = category => {
15411
- return category.isVisited ? category.isCompleted && category.isValid ? PageStatus.Complete : PageStatus.Inprogress : PageStatus.NotStarted;
15412
- };
15413
- const getCategoryStatusBadge = category => {
15414
- const status = getCategoryStatus(category);
15415
- const badgeType = status === PageStatus.Complete ? 'success' : 'information';
15416
- return jsx(GoabBadge, {
15417
- type: badgeType,
15418
- content: status,
15419
- ariaLabel: status,
15420
- icon: false
15421
- });
15422
- };
15423
-
15424
15574
  /* eslint-disable jsx-a11y/anchor-is-valid */
15425
15575
  const CategoryRow = ({
15426
15576
  category,
@@ -15558,6 +15708,17 @@ function updateCompletion(group, index) {
15558
15708
  isValid: newIsCompleted ? category.isValid : false
15559
15709
  });
15560
15710
  }
15711
+ // The rows the progress bar is counting: the ones actually rendered in the task list.
15712
+ const isCounted = cat => shouldShow(cat) && (cat == null ? void 0 : cat.visible) !== false;
15713
+ // A page counts as completed only when its own badge says so. A page with no required fields is
15714
+ // flagged isCompleted on mount (so an untouched optional page does not block submission), while its
15715
+ // badge still reads "Not started" - counting isCompleted alone credits pages the user never opened.
15716
+ // updateCompletion rolls up the detail pages hidden from the task list, exactly as the rendered row
15717
+ // does, so the count never runs ahead of the badges.
15718
+ const isCountedComplete = (group, index) => getCategoryStatus(updateCompletion(group, index)) === PageStatus.Complete;
15719
+ const countCountedPages = group => group.filter(isCounted).length;
15720
+ const countCompletedPages = group => group.filter((cat, index) => isCounted(cat) && isCountedComplete(group, index)).length;
15721
+ const sumOverSections = (sections, count) => sections.reduce((total, section) => total + count(section.categories), 0);
15561
15722
  const TaskList = ({
15562
15723
  categories,
15563
15724
  onClick,
@@ -15584,8 +15745,8 @@ const TaskList = ({
15584
15745
  const sections = mergeOrphanSections(getCategorySections(categories));
15585
15746
  return sections;
15586
15747
  }, [categories]);
15587
- const totalPages = useMemo(() => mergedSections.reduce((count, section) => count + section.categories.filter(shouldShow).length, 0), [mergedSections]);
15588
- const completedPages = useMemo(() => mergedSections.reduce((count, section) => count + section.categories.filter(cat => shouldShow(cat) && cat.isCompleted).length, 0), [mergedSections]);
15748
+ const totalPages = useMemo(() => sumOverSections(mergedSections, countCountedPages), [mergedSections]);
15749
+ const completedPages = useMemo(() => sumOverSections(mergedSections, countCompletedPages), [mergedSections]);
15589
15750
  let globalIndex = 0;
15590
15751
  let sectionIndex = 1;
15591
15752
  return jsx(PageBorder, {
@@ -19772,158 +19933,6 @@ async function tryResolveRefs(schema, ...refSchemas) {
19772
19933
  }
19773
19934
  }
19774
19935
 
19775
- const AUTO_POPULATE_SOURCES = ['firstName', 'lastName', 'email'];
19776
- const getNameParts = user => {
19777
- const parts = ((user == null ? void 0 : user.name) || '').trim().split(/\s+/).filter(Boolean);
19778
- return {
19779
- firstName: parts[0] || '',
19780
- lastName: parts.length > 1 ? parts[parts.length - 1] : ''
19781
- };
19782
- };
19783
- /**
19784
- * @deprecated Field names no longer control auto-population. Use the
19785
- * UI-schema `options.autoPopulate` directive.
19786
- */
19787
- const USER_FIELD_DEFINITIONS = {
19788
- fullName: {
19789
- schema: {
19790
- type: 'string'
19791
- },
19792
- getValue: user => user == null ? void 0 : user.name
19793
- },
19794
- name: {
19795
- schema: {
19796
- type: 'string'
19797
- },
19798
- getValue: user => user == null ? void 0 : user.name
19799
- },
19800
- firstName: {
19801
- schema: {
19802
- type: 'string'
19803
- },
19804
- getValue: user => getNameParts(user).firstName
19805
- },
19806
- givenName: {
19807
- schema: {
19808
- type: 'string'
19809
- },
19810
- getValue: user => getNameParts(user).firstName
19811
- },
19812
- lastName: {
19813
- schema: {
19814
- type: 'string'
19815
- },
19816
- getValue: user => getNameParts(user).lastName
19817
- },
19818
- familyName: {
19819
- schema: {
19820
- type: 'string'
19821
- },
19822
- getValue: user => getNameParts(user).lastName
19823
- },
19824
- surname: {
19825
- schema: {
19826
- type: 'string'
19827
- },
19828
- getValue: user => getNameParts(user).lastName
19829
- },
19830
- email: {
19831
- schema: {
19832
- type: 'string',
19833
- format: 'email'
19834
- },
19835
- getValue: user => (user == null ? void 0 : user.email) || ''
19836
- },
19837
- emailAddress: {
19838
- schema: {
19839
- type: 'string',
19840
- format: 'email'
19841
- },
19842
- getValue: user => (user == null ? void 0 : user.email) || ''
19843
- },
19844
- primaryEmail: {
19845
- schema: {
19846
- type: 'string',
19847
- format: 'email'
19848
- },
19849
- getValue: user => (user == null ? void 0 : user.email) || ''
19850
- }
19851
- };
19852
- const AUTO_POPULATE_ACTION_TYPES = new Set([INIT, UPDATE_CORE]);
19853
- const isEmptyAutoPopulateTarget = value => value === undefined || value === null || value === '';
19854
- const shouldAutoPopulate = actionType => AUTO_POPULATE_ACTION_TYPES.has(actionType);
19855
- const isAutoPopulateSource = value => typeof value === 'string' && AUTO_POPULATE_SOURCES.includes(value);
19856
- const autoPopulateValue = (user, props) => {
19857
- var _props$uischema;
19858
- const source = (_props$uischema = props.uischema) == null || (_props$uischema = _props$uischema.options) == null ? void 0 : _props$uischema.autoPopulate;
19859
- if (!isAutoPopulateSource(source)) {
19860
- return undefined;
19861
- }
19862
- const name = getNameParts(user);
19863
- const values = {
19864
- firstName: name.firstName,
19865
- lastName: name.lastName,
19866
- email: (user == null ? void 0 : user.email) || ''
19867
- };
19868
- return values[source];
19869
- };
19870
- const getAutoPopulateControls = element => {
19871
- var _element$options, _element$elements;
19872
- if (!element) {
19873
- return [];
19874
- }
19875
- const controls = element.type === 'Control' && (_element$options = element.options) != null && _element$options.autoPopulate ? [element] : [];
19876
- const children = (_element$elements = element.elements) != null ? _element$elements : [];
19877
- return [...controls, ...children.flatMap(getAutoPopulateControls)];
19878
- };
19879
- const getAutoPopulatedData = (uischema, user) => {
19880
- if (!user) {
19881
- return [];
19882
- }
19883
- return getAutoPopulateControls(uischema).map(control => ({
19884
- path: toDataPath(control.scope),
19885
- value: autoPopulateValue(user, {
19886
- uischema: control
19887
- })
19888
- })).filter(({
19889
- path,
19890
- value
19891
- }) => Boolean(path) && value !== undefined && value !== null);
19892
- };
19893
- const mergeAutoPopulatedData = (data, autoPopulatedData) => {
19894
- if (autoPopulatedData.length === 0) {
19895
- return data;
19896
- }
19897
- const defaults = autoPopulatedData.reduce((values, {
19898
- path,
19899
- value
19900
- }) => _$c.set(values, path, value), {});
19901
- const normalizedData = _$c.cloneDeep(data != null ? data : {});
19902
- autoPopulatedData.forEach(({
19903
- path,
19904
- value
19905
- }) => {
19906
- if (isEmptyAutoPopulateTarget(_$c.get(normalizedData, path)) && value !== undefined && value !== null) {
19907
- _$c.unset(normalizedData, path);
19908
- }
19909
- });
19910
- return _$c.defaultsDeep({}, normalizedData, defaults);
19911
- };
19912
- const createAutoPopulateMiddleware = (uischema, user) => (state, action, defaultReducer) => {
19913
- const newState = defaultReducer(state, action);
19914
- if (!shouldAutoPopulate(action.type)) {
19915
- return newState;
19916
- }
19917
- return Object.assign({}, newState, {
19918
- data: mergeAutoPopulatedData(newState.data, getAutoPopulatedData(uischema, user))
19919
- });
19920
- };
19921
- /**
19922
- * Retained for compatibility with consumers of the previous data-schema
19923
- * autocomplete API. Auto-population is now configured in the UI schema.
19924
- */
19925
- const autoPopulatePropertiesMonaco = [];
19926
-
19927
19936
  const GoABaseRenderers = [
19928
19937
  // controls
19929
19938
  {