@abgov/jsonforms-components 1.35.5 → 1.36.0

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,9 +4,9 @@ import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputD
4
4
  import styled from 'styled-components';
5
5
  import axios from 'axios';
6
6
  import get$1 from 'lodash/get';
7
- import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, getAjv, isVisible, isEnabled, deriveLabelForUISchemaElement, schemaTypeIs, formatIs, createDefaultValue, Paths, or, isObjectArrayControl, isPrimitiveArrayControl, isObjectControl, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
7
+ import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, getAjv, isVisible, isEnabled, deriveLabelForUISchemaElement, schemaTypeIs, formatIs, createDefaultValue, Paths, or, isObjectArrayControl, isPrimitiveArrayControl, isControl, isScoped, hasType, isCategorization, isLayout } from '@jsonforms/core';
8
8
  import { withJsonFormsControlProps, withJsonFormsRendererProps, withJsonFormsEnumProps, withTranslateProps, useJsonForms, JsonFormsDispatch, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
9
- import { isEqual } from 'lodash';
9
+ import { isEqual, isObject as isObject$e } from 'lodash';
10
10
  import merge from 'lodash/merge';
11
11
  import isEmpty$1 from 'lodash/isEmpty';
12
12
  import range from 'lodash/range';
@@ -7718,7 +7718,7 @@ const AddressLookUpControl = props => {
7718
7718
  setErrors({});
7719
7719
  };
7720
7720
  const handleRequiredFieldBlur = name => {
7721
- if ((!(data === null || data === void 0 ? void 0 : data[name]) || (data === null || data === void 0 ? void 0 : data[name]) === '') && requiredFields.includes(name)) {
7721
+ if ((!(data === null || data === void 0 ? void 0 : data[name]) || (data === null || data === void 0 ? void 0 : data[name]) === '') && (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes(name))) {
7722
7722
  const err = Object.assign({}, errors);
7723
7723
  err[name] = name === 'municipality' ? `city is required` : `${name} is required`;
7724
7724
  setErrors(err);
@@ -7765,7 +7765,29 @@ const AddressLookUpControl = props => {
7765
7765
  });
7766
7766
  };
7767
7767
 
7768
- const AddressLookUpTester = rankWith(3, isObjectControl);
7768
+ const isAddressSchema = obj => {
7769
+ if (isObject$e(obj)) {
7770
+ const keys = Object.keys(obj);
7771
+ return ['addressLine2', 'municipality', 'addressLine1', 'subdivisionCode', 'postalCode'].every(attr => keys.includes(attr));
7772
+ }
7773
+ return false;
7774
+ };
7775
+ const isAddressLookup = (uischema, schema, context) => {
7776
+ if (!isControl(uischema) || !isScoped(uischema)) {
7777
+ return false;
7778
+ }
7779
+ if ((schema === null || schema === void 0 ? void 0 : schema.properties) && isObject$e(schema === null || schema === void 0 ? void 0 : schema.properties)) {
7780
+ const propertyFromScope = uischema['scope'].split('/').pop();
7781
+ if (isObject$e(schema.properties[propertyFromScope]) && 'properties' in schema.properties[propertyFromScope]) {
7782
+ const objToTest = schema.properties[propertyFromScope]['properties'];
7783
+ if (objToTest && isAddressSchema(objToTest)) {
7784
+ return true;
7785
+ }
7786
+ }
7787
+ }
7788
+ return false;
7789
+ };
7790
+ const AddressLookUpTester = rankWith(3, isAddressLookup);
7769
7791
 
7770
7792
  const GoATextCell = props => jsx(GoAInputText, Object.assign({}, props));
7771
7793
  const GoATextCellTester = rankWith(1, isStringControl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.35.5",
3
+ "version": "1.36.0",
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,2 +1,3 @@
1
- import { RankedTester } from '@jsonforms/core';
1
+ import { RankedTester, UISchemaElement, JsonSchema, TesterContext } from '@jsonforms/core';
2
+ export declare const isAddressLookup: (uischema: UISchemaElement, schema: JsonSchema, context: TesterContext) => boolean;
2
3
  export declare const AddressLookUpTester: RankedTester;