@abgov/jsonforms-components 1.41.5 → 1.42.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
@@ -2341,6 +2341,9 @@ fixRegExpWellKnownSymbolLogic$1('replace', function (_, nativeReplace, maybeCall
2341
2341
  ];
2342
2342
  }, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE);
2343
2343
 
2344
+ const sinTitle = 'Social insurance number';
2345
+ const invalidSin = 'Social insurance number is invalid';
2346
+
2344
2347
  /**
2345
2348
  * Sets the first word to be capitalized so that it is sentence cased.
2346
2349
  * @param words
@@ -2422,10 +2425,10 @@ const checkFieldValidity = props => {
2422
2425
  } = props;
2423
2426
  const labelToUpdate = getLabelText(uischema.scope, label);
2424
2427
  const extraSchema = schema;
2425
- if (extraSchema && data && (extraSchema === null || extraSchema === void 0 ? void 0 : extraSchema.title) === 'Social insurance number') {
2428
+ if (extraSchema && data && (extraSchema === null || extraSchema === void 0 ? void 0 : extraSchema.title) === sinTitle) {
2426
2429
  if (data.length === 11 && !validateSinWithLuhn(data)) {
2427
- return 'Social insurance number is invalid';
2428
- } else if (data.length < 11) {
2430
+ return data === '' ? '' : invalidSin;
2431
+ } else if (data.length > 0 && data.length < 11) {
2429
2432
  return extraSchema.errorMessage;
2430
2433
  }
2431
2434
  }
@@ -3822,7 +3825,7 @@ const GoAInputText = props => {
3822
3825
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
3823
3826
  const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
3824
3827
  const errorsFormInput = checkFieldValidity(props);
3825
- const isSinField = schema.title === 'Social insurance number';
3828
+ const isSinField = schema.title === sinTitle;
3826
3829
  const autoCapitalize = ((_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.autoCapitalize) === true || ((_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.autoCapitalize) === true;
3827
3830
  const readOnly = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.readOnly) !== null && _f !== void 0 ? _f : false;
3828
3831
  return jsx(GoAInput, Object.assign({
@@ -3843,7 +3846,7 @@ const GoAInputText = props => {
3843
3846
  // side effect that causes the validation to render when it shouldn't.
3844
3847
  onChange: (name, value) => {
3845
3848
  let formattedValue = value;
3846
- if (schema && schema.title === 'Social insurance number') {
3849
+ if (schema && schema.title === sinTitle && value !== '') {
3847
3850
  formattedValue = formatSin(value);
3848
3851
  }
3849
3852
  onChangeForInputControl({
@@ -5513,10 +5516,11 @@ const RenderStepElements = props => {
5513
5516
  );
5514
5517
  };
5515
5518
 
5519
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5516
5520
  const validateData = (jsonSchema, data, ajv) => {
5517
5521
  const newSchema = JSON.parse(JSON.stringify(jsonSchema));
5518
5522
  Object.keys(newSchema.properties || {}).forEach(propertyName => {
5519
- var _a, _b, _c, _d;
5523
+ var _a, _b, _c, _d, _e;
5520
5524
  const property = newSchema.properties || {};
5521
5525
  if (((_a = property[propertyName]) === null || _a === void 0 ? void 0 : _a.enum) && ((_b = property[propertyName]) === null || _b === void 0 ? void 0 : _b.enum[0]) === '') {
5522
5526
  (_c = property[propertyName]) === null || _c === void 0 ? true : delete _c.enum;
@@ -5524,6 +5528,9 @@ const validateData = (jsonSchema, data, ajv) => {
5524
5528
  if (((_d = property[propertyName]) === null || _d === void 0 ? void 0 : _d.format) === 'file-urn') {
5525
5529
  delete property[propertyName].format;
5526
5530
  }
5531
+ if (((_e = property[propertyName]) === null || _e === void 0 ? void 0 : _e.title) === sinTitle && data && data[propertyName] === '') {
5532
+ delete data[propertyName];
5533
+ }
5527
5534
  });
5528
5535
  try {
5529
5536
  const validate = ajv.compile(newSchema);
@@ -5765,8 +5772,7 @@ const FormStepper = props => {
5765
5772
  },
5766
5773
  children: readOnly ? 'View' : 'Edit'
5767
5774
  })]
5768
- }), jsx(GoAGrid, {
5769
- minChildWidth: "600px",
5775
+ }), jsx("div", {
5770
5776
  children: category.elements.filter(field => {
5771
5777
  var _a, _b;
5772
5778
  const conditionProps = (_a = field.rule) === null || _a === void 0 ? void 0 : _a.condition;
@@ -8411,6 +8417,7 @@ const FullNameControl = props => {
8411
8417
  };
8412
8418
  const [nameData, setNameData] = useState(data || defaultName);
8413
8419
  const updateFormData = updatedData => {
8420
+ updatedData = Object.fromEntries(Object.entries(updatedData).filter(([_, value]) => value !== ''));
8414
8421
  handleChange(path, updatedData);
8415
8422
  };
8416
8423
  const handleInputChange = (field, value) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.41.5",
3
+ "version": "1.42.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,3 +1,3 @@
1
1
  import { JsonSchema } from '@jsonforms/core';
2
2
  import Ajv from 'ajv';
3
- export declare const validateData: (jsonSchema: JsonSchema, data: unknown, ajv: Ajv) => boolean;
3
+ export declare const validateData: (jsonSchema: JsonSchema, data: any, ajv: Ajv) => boolean;
@@ -0,0 +1,2 @@
1
+ export declare const sinTitle = "Social insurance number";
2
+ export declare const invalidSin = "Social insurance number is invalid";