@abgov/jsonforms-components 1.36.1 → 1.37.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
@@ -7927,29 +7927,37 @@ const AddressLookUpControl = props => {
7927
7927
  });
7928
7928
  };
7929
7929
 
7930
- const isAddressSchema = obj => {
7930
+ const isPropertiesMatch = (obj, props, isExactMatch) => {
7931
7931
  if (isObject$e(obj)) {
7932
7932
  const keys = Object.keys(obj);
7933
- return ['addressLine2', 'municipality', 'addressLine1', 'subdivisionCode', 'postalCode'].every(attr => keys.includes(attr));
7933
+ if (isExactMatch) {
7934
+ return props.every(attr => keys.includes(attr)) && keys.length === props.length;
7935
+ } else {
7936
+ return props.every(attr => keys.includes(attr));
7937
+ }
7934
7938
  }
7935
7939
  return false;
7936
7940
  };
7937
- const isAddressLookup = (uischema, schema, context) => {
7938
- if (!isControl(uischema) || !isScoped(uischema)) {
7939
- return false;
7940
- }
7941
- if ((schema === null || schema === void 0 ? void 0 : schema.properties) && isObject$e(schema === null || schema === void 0 ? void 0 : schema.properties)) {
7942
- const propertyFromScope = uischema['scope'].split('/').pop();
7943
- if (isObject$e(schema.properties[propertyFromScope]) && 'properties' in schema.properties[propertyFromScope]) {
7944
- const objToTest = schema.properties[propertyFromScope]['properties'];
7945
- if (objToTest && isAddressSchema(objToTest)) {
7946
- return true;
7941
+ const createSchemaMatchTester = (props, isExactMatch = false) => {
7942
+ return (uischema, schema, context) => {
7943
+ if (!isControl(uischema) || !isScoped(uischema)) {
7944
+ return false;
7945
+ }
7946
+ if ((schema === null || schema === void 0 ? void 0 : schema.properties) && isObject$e(schema === null || schema === void 0 ? void 0 : schema.properties)) {
7947
+ const propertyFromScope = uischema['scope'].split('/').pop();
7948
+ if (isObject$e(schema.properties[propertyFromScope]) && 'properties' in schema.properties[propertyFromScope]) {
7949
+ const objToTest = schema.properties[propertyFromScope]['properties'];
7950
+ if (objToTest && isPropertiesMatch(objToTest, props, isExactMatch)) {
7951
+ return true;
7952
+ }
7947
7953
  }
7948
7954
  }
7949
- }
7950
- return false;
7955
+ return false;
7956
+ };
7951
7957
  };
7952
- const AddressLookUpTester = rankWith(3, isAddressLookup);
7958
+
7959
+ const isAddressLookup = createSchemaMatchTester(['addressLine2', 'municipality', 'addressLine1', 'subdivisionCode', 'postalCode']);
7960
+ const AddressLookUpTester = rankWith(4, isAddressLookup);
7953
7961
 
7954
7962
  const GoATextCell = props => jsx(GoAInputText, Object.assign({}, props));
7955
7963
  const GoATextCellTester = rankWith(1, isStringControl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.36.1",
3
+ "version": "1.37.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,3 +1,3 @@
1
- import { RankedTester, UISchemaElement, JsonSchema, TesterContext } from '@jsonforms/core';
2
- export declare const isAddressLookup: (uischema: UISchemaElement, schema: JsonSchema, context: TesterContext) => boolean;
1
+ import { RankedTester } from '@jsonforms/core';
2
+ export declare const isAddressLookup: import("@jsonforms/core").Tester;
3
3
  export declare const AddressLookUpTester: RankedTester;
@@ -0,0 +1,3 @@
1
+ import { Tester, RankedTester } from '@jsonforms/core';
2
+ export declare const createSchemaMatchTester: (props: string[], isExactMatch?: boolean) => Tester;
3
+ export declare const createSchemaMatchRankedTester: (props: string[], isExactMatch?: boolean) => RankedTester;