@abgov/jsonforms-components 2.66.4 → 2.67.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
@@ -6,7 +6,7 @@ import Ajv from 'ajv';
6
6
  import styled from 'styled-components';
7
7
  import axios from 'axios';
8
8
  import get$1 from 'lodash/get';
9
- 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 } from '@jsonforms/core';
9
+ 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';
10
10
  import * as _$c from 'lodash';
11
11
  import ___default, { isObject as isObject$i, isEmpty as isEmpty$1 } from 'lodash';
12
12
  import { useJsonForms, withJsonFormsControlProps, withJsonFormsEnumProps, withTranslateProps, JsonFormsDispatch, withJsonFormsAllOfProps, withJsonFormsArrayLayoutProps, withJsonFormsLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
@@ -4103,7 +4103,7 @@ const onKeyPressForTimeControl = props => {
4103
4103
  path
4104
4104
  } = controlProps;
4105
4105
  if (isNotKeyPressTabOrShift(key)) {
4106
- handleChange(path, value === '' ? undefined : value);
4106
+ handleChange(path, value);
4107
4107
  }
4108
4108
  };
4109
4109
  /**
@@ -4124,7 +4124,7 @@ const onKeyPressForDateControl = props => {
4124
4124
  } = controlProps;
4125
4125
  if (isNotKeyPressTabOrShift(key)) {
4126
4126
  value = standardizeDate(value) || '';
4127
- handleChange(path, value === '' ? undefined : value);
4127
+ handleChange(path, value);
4128
4128
  }
4129
4129
  };
4130
4130
  /**
@@ -4141,7 +4141,7 @@ const onBlurForTextControl = props => {
4141
4141
  path
4142
4142
  } = controlProps;
4143
4143
  if (isRequiredAndHasNoData(controlProps)) {
4144
- handleChange(path, value === '' ? undefined : value);
4144
+ handleChange(path, value);
4145
4145
  }
4146
4146
  };
4147
4147
  /**
@@ -4182,7 +4182,7 @@ const onBlurForDateControl = props => {
4182
4182
  } = controlProps;
4183
4183
  if (isRequiredAndHasNoData(controlProps)) {
4184
4184
  value = standardizeDate(value) || '';
4185
- handleChange(path, value === '' ? undefined : value);
4185
+ handleChange(path, value);
4186
4186
  }
4187
4187
  };
4188
4188
  /**
@@ -4204,7 +4204,7 @@ const onChangeForDateControl = props => {
4204
4204
  if (value && value !== null) {
4205
4205
  value = standardizeDate(value) || '';
4206
4206
  if (value !== data) {
4207
- handleChange(path, value === '' ? undefined : value);
4207
+ handleChange(path, value);
4208
4208
  }
4209
4209
  }
4210
4210
  };
@@ -4223,7 +4223,7 @@ const onChangeForInputControl = props => {
4223
4223
  handleChange,
4224
4224
  path
4225
4225
  } = controlProps;
4226
- handleChange(path, value === '' ? undefined : value);
4226
+ handleChange(path, value);
4227
4227
  };
4228
4228
  /**
4229
4229
  * Helper function to process onChange event for Date controls.
@@ -4245,19 +4245,23 @@ const onChangeForDateTimeControl = props => {
4245
4245
  var _Date;
4246
4246
  value = isValidDate(value) ? (_Date = new Date(value)) == null ? void 0 : _Date.toISOString() : '';
4247
4247
  if (data !== value) {
4248
- handleChange(path, value === '' ? undefined : value);
4248
+ handleChange(path, value);
4249
4249
  }
4250
4250
  }
4251
4251
  };
4252
+ const toNumericControlValue = value => {
4253
+ if (value === '' || value === null || value === undefined || value instanceof Date) {
4254
+ return undefined;
4255
+ }
4256
+ return +value;
4257
+ };
4252
4258
  /**
4253
4259
  * Helper function to process onChange event for Number/Integer controls.
4254
4260
  * @param props - EventChangeControlProps
4255
4261
  */
4256
4262
  const onChangeForNumericControl = props => {
4257
4263
  const {
4258
- value
4259
- } = props;
4260
- const {
4264
+ value,
4261
4265
  controlProps
4262
4266
  } = props;
4263
4267
  const {
@@ -4265,18 +4269,9 @@ const onChangeForNumericControl = props => {
4265
4269
  path,
4266
4270
  data
4267
4271
  } = controlProps;
4268
- if (value && value !== null) {
4269
- //Prevents handleChange from executing if the data has not changed
4270
- //so the component will not re render.
4271
- if (data !== +value) {
4272
- let newValue = undefined;
4273
- if (value !== '') {
4274
- newValue = +value;
4275
- }
4276
- handleChange(path, newValue);
4277
- }
4278
- } else {
4279
- handleChange(path, value === '' ? undefined : value);
4272
+ const newValue = toNumericControlValue(value);
4273
+ if (data !== newValue) {
4274
+ handleChange(path, newValue);
4280
4275
  }
4281
4276
  };
4282
4277
  const ensureGoaDatePointerCursor = host => {
@@ -4425,8 +4420,8 @@ if ($stringify) {
4425
4420
  });
4426
4421
  }
4427
4422
 
4428
- const defineFields$1 = fields => fields;
4429
- const OPTION_DEFINITIONS = defineFields$1({
4423
+ const defineFields = fields => fields;
4424
+ const OPTION_DEFINITIONS = defineFields({
4430
4425
  mainTitle: {
4431
4426
  schema: 'Main form title'
4432
4427
  },
@@ -4442,6 +4437,9 @@ const OPTION_DEFINITIONS = defineFields$1({
4442
4437
  emailFirst: {
4443
4438
  schema: true
4444
4439
  },
4440
+ autoPopulate: {
4441
+ schema: 'firstName'
4442
+ },
4445
4443
  noDataMessage: {
4446
4444
  schema: 'no data'
4447
4445
  },
@@ -6491,21 +6489,6 @@ function buildConditionalDeps(rootSchema) {
6491
6489
  return out;
6492
6490
  }
6493
6491
 
6494
- function getValueAtPath(obj, path) {
6495
- return path.split('.').reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
6496
- }
6497
- function hasMeaningfulValue(val) {
6498
- if (val === undefined || val === null) return false;
6499
- if (typeof val === 'string') return val.trim() !== '';
6500
- if (Array.isArray(val)) return val.length > 0;
6501
- if (typeof val === 'object') return Object.keys(val).length > 0;
6502
- return true;
6503
- }
6504
- function isStepStarted(normalizedScopes, data) {
6505
- return normalizedScopes.some(path => {
6506
- return hasMeaningfulValue(getValueAtPath(data, path));
6507
- });
6508
- }
6509
6492
  function getSubSchema(schema, path) {
6510
6493
  const parts = path.replace(/^#\//, '').split('/').filter(p => p !== 'properties') // remove 'properties' segments
6511
6494
  .slice(0, -1);
@@ -6553,8 +6536,10 @@ function getStepStatus(opts) {
6553
6536
  data,
6554
6537
  visited
6555
6538
  } = opts;
6539
+ if (!visited) {
6540
+ return 'NotStarted';
6541
+ }
6556
6542
  const normalizedScopes = scopes.map(normalizeSchemaPath).filter(Boolean);
6557
- const started = isStepStarted(normalizedScopes, data);
6558
6543
  const incompleteInStep = getIncompletePaths(errors, scopes);
6559
6544
  if (incompleteInStep.length > 0) {
6560
6545
  return 'InProgress';
@@ -6565,21 +6550,27 @@ function getStepStatus(opts) {
6565
6550
  }
6566
6551
  const deps = buildConditionalDeps(schema);
6567
6552
  const controllersInStep = normalizedScopes.filter(s => deps.has(s));
6568
- if (controllersInStep.length === 0) return visited || started ? 'Completed' : 'NotStarted';
6553
+ if (controllersInStep.length === 0) {
6554
+ return 'Completed';
6555
+ }
6569
6556
  const affected = new Set();
6570
- for (const c of controllersInStep) {
6571
- for (const p of deps.get(c) || []) affected.add(p);
6557
+ for (const controller of controllersInStep) {
6558
+ for (const path of deps.get(controller) || []) {
6559
+ affected.add(path);
6560
+ }
6561
+ }
6562
+ if (affected.size === 0) {
6563
+ return 'Completed';
6572
6564
  }
6573
- if (affected.size === 0) return visited || started ? 'Completed' : 'NotStarted';
6574
6565
  const affectedPaths = [...affected];
6575
6566
  for (const err of errors || []) {
6576
- for (const cand of collectErrorCandidates(err)) {
6577
- if (affectedPaths.some(p => isUnder(cand, p))) {
6567
+ for (const candidate of collectErrorCandidates(err)) {
6568
+ if (affectedPaths.some(path => isUnder(candidate, path))) {
6578
6569
  return 'InProgress';
6579
6570
  }
6580
6571
  }
6581
6572
  }
6582
- return visited || started ? 'Completed' : 'NotStarted';
6573
+ return 'Completed';
6583
6574
  }
6584
6575
  function collectErrorCandidates(e) {
6585
6576
  var _e$params;
@@ -6859,6 +6850,9 @@ const createStepperContextInitData = props => {
6859
6850
  };
6860
6851
  };
6861
6852
  const JsonFormsStepperContext = /*#__PURE__*/createContext(undefined);
6853
+ const isFormValid = (ajvValid, emptyRequiredStringErrors) => {
6854
+ return ajvValid && emptyRequiredStringErrors.length === 0;
6855
+ };
6862
6856
  const JsonFormsStepperContextProvider = ({
6863
6857
  children,
6864
6858
  StepperProps
@@ -6895,6 +6889,8 @@ const JsonFormsStepperContextProvider = ({
6895
6889
  stepperDispatch,
6896
6890
  selectStepperState: () => {
6897
6891
  var _stepperState$categor;
6892
+ const emptyRequiredStringErrors = getEmptyRequiredStringErrors(data || {}, schema);
6893
+ stepperState.isValid = isFormValid(stepperState.isValid, emptyRequiredStringErrors);
6898
6894
  return Object.assign({}, stepperState, {
6899
6895
  categories: (_stepperState$categor = stepperState.categories) == null ? void 0 : _stepperState$categor.map(c => {
6900
6896
  return Object.assign({}, c, {
@@ -7009,6 +7005,58 @@ const JsonFormsStepperContextProvider = ({
7009
7005
  children: children
7010
7006
  });
7011
7007
  };
7008
+ const isSchemaObject = schema => {
7009
+ return !!schema && typeof schema === 'object' && !Array.isArray(schema);
7010
+ };
7011
+ const getObjectData = data => {
7012
+ return data && typeof data === 'object' && !Array.isArray(data) ? data : {};
7013
+ };
7014
+ const isRequiredStringSchema = schema => {
7015
+ return isSchemaObject(schema) && schema.type === 'string';
7016
+ };
7017
+ const createRequiredStringError = (schema, propertyName, instancePath, schemaPath) => ({
7018
+ instancePath: `${instancePath}/${propertyName}`,
7019
+ schemaPath: `${schemaPath}/requiredString`,
7020
+ keyword: 'requiredString',
7021
+ params: {
7022
+ propertyName
7023
+ },
7024
+ message: 'is required',
7025
+ schema: true,
7026
+ parentSchema: schema,
7027
+ data: ''
7028
+ });
7029
+ const addEmptyRequiredStringErrors = (data, schema, instancePath, schemaPath, errors) => {
7030
+ var _schema$required, _schema$properties;
7031
+ const required = (_schema$required = schema.required) != null ? _schema$required : [];
7032
+ const properties = (_schema$properties = schema.properties) != null ? _schema$properties : {};
7033
+ for (const propertyName of required) {
7034
+ const propertySchema = properties[propertyName];
7035
+ if (isRequiredStringSchema(propertySchema) && data[propertyName] === '') {
7036
+ errors.push(createRequiredStringError(schema, propertyName, instancePath, schemaPath));
7037
+ }
7038
+ }
7039
+ };
7040
+ const collectEmptyRequiredStringErrors = (data, schema, instancePath, schemaPath, errors) => {
7041
+ var _schema$properties2;
7042
+ if (!isSchemaObject(schema)) {
7043
+ return;
7044
+ }
7045
+ const objectData = getObjectData(data);
7046
+ const properties = (_schema$properties2 = schema.properties) != null ? _schema$properties2 : {};
7047
+ addEmptyRequiredStringErrors(objectData, schema, instancePath, schemaPath, errors);
7048
+ for (const [propertyName, propertySchema] of Object.entries(properties)) {
7049
+ if (!isSchemaObject(propertySchema)) {
7050
+ continue;
7051
+ }
7052
+ collectEmptyRequiredStringErrors(objectData[propertyName], propertySchema, `${instancePath}/${propertyName}`, `${schemaPath}/properties/${propertyName}`, errors);
7053
+ }
7054
+ };
7055
+ const getEmptyRequiredStringErrors = (data, schema) => {
7056
+ const errors = [];
7057
+ collectEmptyRequiredStringErrors(data, schema, '', '#', errors);
7058
+ return errors;
7059
+ };
7012
7060
 
7013
7061
  const GoAInputBaseControl = props => {
7014
7062
  var _stepperState$categor, _uischema$options$com, _uischema$options, _uischema$options2, _uischema$options3;
@@ -7302,7 +7350,6 @@ const InnerGoAInputText = props => {
7302
7350
  isVisited,
7303
7351
  setIsVisited
7304
7352
  } = props;
7305
- useRegisterUser();
7306
7353
  const isSinField = schema.title === sinTitle;
7307
7354
  const initialValue = isSinField && typeof data === 'string' ? formatSinForDisplay(data) : data;
7308
7355
  const [manualInput, setManualInput] = useState(false);
@@ -10377,94 +10424,6 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa
10377
10424
  ];
10378
10425
  }, BUGGY || !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
10379
10426
 
10380
- const defineFields = fields => fields;
10381
- const autoLabel = name => `${name} (auto from user profile)`;
10382
- const buildInsertText = (key, schema) => `${key}": ${JSON.stringify(schema, null, 2)}`;
10383
- const getNameParts = user => {
10384
- const [first = '', last = ''] = ((user == null ? void 0 : user.name) || '').split(' ');
10385
- return {
10386
- first,
10387
- last
10388
- };
10389
- };
10390
- const fullNameSchema = {
10391
- type: 'string',
10392
- minLength: 3,
10393
- description: 'Please enter your full name'
10394
- };
10395
- const firstNameSchema = {
10396
- type: 'string',
10397
- minLength: 3,
10398
- description: 'Please enter your first name'
10399
- };
10400
- const lastNameSchema = {
10401
- type: 'string',
10402
- minLength: 3,
10403
- description: 'Please enter your last name'
10404
- };
10405
- const emailSchema = {
10406
- type: 'string',
10407
- format: 'email',
10408
- maxLength: 100,
10409
- pattern: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,}$',
10410
- description: 'Please enter a valid email address (e.g., name@example.com).',
10411
- errorMessage: {
10412
- pattern: '(e.g., name@example.com).',
10413
- maxLength: 'Email must be less than 100 characters.'
10414
- }
10415
- };
10416
- const USER_FIELD_DEFINITIONS = defineFields({
10417
- fullName: {
10418
- schema: fullNameSchema,
10419
- getValue: user => user == null ? void 0 : user.name
10420
- },
10421
- name: {
10422
- schema: fullNameSchema,
10423
- getValue: user => user == null ? void 0 : user.name
10424
- },
10425
- firstName: {
10426
- schema: firstNameSchema,
10427
- getValue: user => getNameParts(user).first
10428
- },
10429
- givenName: {
10430
- schema: firstNameSchema,
10431
- getValue: user => getNameParts(user).first
10432
- },
10433
- lastName: {
10434
- schema: lastNameSchema,
10435
- getValue: user => getNameParts(user).last
10436
- },
10437
- familyName: {
10438
- schema: lastNameSchema,
10439
- getValue: user => getNameParts(user).last
10440
- },
10441
- surname: {
10442
- schema: lastNameSchema,
10443
- getValue: user => getNameParts(user).last
10444
- },
10445
- email: {
10446
- schema: emailSchema,
10447
- getValue: user => (user == null ? void 0 : user.email) || ''
10448
- },
10449
- emailAddress: {
10450
- schema: emailSchema,
10451
- getValue: user => (user == null ? void 0 : user.email) || ''
10452
- },
10453
- primaryEmail: {
10454
- schema: emailSchema,
10455
- getValue: user => (user == null ? void 0 : user.email) || ''
10456
- }
10457
- });
10458
- const autoPopulateValue = (user, props) => {
10459
- const field = USER_FIELD_DEFINITIONS[props.path];
10460
- if (!field) return undefined;
10461
- return field.getValue(user);
10462
- };
10463
- const autoPopulatePropertiesMonaco = Object.entries(USER_FIELD_DEFINITIONS).map(([key, field]) => ({
10464
- label: autoLabel(key),
10465
- insertText: buildInsertText(key, field.schema)
10466
- }));
10467
-
10468
10427
  const defaultLabel = 'Email address';
10469
10428
  const GoAEmailInput = props => {
10470
10429
  var _uischema$options$com, _uischema$options, _uischema$options$com2, _uischema$options2, _stepperState$categor;
@@ -10485,13 +10444,18 @@ const GoAEmailInput = props => {
10485
10444
  const appliedUiSchemaOptions = Object.assign({}, config, uischema == null ? void 0 : uischema.options);
10486
10445
  const readOnly = (_uischema$options$com = uischema == null || (_uischema$options = uischema.options) == null || (_uischema$options = _uischema$options.componentProps) == null ? void 0 : _uischema$options.readOnly) != null ? _uischema$options$com : false;
10487
10446
  const width = (_uischema$options$com2 = uischema == null || (_uischema$options2 = uischema.options) == null || (_uischema$options2 = _uischema$options2.componentProps) == null ? void 0 : _uischema$options2.width) != null ? _uischema$options$com2 : '100%';
10488
- const user = useRegisterUser();
10489
10447
  const formStepperCtx = useContext(JsonFormsStepperContext);
10490
10448
  const stepperState = formStepperCtx == null || formStepperCtx.selectStepperState == null ? void 0 : formStepperCtx.selectStepperState();
10491
10449
  const currentCategory = stepperState == null || (_stepperState$categor = stepperState.categories) == null ? void 0 : _stepperState$categor[stepperState == null ? void 0 : stepperState.activeId];
10492
10450
  const showReviewLink = currentCategory == null ? void 0 : currentCategory.showReviewPageLink;
10493
10451
  const [localValue, setLocalValue] = useState(data);
10494
10452
  const debouncedValue = useDebounce(localValue, 300);
10453
+ useEffect(() => {
10454
+ if (data === undefined || data === null) {
10455
+ return;
10456
+ }
10457
+ setLocalValue(data);
10458
+ }, [data]);
10495
10459
  /* istanbul ignore next */
10496
10460
  useEffect(() => {
10497
10461
  if (debouncedValue === data) return;
@@ -10503,7 +10467,6 @@ const GoAEmailInput = props => {
10503
10467
  });
10504
10468
  }
10505
10469
  }, [debouncedValue]);
10506
- const [manualInput, setManualInput] = useState(false);
10507
10470
  const [isVisited, setIsVisited] = useState(false);
10508
10471
  useEffect(() => {
10509
10472
  if (showReviewLink === true) {
@@ -10515,14 +10478,6 @@ const GoAEmailInput = props => {
10515
10478
  const splintIndex = splitErrors.findIndex(e => e === REQUIRED_PROPERTY_ERROR);
10516
10479
  splitErrors[splintIndex] = `${primaryLabel} is required`;
10517
10480
  const finalErrors = splitErrors.join('\n');
10518
- useEffect(() => {
10519
- if (!user || data) return;
10520
- const autoPopulatedValue = schema.default || user && autoPopulateValue(user, props);
10521
- if (autoPopulatedValue && autoPopulatedValue !== data && !manualInput) {
10522
- handleChange(props.path, autoPopulatedValue);
10523
- }
10524
- // eslint-disable-next-line react-hooks/exhaustive-deps
10525
- }, [schema, user]);
10526
10481
  useEffect(() => {
10527
10482
  if (typeof handleChange === 'function' && (schema == null ? void 0 : schema.default) !== undefined) {
10528
10483
  handleChange(props.path, schema.default);
@@ -10549,7 +10504,6 @@ const GoAEmailInput = props => {
10549
10504
  disabled: !enabled,
10550
10505
  readonly: readOnly,
10551
10506
  onChange: detail => {
10552
- setManualInput(true);
10553
10507
  if (!isVisited) {
10554
10508
  setIsVisited(true);
10555
10509
  }
@@ -18870,6 +18824,158 @@ async function tryResolveRefs(schema, ...refSchemas) {
18870
18824
  }
18871
18825
  }
18872
18826
 
18827
+ const AUTO_POPULATE_SOURCES = ['firstName', 'lastName', 'email'];
18828
+ const getNameParts = user => {
18829
+ const parts = ((user == null ? void 0 : user.name) || '').trim().split(/\s+/).filter(Boolean);
18830
+ return {
18831
+ firstName: parts[0] || '',
18832
+ lastName: parts.length > 1 ? parts[parts.length - 1] : ''
18833
+ };
18834
+ };
18835
+ /**
18836
+ * @deprecated Field names no longer control auto-population. Use the
18837
+ * UI-schema `options.autoPopulate` directive.
18838
+ */
18839
+ const USER_FIELD_DEFINITIONS = {
18840
+ fullName: {
18841
+ schema: {
18842
+ type: 'string'
18843
+ },
18844
+ getValue: user => user == null ? void 0 : user.name
18845
+ },
18846
+ name: {
18847
+ schema: {
18848
+ type: 'string'
18849
+ },
18850
+ getValue: user => user == null ? void 0 : user.name
18851
+ },
18852
+ firstName: {
18853
+ schema: {
18854
+ type: 'string'
18855
+ },
18856
+ getValue: user => getNameParts(user).firstName
18857
+ },
18858
+ givenName: {
18859
+ schema: {
18860
+ type: 'string'
18861
+ },
18862
+ getValue: user => getNameParts(user).firstName
18863
+ },
18864
+ lastName: {
18865
+ schema: {
18866
+ type: 'string'
18867
+ },
18868
+ getValue: user => getNameParts(user).lastName
18869
+ },
18870
+ familyName: {
18871
+ schema: {
18872
+ type: 'string'
18873
+ },
18874
+ getValue: user => getNameParts(user).lastName
18875
+ },
18876
+ surname: {
18877
+ schema: {
18878
+ type: 'string'
18879
+ },
18880
+ getValue: user => getNameParts(user).lastName
18881
+ },
18882
+ email: {
18883
+ schema: {
18884
+ type: 'string',
18885
+ format: 'email'
18886
+ },
18887
+ getValue: user => (user == null ? void 0 : user.email) || ''
18888
+ },
18889
+ emailAddress: {
18890
+ schema: {
18891
+ type: 'string',
18892
+ format: 'email'
18893
+ },
18894
+ getValue: user => (user == null ? void 0 : user.email) || ''
18895
+ },
18896
+ primaryEmail: {
18897
+ schema: {
18898
+ type: 'string',
18899
+ format: 'email'
18900
+ },
18901
+ getValue: user => (user == null ? void 0 : user.email) || ''
18902
+ }
18903
+ };
18904
+ const AUTO_POPULATE_ACTION_TYPES = new Set([INIT, UPDATE_CORE]);
18905
+ const isEmptyAutoPopulateTarget = value => value === undefined || value === null || value === '';
18906
+ const shouldAutoPopulate = actionType => AUTO_POPULATE_ACTION_TYPES.has(actionType);
18907
+ const isAutoPopulateSource = value => typeof value === 'string' && AUTO_POPULATE_SOURCES.includes(value);
18908
+ const autoPopulateValue = (user, props) => {
18909
+ var _props$uischema;
18910
+ const source = (_props$uischema = props.uischema) == null || (_props$uischema = _props$uischema.options) == null ? void 0 : _props$uischema.autoPopulate;
18911
+ if (!isAutoPopulateSource(source)) {
18912
+ return undefined;
18913
+ }
18914
+ const name = getNameParts(user);
18915
+ const values = {
18916
+ firstName: name.firstName,
18917
+ lastName: name.lastName,
18918
+ email: (user == null ? void 0 : user.email) || ''
18919
+ };
18920
+ return values[source];
18921
+ };
18922
+ const getAutoPopulateControls = element => {
18923
+ var _element$options, _element$elements;
18924
+ if (!element) {
18925
+ return [];
18926
+ }
18927
+ const controls = element.type === 'Control' && (_element$options = element.options) != null && _element$options.autoPopulate ? [element] : [];
18928
+ const children = (_element$elements = element.elements) != null ? _element$elements : [];
18929
+ return [...controls, ...children.flatMap(getAutoPopulateControls)];
18930
+ };
18931
+ const getAutoPopulatedData = (uischema, user) => {
18932
+ if (!user) {
18933
+ return [];
18934
+ }
18935
+ return getAutoPopulateControls(uischema).map(control => ({
18936
+ path: toDataPath(control.scope),
18937
+ value: autoPopulateValue(user, {
18938
+ uischema: control
18939
+ })
18940
+ })).filter(({
18941
+ path,
18942
+ value
18943
+ }) => Boolean(path) && value !== undefined && value !== null);
18944
+ };
18945
+ const mergeAutoPopulatedData = (data, autoPopulatedData) => {
18946
+ if (autoPopulatedData.length === 0) {
18947
+ return data;
18948
+ }
18949
+ const defaults = autoPopulatedData.reduce((values, {
18950
+ path,
18951
+ value
18952
+ }) => _$c.set(values, path, value), {});
18953
+ const normalizedData = _$c.cloneDeep(data != null ? data : {});
18954
+ autoPopulatedData.forEach(({
18955
+ path,
18956
+ value
18957
+ }) => {
18958
+ if (isEmptyAutoPopulateTarget(_$c.get(normalizedData, path)) && value !== undefined && value !== null) {
18959
+ _$c.unset(normalizedData, path);
18960
+ }
18961
+ });
18962
+ return _$c.defaultsDeep({}, normalizedData, defaults);
18963
+ };
18964
+ const createAutoPopulateMiddleware = (uischema, user) => (state, action, defaultReducer) => {
18965
+ const newState = defaultReducer(state, action);
18966
+ if (!shouldAutoPopulate(action.type)) {
18967
+ return newState;
18968
+ }
18969
+ return Object.assign({}, newState, {
18970
+ data: mergeAutoPopulatedData(newState.data, getAutoPopulatedData(uischema, user))
18971
+ });
18972
+ };
18973
+ /**
18974
+ * Retained for compatibility with consumers of the previous data-schema
18975
+ * autocomplete API. Auto-population is now configured in the UI schema.
18976
+ */
18977
+ const autoPopulatePropertiesMonaco = [];
18978
+
18873
18979
  const GoABaseRenderers = [
18874
18980
  // controls
18875
18981
  {
@@ -19136,4 +19242,4 @@ const GoARenderers = [...GoABaseRenderers, {
19136
19242
  }];
19137
19243
  const GoACells = [...InputCells];
19138
19244
 
19139
- export { ADD_DATALIST_ACTION, ADD_NO_ANONYMOUS_ACTION, ADD_REGISTER_DATA_ACTION, ADD_REGISTER_DATA_ERROR, ADD_USER_ACTION, AddressLookUpControl, AddressLookUpControlReview, AddressLookUpTester, AddressLoopUpControlTableReview, ArrayControl, ArrayControlBase, ArrayControlReview, BooleanComponent, BooleanControl, BooleanRadioComponent, BooleanRadioControl, CategorizationPagesRendererTester, CategorizationStepperRendererTester, CheckboxGroup, ContactInformationTester, ContextProviderC, ContextProviderClass, ContextProviderFactory, ContractInfoControl, ContractInfoControlReview, EnumCheckboxControl, EnumRadioControl, EnumSelect, FileUploader, FileUploaderReview, FileUploaderTester, FormPageStepper, FormPagesView, FormStepper, FormStepperControl, FormStepperPagesControl, FormStepperReviewControl, FormStepperReviewer, FormStepperView, FullNameControl, FullNameControlReview, FullNameDobControl, FullNameDobReviewControl, FullNameDobTester, FullNameReviewControl, FullNameTester, GoAArrayControlRenderer, GoAArrayControlReviewRenderer, GoAArrayControlTester, GoABaseInputReviewComponent, GoABaseRenderers, GoABaseReviewRenderers, GoABaseTableReviewRenderers, GoABooleanControl, GoABooleanControlTester, GoABooleanRadioControl, GoABooleanRadioControlTester, GoACalculationControl, GoACalculationControlTester, GoACells, GoACheckoutGroupControlTester, GoAContractInfoControlReview, GoADateControl, GoADateControlTester, GoADateInput, GoADateTimeControl, GoADateTimeControlTester, GoADateTimeInput, GoAEmailControl, GoAEmailControlTester, GoAEmailInput, GoAEnumCheckboxGroupControl, GoAEnumControl, GoAEnumControlTester, GoAEnumRadioGroupControl, GoAInputBaseControl, GoAInputBaseFullNameControlReview, GoAInputBaseFullNameDobControlReview, GoAInputBaseReviewControl, GoAInputBaseTableReview, GoAInputBaseTableReviewControl, GoAInputDateControl, GoAInputDateTimeControl, GoAInputEmailControl, GoAInputIntegerControl, GoAInputNumberControl, GoAInputText, GoAInputTextControl, GoAInputTimeControl, GoAIntegerControl, GoAIntegerControlTester, GoAListWithDetailsControlRenderer, GoAListWithDetailsTester, GoANumberControl, GoANumberControlTester, GoANumberInput, GoAPhoneNumberControl, GoAPhoneNumberWithTypeControl, GoAPrimitiveArrayRenderer, GoAPrimitiveArrayTester, GoARadioGroupControlTester, GoARenderers, GoAReviewRenderers, GoATextControl, GoATextControlTester, GoATimeControl, GoATimeControlTester, GoATimeInput, GoInputBaseReview, GoabInputBasePhoneNumberReviewControl, GoabInputBasePhoneNumberWithTypeReviewControl, GoabInputInteger, InnerGoAInputText, JsonFormContext, JsonFormRegisterProvider, JsonFormsRegisterContext, ListWithDetailsControl, MultiLineText, MultiLineTextControl, MultiLineTextControlInput, MultiLineTextControlTester, OPTION_DEFINITIONS, PHONE_REGEX, PhoneGrid, PhoneNumberControl, PhoneNumberReviewControl, PhoneNumberTester, PhoneNumberWithTypeControl, PhoneNumberWithTypeReviewControl, PhoneNumberWithTypeTester, PrimitiveArrayControl, RadioGroup, USER_FIELD_DEFINITIONS, autoPopulatePropertiesMonaco, autoPopulateValue, categoriesAreValid, createDefaultAjv, enumControl, errMalformedDate, fetchRegisterConfigFromOptions$1 as fetchRegisterConfigFromOptions, formatSin, getByJsonPointer, getCategoryScopes, hasDataInScopes, hasDataValue, isAddressLookup, isContactInformation, isFullName, isFullNameDoB, isPhoneNumberWithType, predictiveOptionsMonaco, registerReducer, resolveRefs, toDateTimeLocalInputValue, tryResolveRefs, useRegisterUser };
19245
+ export { ADD_DATALIST_ACTION, ADD_NO_ANONYMOUS_ACTION, ADD_REGISTER_DATA_ACTION, ADD_REGISTER_DATA_ERROR, ADD_USER_ACTION, AUTO_POPULATE_SOURCES, AddressLookUpControl, AddressLookUpControlReview, AddressLookUpTester, AddressLoopUpControlTableReview, ArrayControl, ArrayControlBase, ArrayControlReview, BooleanComponent, BooleanControl, BooleanRadioComponent, BooleanRadioControl, CategorizationPagesRendererTester, CategorizationStepperRendererTester, CheckboxGroup, ContactInformationTester, ContextProviderC, ContextProviderClass, ContextProviderFactory, ContractInfoControl, ContractInfoControlReview, EnumCheckboxControl, EnumRadioControl, EnumSelect, FileUploader, FileUploaderReview, FileUploaderTester, FormPageStepper, FormPagesView, FormStepper, FormStepperControl, FormStepperPagesControl, FormStepperReviewControl, FormStepperReviewer, FormStepperView, FullNameControl, FullNameControlReview, FullNameDobControl, FullNameDobReviewControl, FullNameDobTester, FullNameReviewControl, FullNameTester, GoAArrayControlRenderer, GoAArrayControlReviewRenderer, GoAArrayControlTester, GoABaseInputReviewComponent, GoABaseRenderers, GoABaseReviewRenderers, GoABaseTableReviewRenderers, GoABooleanControl, GoABooleanControlTester, GoABooleanRadioControl, GoABooleanRadioControlTester, GoACalculationControl, GoACalculationControlTester, GoACells, GoACheckoutGroupControlTester, GoAContractInfoControlReview, GoADateControl, GoADateControlTester, GoADateInput, GoADateTimeControl, GoADateTimeControlTester, GoADateTimeInput, GoAEmailControl, GoAEmailControlTester, GoAEmailInput, GoAEnumCheckboxGroupControl, GoAEnumControl, GoAEnumControlTester, GoAEnumRadioGroupControl, GoAInputBaseControl, GoAInputBaseFullNameControlReview, GoAInputBaseFullNameDobControlReview, GoAInputBaseReviewControl, GoAInputBaseTableReview, GoAInputBaseTableReviewControl, GoAInputDateControl, GoAInputDateTimeControl, GoAInputEmailControl, GoAInputIntegerControl, GoAInputNumberControl, GoAInputText, GoAInputTextControl, GoAInputTimeControl, GoAIntegerControl, GoAIntegerControlTester, GoAListWithDetailsControlRenderer, GoAListWithDetailsTester, GoANumberControl, GoANumberControlTester, GoANumberInput, GoAPhoneNumberControl, GoAPhoneNumberWithTypeControl, GoAPrimitiveArrayRenderer, GoAPrimitiveArrayTester, GoARadioGroupControlTester, GoARenderers, GoAReviewRenderers, GoATextControl, GoATextControlTester, GoATimeControl, GoATimeControlTester, GoATimeInput, GoInputBaseReview, GoabInputBasePhoneNumberReviewControl, GoabInputBasePhoneNumberWithTypeReviewControl, GoabInputInteger, InnerGoAInputText, JsonFormContext, JsonFormRegisterProvider, JsonFormsRegisterContext, ListWithDetailsControl, MultiLineText, MultiLineTextControl, MultiLineTextControlInput, MultiLineTextControlTester, OPTION_DEFINITIONS, PHONE_REGEX, PhoneGrid, PhoneNumberControl, PhoneNumberReviewControl, PhoneNumberTester, PhoneNumberWithTypeControl, PhoneNumberWithTypeReviewControl, PhoneNumberWithTypeTester, PrimitiveArrayControl, RadioGroup, USER_FIELD_DEFINITIONS, autoPopulatePropertiesMonaco, autoPopulateValue, categoriesAreValid, createAutoPopulateMiddleware, createDefaultAjv, enumControl, errMalformedDate, fetchRegisterConfigFromOptions$1 as fetchRegisterConfigFromOptions, formatSin, getAutoPopulateControls, getAutoPopulatedData, getByJsonPointer, getCategoryScopes, hasDataInScopes, hasDataValue, isAddressLookup, isContactInformation, isFullName, isFullNameDoB, isPhoneNumberWithType, mergeAutoPopulatedData, predictiveOptionsMonaco, registerReducer, resolveRefs, toDateTimeLocalInputValue, tryResolveRefs, useRegisterUser };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.66.4",
3
+ "version": "2.67.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",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": "1.0.0",
3
- "generatedAt": "2026-06-17T15:15:12.476Z",
4
- "sourceCommit": "131eadb73d7d67a498c9363ca20648a1cc9b6b88",
3
+ "generatedAt": "2026-06-17T22:56:51.334Z",
4
+ "sourceCommit": "9ef587fe99c904bd13ddb7f7b8e399f67aec1a53",
5
5
  "sourcePath": "libs/jsonforms-components/src/index.ts",
6
6
  "rendererCount": 33,
7
7
  "renderers": [
@@ -2,6 +2,8 @@ import { ReactNode, Dispatch } from 'react';
2
2
  import { CategorizationStepperLayoutRendererProps } from '../types';
3
3
  import { StepperContextDataType, CategoryState } from './types';
4
4
  import { JsonFormStepperDispatch } from './reducer';
5
+ import { JsonSchema } from '@jsonforms/core';
6
+ import { ErrorObject } from 'ajv';
5
7
  export interface JsonFormsStepperContextProviderProps {
6
8
  children: ReactNode;
7
9
  StepperProps: CategorizationStepperLayoutRendererProps & {
@@ -29,3 +31,4 @@ export interface JsonFormsStepperContextProps {
29
31
  }
30
32
  export declare const JsonFormsStepperContext: import("react").Context<JsonFormsStepperContextProps | undefined>;
31
33
  export declare const JsonFormsStepperContextProvider: ({ children, StepperProps, }: JsonFormsStepperContextProviderProps) => JSX.Element;
34
+ export declare const getEmptyRequiredStringErrors: (data: unknown, schema: JsonSchema) => ErrorObject[];
@@ -1,58 +1,51 @@
1
1
  import { User } from '../Context/register';
2
+ import { ControlElement, Middleware, UISchemaElement } from '@jsonforms/core';
3
+ export declare const AUTO_POPULATE_SOURCES: readonly ["firstName", "lastName", "email"];
4
+ export type AutoPopulateSource = (typeof AUTO_POPULATE_SOURCES)[number];
5
+ /**
6
+ * @deprecated Field names no longer control auto-population. Use the
7
+ * UI-schema `options.autoPopulate` directive.
8
+ */
2
9
  export declare const USER_FIELD_DEFINITIONS: {
3
10
  fullName: {
4
11
  schema: {
5
12
  type: string;
6
- minLength: number;
7
- description: string;
8
13
  };
9
14
  getValue: (user: User) => string;
10
15
  };
11
16
  name: {
12
17
  schema: {
13
18
  type: string;
14
- minLength: number;
15
- description: string;
16
19
  };
17
20
  getValue: (user: User) => string;
18
21
  };
19
22
  firstName: {
20
23
  schema: {
21
24
  type: string;
22
- minLength: number;
23
- description: string;
24
25
  };
25
26
  getValue: (user: User) => string;
26
27
  };
27
28
  givenName: {
28
29
  schema: {
29
30
  type: string;
30
- minLength: number;
31
- description: string;
32
31
  };
33
32
  getValue: (user: User) => string;
34
33
  };
35
34
  lastName: {
36
35
  schema: {
37
36
  type: string;
38
- minLength: number;
39
- description: string;
40
37
  };
41
38
  getValue: (user: User) => string;
42
39
  };
43
40
  familyName: {
44
41
  schema: {
45
42
  type: string;
46
- minLength: number;
47
- description: string;
48
43
  };
49
44
  getValue: (user: User) => string;
50
45
  };
51
46
  surname: {
52
47
  schema: {
53
48
  type: string;
54
- minLength: number;
55
- description: string;
56
49
  };
57
50
  getValue: (user: User) => string;
58
51
  };
@@ -60,13 +53,6 @@ export declare const USER_FIELD_DEFINITIONS: {
60
53
  schema: {
61
54
  type: string;
62
55
  format: string;
63
- maxLength: number;
64
- pattern: string;
65
- description: string;
66
- errorMessage: {
67
- pattern: string;
68
- maxLength: string;
69
- };
70
56
  };
71
57
  getValue: (user: User) => string;
72
58
  };
@@ -74,13 +60,6 @@ export declare const USER_FIELD_DEFINITIONS: {
74
60
  schema: {
75
61
  type: string;
76
62
  format: string;
77
- maxLength: number;
78
- pattern: string;
79
- description: string;
80
- errorMessage: {
81
- pattern: string;
82
- maxLength: string;
83
- };
84
63
  };
85
64
  getValue: (user: User) => string;
86
65
  };
@@ -88,22 +67,31 @@ export declare const USER_FIELD_DEFINITIONS: {
88
67
  schema: {
89
68
  type: string;
90
69
  format: string;
91
- maxLength: number;
92
- pattern: string;
93
- description: string;
94
- errorMessage: {
95
- pattern: string;
96
- maxLength: string;
97
- };
98
70
  };
99
71
  getValue: (user: User) => string;
100
72
  };
101
73
  };
74
+ /** @deprecated Use AutoPopulateSource. */
102
75
  export type UserField = keyof typeof USER_FIELD_DEFINITIONS;
103
- export declare const autoPopulateValue: (user: User, props: {
76
+ type AutoPopulateProps = {
77
+ uischema?: {
78
+ options?: {
79
+ autoPopulate?: unknown;
80
+ };
81
+ };
82
+ };
83
+ interface AutoPopulatedValue {
104
84
  path: string;
105
- }) => string | undefined;
106
- export declare const autoPopulatePropertiesMonaco: {
107
- label: string;
108
- insertText: string;
109
- }[];
85
+ value: unknown;
86
+ }
87
+ export declare const autoPopulateValue: (user: User, props: AutoPopulateProps) => string | undefined;
88
+ export declare const getAutoPopulateControls: (element?: UISchemaElement) => ControlElement[];
89
+ export declare const getAutoPopulatedData: (uischema: UISchemaElement | undefined, user?: User) => AutoPopulatedValue[];
90
+ export declare const mergeAutoPopulatedData: (data: unknown, autoPopulatedData: AutoPopulatedValue[]) => any;
91
+ export declare const createAutoPopulateMiddleware: (uischema: UISchemaElement | undefined, user?: User) => Middleware;
92
+ /**
93
+ * Retained for compatibility with consumers of the previous data-schema
94
+ * autocomplete API. Auto-population is now configured in the UI schema.
95
+ */
96
+ export declare const autoPopulatePropertiesMonaco: never[];
97
+ export {};
@@ -14,6 +14,9 @@ export declare const OPTION_DEFINITIONS: {
14
14
  emailFirst: {
15
15
  schema: boolean;
16
16
  };
17
+ autoPopulate: {
18
+ schema: string;
19
+ };
17
20
  noDataMessage: {
18
21
  schema: string;
19
22
  };